@remoteoss/remote-flows 0.4.0-alpha.13 → 0.4.0-alpha.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-KGSIUWBI.js → chunk-26PHG6H2.js} +2 -2
- package/dist/{chunk-Z3HWTDRE.js → chunk-2NLOH7NZ.js} +2 -2
- package/dist/{chunk-X6DRD2I4.js → chunk-4J55VB37.js} +2 -2
- package/dist/chunk-4UBZTJMC.js +2 -0
- package/dist/chunk-4UBZTJMC.js.map +1 -0
- package/dist/{chunk-D53FKWGJ.js → chunk-6ACAZ6EG.js} +2 -2
- package/dist/{chunk-U6OPL6WG.js → chunk-6SWZH7KI.js} +2 -2
- package/dist/{chunk-OS3QI7CV.js → chunk-AI2TYE56.js} +2 -2
- package/dist/{chunk-AOJAZ4FT.js → chunk-BMEK4OFQ.js} +2 -2
- package/dist/{chunk-QKTDO33H.js → chunk-BYKZON2I.js} +2 -2
- package/dist/{chunk-RDAO365M.js → chunk-CVTAWW6F.js} +2 -2
- package/dist/{chunk-RDAO365M.js.map → chunk-CVTAWW6F.js.map} +1 -1
- package/dist/chunk-EIWJKCKN.js +2 -0
- package/dist/chunk-EIWJKCKN.js.map +1 -0
- package/dist/{chunk-BYFO5OB6.js → chunk-G7P5P2TG.js} +2 -2
- package/dist/{chunk-NIOH7TNP.js → chunk-HAOVUJOL.js} +2 -2
- package/dist/{chunk-QUM7V5EP.js → chunk-HXZSZEOG.js} +2 -2
- package/dist/{chunk-RFYJGH2X.js → chunk-MA4IML3T.js} +2 -2
- package/dist/{chunk-XQXFQ7LM.js → chunk-NBGOLNUH.js} +2 -2
- package/dist/{chunk-IEZAM2XO.js → chunk-OOVMHJTY.js} +2 -2
- package/dist/{chunk-ASFAGLQI.js → chunk-Q4KOH5ZH.js} +2 -2
- package/dist/{chunk-WRKHWEZA.js → chunk-QW4JPW6J.js} +1 -1
- package/dist/chunk-QW4JPW6J.js.map +1 -0
- package/dist/{chunk-O4PJ6GWS.js → chunk-RDLTU3FE.js} +2 -2
- package/dist/chunk-RLETCEUU.js +2 -0
- package/dist/chunk-RLETCEUU.js.map +1 -0
- package/dist/{chunk-4BOE6EEO.js → chunk-X3YONWNH.js} +2 -2
- package/dist/{chunk-H4BI3LJD.js → chunk-Y56L3QKM.js} +2 -2
- package/dist/{chunk-OP4QGFLS.js → chunk-ZUNKCQBT.js} +2 -2
- package/dist/flows/ContractAmendment/ContractAmendmentFlow.js +1 -1
- package/dist/flows/ContractAmendment/ContractAmendmentForm.js +1 -1
- package/dist/flows/ContractAmendment/hooks.js +1 -1
- package/dist/flows/ContractAmendment/index.js +1 -1
- package/dist/flows/CostCalculator/CostCalculatorForm.js +1 -1
- package/dist/flows/CostCalculator/index.js +1 -1
- package/dist/flows/Onboarding/AnnualGrossSalary.js +1 -1
- package/dist/flows/Onboarding/BasicInformationStep.js +1 -1
- package/dist/flows/Onboarding/BenefitsStep.js +1 -1
- package/dist/flows/Onboarding/ContractDetailsStep.js +1 -1
- package/dist/flows/Onboarding/OnboardingFlow.js +1 -1
- package/dist/flows/Onboarding/OnboardingForm.js +1 -1
- package/dist/flows/Onboarding/OnboardingInvite.js +1 -1
- package/dist/flows/Onboarding/SelectCountryStep.js +1 -1
- package/dist/flows/Onboarding/context.d.ts +7 -2
- package/dist/flows/Onboarding/hooks.d.ts +7 -2
- package/dist/flows/Onboarding/hooks.js +1 -1
- package/dist/flows/Onboarding/index.d.ts +1 -1
- package/dist/flows/Onboarding/index.js +1 -1
- package/dist/flows/Onboarding/types.d.ts +8 -1
- package/dist/flows/Onboarding/utils.js +1 -1
- package/dist/flows/Termination/AdditionalDetailsForm.js +1 -1
- package/dist/flows/Termination/EmployeeComunicationForm.js +1 -1
- package/dist/flows/Termination/PaidTimeOffForm.js +1 -1
- package/dist/flows/Termination/TerminationDetailsForm.js +1 -1
- package/dist/flows/Termination/TerminationFlow.js +1 -1
- package/dist/flows/Termination/TerminationForm.js +1 -1
- package/dist/flows/Termination/hooks.js +1 -1
- package/dist/flows/Termination/index.js +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-7JHIPWS7.js +0 -2
- package/dist/chunk-7JHIPWS7.js.map +0 -1
- package/dist/chunk-7N7ND6Z4.js +0 -2
- package/dist/chunk-7N7ND6Z4.js.map +0 -1
- package/dist/chunk-GFMFGU7A.js +0 -2
- package/dist/chunk-GFMFGU7A.js.map +0 -1
- package/dist/chunk-WRKHWEZA.js.map +0 -1
- /package/dist/{chunk-KGSIUWBI.js.map → chunk-26PHG6H2.js.map} +0 -0
- /package/dist/{chunk-Z3HWTDRE.js.map → chunk-2NLOH7NZ.js.map} +0 -0
- /package/dist/{chunk-X6DRD2I4.js.map → chunk-4J55VB37.js.map} +0 -0
- /package/dist/{chunk-D53FKWGJ.js.map → chunk-6ACAZ6EG.js.map} +0 -0
- /package/dist/{chunk-U6OPL6WG.js.map → chunk-6SWZH7KI.js.map} +0 -0
- /package/dist/{chunk-OS3QI7CV.js.map → chunk-AI2TYE56.js.map} +0 -0
- /package/dist/{chunk-AOJAZ4FT.js.map → chunk-BMEK4OFQ.js.map} +0 -0
- /package/dist/{chunk-QKTDO33H.js.map → chunk-BYKZON2I.js.map} +0 -0
- /package/dist/{chunk-BYFO5OB6.js.map → chunk-G7P5P2TG.js.map} +0 -0
- /package/dist/{chunk-NIOH7TNP.js.map → chunk-HAOVUJOL.js.map} +0 -0
- /package/dist/{chunk-QUM7V5EP.js.map → chunk-HXZSZEOG.js.map} +0 -0
- /package/dist/{chunk-RFYJGH2X.js.map → chunk-MA4IML3T.js.map} +0 -0
- /package/dist/{chunk-XQXFQ7LM.js.map → chunk-NBGOLNUH.js.map} +0 -0
- /package/dist/{chunk-IEZAM2XO.js.map → chunk-OOVMHJTY.js.map} +0 -0
- /package/dist/{chunk-ASFAGLQI.js.map → chunk-Q4KOH5ZH.js.map} +0 -0
- /package/dist/{chunk-O4PJ6GWS.js.map → chunk-RDLTU3FE.js.map} +0 -0
- /package/dist/{chunk-4BOE6EEO.js.map → chunk-X3YONWNH.js.map} +0 -0
- /package/dist/{chunk-H4BI3LJD.js.map → chunk-Y56L3QKM.js.map} +0 -0
- /package/dist/{chunk-OP4QGFLS.js.map → chunk-ZUNKCQBT.js.map} +0 -0
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as t}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{a as t}from"./chunk-6SWZH7KI.js";import{b as a}from"./chunk-MRYRNB7Y.js";import{a as i}from"./chunk-P37U34EQ.js";import{jsx as p}from"react/jsx-runtime";function F({requesterName:n,onSubmit:s,onSuccess:m,onError:d}){let{terminationBag:e}=a(),l=i(async o=>{await s?.(e?.parseFormValues(o));let r=await e?.onSubmit(o);r?.error?d?.(r.error):r?.data&&await m?.(r.data)},"handleSubmit"),u=e?.fields.map(o=>o.name==="acknowledge_termination_procedure"?{...o,label:o.label.replace("{{requesterName}}",n)}:o);return p(t,{fields:u,onSubmit:l})}i(F,"AdditionalDetailsForm");export{F as a};
|
|
2
|
+
//# sourceMappingURL=chunk-26PHG6H2.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as $e}from"./chunk-XO3JWN33.js";import{a as A}from"./chunk-GFMFGU7A.js";import{a as ge,b as B}from"./chunk-GEYFQVQI.js";import{b as x}from"./chunk-3ZWDIEEM.js";import{a as Me,b as C,c as R,d as S,e as N,f as w,g as T}from"./chunk-VNSF5IOL.js";import{a as m}from"./chunk-KPHSEIR3.js";import{a as o}from"./chunk-P37U34EQ.js";import{Fragment as zo}from"react";import*as He from"react";import*as ee from"@radix-ui/react-checkbox";import{Check as Dt}from"lucide-react";import{jsx as ve}from"react/jsx-runtime";var te=He.forwardRef(({className:e,...t},r)=>ve(ee.Root,{ref:r,className:m("peer h-4 w-4 shrink-0 rounded-sm border border-input ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-checkbox data-[state=checked]:text-primary",e),...t,children:ve(ee.Indicator,{className:m("flex items-center justify-center text-current"),children:ve(Dt,{className:"h-4 w-4"})})}));te.displayName=ee.Root.displayName;import{useFormContext as Tt}from"react-hook-form";import{Fragment as It,jsx as z,jsxs as oe}from"react/jsx-runtime";function re({name:e,defaultValue:t,description:r,label:a,onChange:i,multiple:d,options:p,component:g,...v}){let{components:n}=x(),{control:c}=Tt(),u=o((s,l,h)=>{let f=h.value?[...h.value]:[];l?f.includes(s)||h.onChange([...f,s]):h.onChange(f.filter(_=>_!==s))},"handleCheckboxChange");return z(C,{control:c,name:e,defaultValue:t,render:({field:s,fieldState:l})=>{let h=g||n?.checkbox;if(h){let f={name:e,description:r,label:a,defaultValue:t,multiple:d,options:p,...v};return z(h,{field:{...s,onChange:o(_=>{if(d){let{checked:k,value:b}=_.target;u(b,k,s),i?.(k);return}s.onChange(_),i?.(_)},"onChange")},fieldState:l,fieldData:f})}return oe(R,{"data-field":e,className:m(`RemoteFlows__CheckBoxField__Item__${e}`),children:[z(N,{children:oe(It,{children:[p&&d?z(S,{children:a}):null,p&&d?p.map(f=>oe("div",{className:"flex space-x-2",children:[z(te,{id:f.value,onCheckedChange:_=>{u(f.value,_===!0,s),i?.(_,f.value)},checked:s.value?.includes(f.value),className:"RemoteFlows__CheckBox__Input"}),z(S,{htmlFor:f.value,className:"mb-0 RemoteFlows__CheckBox__Label",children:f.label})]},f.value)):oe("div",{className:"flex space-x-2",children:[z(te,{id:e,onCheckedChange:f=>{s.onChange(f),i?.(f)},checked:s.value,className:"RemoteFlows__CheckBox__Input"}),z(S,{htmlFor:e,className:"mb-0 RemoteFlows__CheckBox__Label",children:a})]})]})}),r&&z(w,{children:r}),l.error&&z(T,{})]})}})}o(re,"CheckBoxField");import{CalendarIcon as $t}from"lucide-react";import{useFormContext as Ht}from"react-hook-form";import{ChevronLeft as Wt,ChevronRight as Lt}from"lucide-react";import{DayPicker as Mt}from"react-day-picker";import{jsx as Fe}from"react/jsx-runtime";function Ee({className:e,classNames:t,showOutsideDays:r=!0,...a}){return Fe(Mt,{showOutsideDays:r,className:m("p-3",e),classNames:{months:"flex flex-col sm:flex-row gap-2",month:"flex flex-col gap-4",caption:"flex justify-center pt-1 relative items-center w-full",caption_label:"text-sm font-medium",nav:"flex items-center gap-1",nav_button:m(ge({variant:"outline"}),"size-7 bg-transparent p-0 opacity-50 hover:opacity-100"),nav_button_previous:"absolute left-1",nav_button_next:"absolute right-1",table:"w-full border-collapse space-x-1",head_row:"flex",head_cell:"text-muted-foreground rounded-md w-8 font-normal text-[0.8rem]",row:"flex w-full mt-2",cell:m("relative p-0 text-center text-sm focus-within:relative focus-within:z-20 [&:has([aria-selected])]:bg-accent [&:has([aria-selected].day-range-end)]:rounded-r-md",a.mode==="range"?"[&:has(>.day-range-end)]:rounded-r-md [&:has(>.day-range-start)]:rounded-l-md first:[&:has([aria-selected])]:rounded-l-md last:[&:has([aria-selected])]:rounded-r-md":"[&:has([aria-selected])]:rounded-md"),day:m(ge({variant:"ghost"}),"size-8 p-0 font-normal aria-selected:opacity-100"),day_range_start:"day-range-start aria-selected:bg-primary aria-selected:text-primary-foreground",day_range_end:"day-range-end aria-selected:bg-primary aria-selected:text-primary-foreground",day_selected:"bg-primary text-primary-foreground hover:bg-primary hover:text-primary-foreground focus:bg-primary focus:text-primary-foreground",day_today:"bg-accent text-accent-foreground",day_outside:"day-outside text-muted-foreground aria-selected:text-muted-foreground",day_disabled:"text-muted-foreground opacity-50",day_range_middle:"aria-selected:bg-accent aria-selected:text-accent-foreground",day_hidden:"invisible",...t},components:{IconLeft:o(({className:i,...d})=>Fe(Wt,{className:m("size-4",i),...d}),"IconLeft"),IconRight:o(({className:i,...d})=>Fe(Lt,{className:m("size-4",i),...d}),"IconRight")},...a})}o(Ee,"Calendar");import*as O from"@radix-ui/react-popover";import{jsx as ae}from"react/jsx-runtime";function ne({...e}){return ae(O.Root,{"data-slot":"popover",...e})}o(ne,"Popover");function ie({...e}){return ae(O.Trigger,{"data-slot":"popover-trigger",...e})}o(ie,"PopoverTrigger");function se({className:e,align:t="center",sideOffset:r=4,...a}){return ae(O.Portal,{children:ae(O.Content,{"data-slot":"popover-content",align:t,sideOffset:r,className:m("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-72 origin-(--radix-popover-content-transform-origin) rounded-md border p-4 shadow-md outline-hidden",e),...a})})}o(se,"PopoverContent");import{PopoverClose as Et}from"@radix-ui/react-popover";import{format as Be}from"date-fns";import{Fragment as Bt,jsx as W,jsxs as he}from"react/jsx-runtime";function Ae({description:e,label:t,name:r,minDate:a,onChange:i,component:d,...p}){let{components:g}=x(),{control:v}=Ht();return W(C,{control:v,name:r,render:({field:n,fieldState:c})=>{let u=d||g?.date;if(u){let s={description:e,label:t,name:r,minDate:a,onChange:i,...p};return W(u,{field:{...n,onChange:o(l=>{n.onChange(l),i?.(l)},"onChange")},fieldState:c,fieldData:s})}return he(R,{"data-field":r,className:`flex flex-col RemoteFlows__DatePickerField__Item__${r}`,children:[W(S,{className:"RemoteFlows__DatePickerField__Label",children:t}),he(ne,{children:[W(ie,{asChild:!0,children:W(N,{children:W("div",{children:he(B,{type:"button",variant:"outline",className:m("w-full pl-3 text-left font-normal",!n.value&&"text-muted-foreground"),"data-testid":`date-picker-button-${r}`,children:[n.value&&W(Bt,{children:Be(n.value,"yyyy-MM-dd")}),W($t,{className:"ml-auto h-4 w-4 opacity-50"})]})})})}),W(se,{className:"w-auto p-0 RemoteFlows__DatepickerField__PopoverContent",align:"start",children:W(Ee,{mode:"single",className:"RemoteFlows__DatepickerField__Calendar",selected:n.value?new Date(n.value):void 0,onSelect:s=>{n.onChange(s?Be(s,"yyyy-MM-dd"):null),i?.(s)},defaultMonth:a?new Date(a):void 0,components:{DayContent:o(s=>W(Et,{children:s.date.getDate()}),"DayContent")},...a&&{disabled:o(s=>s<new Date(a),"disabled")}})})]}),e?W(w,{children:e}):null,c.error&&W(T,{className:"RemoteFlows__DatePickerField__Error"})]})}})}o(Ae,"DatePickerField");import{cva as At}from"class-variance-authority";import{jsx as ye}from"react/jsx-runtime";var zt=At("relative w-full rounded-lg border px-4 py-3 text-sm grid has-[>svg]:grid-cols-[calc(var(--spacing)*4)_1fr] grid-cols-[0_1fr] has-[>svg]:gap-x-3 gap-y-0.5 items-start [&>svg]:size-4 [&>svg]:translate-y-0.5 [&>svg]:text-current",{variants:{variant:{default:"bg-card text-card-foreground",destructive:"text-destructive bg-card [&>svg]:text-current *:data-[slot=alert-description]:text-destructive/90",warning:"bg-card bg-warning border-warning-border [&>svg]:text-current"}},defaultVariants:{variant:"default"}});function ze({className:e,variant:t,...r}){return ye("div",{"data-slot":"alert",role:"alert",className:m(zt({variant:t}),e),...r})}o(ze,"Alert");function Oe({className:e,...t}){return ye("div",{"data-slot":"alert-title",className:m("col-start-2 line-clamp-1 min-h-4 font-medium tracking-tight",e),...t})}o(Oe,"AlertTitle");function Ge({className:e,...t}){return ye("div",{"data-slot":"alert-description",className:m("text-muted-foreground col-start-2 grid justify-items-start gap-1 text-sm [&_p]:leading-relaxed",e),...t})}o(Ge,"AlertDescription");import{AlertCircle as Ot}from"lucide-react";import{jsx as le,jsxs as Gt}from"react/jsx-runtime";function me({title:e,description:t,severity:r}){let{components:a}=x();if(a?.statement){let i=a?.statement;return le(i,{data:{title:e,description:t,severity:r}})}return Gt(ze,{variant:"warning",children:[le(Ot,{className:"h-4 w-4"}),e&&le(Oe,{children:e}),le(Ge,{children:t})]})}o(me,"Statement");import{jsx as _e,jsxs as Ve}from"react/jsx-runtime";import{createElement as Vt}from"react";function Ue({label:e,name:t,fields:r,description:a,components:i,statement:d}){return Ve("fieldset",{className:m("border-1 border-input p-4 rounded-xl",`RemoteFlows__FieldSetField__${t}`),children:[_e("legend",{className:"text-sm font-semibold px-2",children:e}),a?_e("div",{className:"mb-5 RemoteFlows__FieldSetField__Description",dangerouslySetInnerHTML:{__html:a}}):null,Ve("div",{className:"grid gap-4",children:[r.map(p=>{let g=ce[p.type];return p.isVisible===!1||p.deprecated?null:Vt(g,{...p,key:p.name,name:`${t}.${p.name}`,component:i?.[p.type]})}),d?_e(me,{...d}):null]})]})}o(Ue,"FieldSetField");import{useFormContext as Yt}from"react-hook-form";import{useState as Ut,useRef as Jt}from"react";import{Upload as qt,X as Kt}from"lucide-react";import{jsx as V,jsxs as xe}from"react/jsx-runtime";function Je({onChange:e,className:t,multiple:r}){let[a,i]=Ut([]),d=Jt(null),p=o(n=>{n.preventDefault(),d.current?.click()},"handleClick"),g=o(n=>{if(n.target.files&&n.target.files.length>0){let c=Array.from(n.target.files);i(c),e(n)}},"handleChange"),v=o(n=>{i(c=>c.filter(u=>u!==n))},"onRemoveFile");return xe("div",{className:m("flex flex-col items-start gap-4",t),children:[V("input",{type:"file",ref:d,onChange:g,className:"hidden","aria-label":"File upload",multiple:r}),xe(B,{type:"button",onClick:p,className:"gap-2",children:[V(qt,{className:"h-4 w-4"}),"Choose File"]}),a.length===0&&V("div",{className:"text-sm",children:r?V("span",{className:"font-medium",children:"No files selected. You can select multiple files"}):V("span",{className:"font-medium",children:"No file selected."})}),a.length>0&&a.map((n,c)=>xe("div",{className:"text-sm flex items-center gap-2",children:["Selected file: ",V("span",{className:"font-medium",children:n.name})," (",Math.round(n.size/1024)," KB)",V(B,{variant:"ghost",onClick:()=>v(n),children:V(Kt,{})})]},c))]})}o(Je,"FileUploader");import{jsx as U,jsxs as Qt}from"react/jsx-runtime";var Xt=o(e=>new Promise((t,r)=>{let a=new FileReader;a.readAsDataURL(e),a.onload=()=>t(a.result),a.onerror=i=>r(i)}),"toBase64"),qe=o(async e=>{let t=e.target.files?Array.from(e.target.files):[];return await Promise.all(t.map(async a=>{let i=await Xt(a);return{name:a.name,content:i.split(",")[1]}}))},"convertFilesToBase64");function Ke({name:e,description:t,label:r,multiple:a,onChange:i,component:d,...p}){let{components:g}=x(),{control:v}=Yt();return U(C,{control:v,name:e,render:({field:n,fieldState:c})=>{let u=d||g?.file;if(u){let s={name:e,description:t,label:r,multiple:a,...p};return U(u,{field:{...n,value:null,onChange:o(async l=>{let h=await qe(l);n.onChange(h),i?.(h)},"onChange")},fieldState:c,fieldData:s})}return Qt(R,{"data-field":e,className:`RemoteFlows__FileUpload__Item__${e}`,children:[U(S,{className:"RemoteFlows__FileUpload__Label",children:r}),U(N,{children:U(Je,{onChange:async s=>{let l=await qe(s);n.onChange(l),i?.(l)},multiple:a,className:m("RemoteFlows__FileUpload__Input")})}),t&&U("div",{className:"flex items-center justify-between",children:U(w,{className:"RemoteFlows__FileUpload__Description",children:t})}),c.error&&U(T,{className:"RemoteFlows__FileUpload__Error"})]})}})}o(Ke,"FileUploadField");import{useFormContext as Zt}from"react-hook-form";import{jsx as Ce}from"react/jsx-runtime";function be(e){let{components:t}=x(),{control:r}=Zt(),a=e.component||t?.number;return a?Ce(C,{control:r,name:e.name,render:({field:i,fieldState:d})=>Ce(a,{field:{...i,onChange:o(p=>{i.onChange(p),e.onChange?.(p)},"onChange")},fieldState:d,fieldData:e})}):Ce(A,{...e,type:"text",inputMode:"decimal",pattern:"^[0-9.]*$"})}o(be,"NumberField");import*as K from"@radix-ui/react-radio-group";import{CircleIcon as jt}from"lucide-react";import{jsx as de}from"react/jsx-runtime";function Ye({className:e,...t}){return de(K.Root,{"data-slot":"radio-group",className:m("grid gap-3",e),...t})}o(Ye,"RadioGroup");function Xe({className:e,...t}){return de(K.Item,{"data-slot":"radio-group-item",className:m("border-input text-primary focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive aspect-square size-4 shrink-0 rounded-full border shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50",e),...t,children:de(K.Indicator,{"data-slot":"radio-group-indicator",className:"relative flex items-center justify-center",children:de(jt,{className:"fill-radio absolute top-1/2 left-1/2 size-2 -translate-x-1/2 -translate-y-1/2"})})})}o(Xe,"RadioGroupItem");import{useFormContext as eo}from"react-hook-form";import{Fragment as to,jsx as $,jsxs as Se}from"react/jsx-runtime";function Qe({name:e,defaultValue:t,description:r,label:a,options:i,onChange:d,component:p,...g}){let{components:v}=x(),{control:n}=eo();return $(C,{control:n,name:e,defaultValue:t,render:({field:c,fieldState:u})=>{let s=p||v?.radio;if(s){let l={name:e,defaultValue:t,description:r,label:a,options:i,...g};return $(s,{field:{...c,onChange:o(h=>{c.onChange(h),d?.(h)},"onChange")},fieldState:u,fieldData:l})}return Se(R,{className:m("space-y-3",`RemoteFlows__RadioGroupField__Item__${e}`),"data-field":e,children:[$(S,{children:a}),$(N,{children:$(Ye,{"aria-label":a||e,onValueChange:l=>{c.onChange(l),d?.(l)},value:c.value,className:"flex flex-col space-y-3",children:i?.map(l=>$(to,{children:Se(R,{"data-field":e,className:"flex items-start space-x-3 space-y-0 gap-0 RemoteFlows__RadioField__Item",children:[$(N,{children:$(Xe,{value:l.value,className:"RemoteFlows__RadioField__Input"})}),Se("div",{children:[$(S,{className:"font-normal mb-0 RemoteFlows__RadioField__Label",children:l.label}),l.description&&$(w,{className:"mt-2",children:l.description})]})]},l.value)}))})}),r&&$(w,{children:r}),u.error&&$(T,{})]})}})}o(Qe,"RadioGroupField");import*as y from"@radix-ui/react-select";import{CheckIcon as oo,ChevronDownIcon as Ze,ChevronUpIcon as ro}from"lucide-react";import{jsx as P,jsxs as Pe}from"react/jsx-runtime";function je({...e}){return P(y.Root,{"data-slot":"select",...e})}o(je,"Select");function et({...e}){return P(y.Group,{"data-slot":"select-group",...e})}o(et,"SelectGroup");function tt({...e}){return P(y.Value,{"data-slot":"select-value",...e})}o(tt,"SelectValue");function ot({className:e,children:t,...r}){return Pe(y.Trigger,{"data-slot":"select-trigger",className:m("border-input data-[placeholder]:text-muted-foreground [&_svg:not([class*='text-'])]:text-muted-foreground aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive flex w-full items-center justify-between rounded-xl border bg-transparent px-4 py-7 text-sm whitespace-nowrap transition-[color] outline-none disabled:cursor-not-allowed disabled:opacity-50 *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-2 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4","focus-visible:border-focused",e),...r,children:[t,P(y.Icon,{asChild:!0,className:"absolute right-4",children:P(Ze,{className:"size-4"})})]})}o(ot,"SelectTrigger");function rt({className:e,children:t,position:r="popper",...a}){return P(y.Portal,{children:Pe(y.Content,{"data-slot":"select-content",className:m("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-xl border",r==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",e),position:r,...a,children:[P(ao,{}),P(y.Viewport,{className:m(r==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] scroll-my-1"),children:t}),P(no,{})]})})}o(rt,"SelectContent");function at({className:e,children:t,...r}){return Pe(y.Item,{"data-slot":"select-item",className:m("focus:bg-accent focus:text-accent-foreground min-h-11 justify-between [&_svg:not([class*='text-'])]:text-muted-foreground flex w-full cursor-default items-center gap-2 py-2 px-4 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2",e),...r,children:[P(y.ItemText,{children:t}),P("span",{className:"flex size-3.5 items-center justify-center",children:P(y.ItemIndicator,{children:P(oo,{className:"size-4"})})})]})}o(at,"SelectItem");function ao({className:e,...t}){return P(y.ScrollUpButton,{"data-slot":"select-scroll-up-button",className:m("flex cursor-default items-center justify-center py-1",e),...t,children:P(ro,{className:"size-4"})})}o(ao,"SelectScrollUpButton");function no({className:e,...t}){return P(y.ScrollDownButton,{"data-slot":"select-scroll-down-button",className:m("flex cursor-default items-center justify-center py-1",e),...t,children:P(Ze,{className:"size-4"})})}o(no,"SelectScrollDownButton");import{useFormContext as io}from"react-hook-form";import{jsx as L,jsxs as nt}from"react/jsx-runtime";function it({label:e,name:t,options:r,defaultValue:a,description:i,onChange:d,component:p,...g}){let{control:v}=io(),{components:n}=x();return L(C,{defaultValue:a,control:v,name:t,render:({field:c,fieldState:u})=>{let s=p||n?.select;if(s){let l={label:e,name:t,options:r,defaultValue:a,description:i,onChange:d,...g};return L(s,{field:{...c,onChange:o(h=>{c.onChange(h),d?.(h)},"onChange")},fieldState:u,fieldData:l})}return nt(R,{"data-field":t,className:`RemoteFlows__SelectField__Item__${t}`,children:[L(S,{className:"RemoteFlows__SelectField__Label",children:e}),L(N,{children:L("div",{className:"relative",children:nt(je,{value:c.value||"",onValueChange:l=>{c.onChange(l),d?.(l)},children:[L(ot,{className:"RemoteFlows__SelectField__Trigger","aria-invalid":!!u.error,"aria-label":e,children:L("span",{className:"absolute",children:L(tt,{placeholder:e})})}),L(rt,{className:"RemoteFlows__SelectField__Content",children:L(et,{className:"RemoteFlows__SelectField__Group",children:r.map(l=>L(at,{value:l.value,className:"RemoteFlows__SelectField__SelectItem",children:l.label},l.value))})})]})})}),i&&L(w,{children:i}),u.error&&L(T,{})]})}})}o(it,"SelectField");import{useState as vo}from"react";import{useFormContext as Fo}from"react-hook-form";import{Fragment as co,useState as po}from"react";import{Check as uo,ChevronDownIcon as fo,X as go}from"lucide-react";import{Command as Y}from"cmdk";import{SearchIcon as Xa}from"lucide-react";import*as D from"@radix-ui/react-dialog";import{XIcon as so}from"lucide-react";import{jsx as G,jsxs as ke}from"react/jsx-runtime";function Re({...e}){return G(D.Root,{"data-slot":"dialog",...e})}o(Re,"Dialog");function st({...e}){return G(D.Trigger,{"data-slot":"dialog-trigger",...e})}o(st,"DialogTrigger");function lo({...e}){return G(D.Portal,{"data-slot":"dialog-portal",...e})}o(lo,"DialogPortal");function mo({className:e,...t}){return G(D.Overlay,{"data-slot":"dialog-overlay",className:m("data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",e),...t})}o(mo,"DialogOverlay");function Ne({className:e,children:t,...r}){return ke(lo,{"data-slot":"dialog-portal",children:[G(mo,{}),ke(D.Content,{"data-slot":"dialog-content",className:m("bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border p-6 shadow-lg duration-200 sm:max-w-lg",e),...r,children:[t,ke(D.Close,{className:"ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 RemoteFlows__Dialog__Close",children:[G(so,{}),G("span",{className:"sr-only",children:"Close"})]})]})]})}o(Ne,"DialogContent");function we({className:e,...t}){return G("div",{"data-slot":"dialog-header",className:m("flex flex-col gap-2 text-center sm:text-left",e),...t})}o(we,"DialogHeader");function De({className:e,...t}){return G(D.Title,{"data-slot":"dialog-title",className:m("text-lg leading-none font-semibold",e),...t})}o(De,"DialogTitle");import{jsx as X,jsxs as en}from"react/jsx-runtime";function lt({className:e,...t}){return X(Y,{"data-slot":"command",className:m("bg-popover text-popover-foreground flex h-full w-full flex-col overflow-hidden rounded-md",e),...t})}o(lt,"Command");function mt({className:e,...t}){return X(Y.List,{"data-slot":"command-list",className:m("max-h-[300px] scroll-py-1 overflow-x-hidden overflow-y-auto",e),...t})}o(mt,"CommandList");function ct({...e}){return X(Y.Empty,{"data-slot":"command-empty",className:"py-6 text-center text-sm",...e})}o(ct,"CommandEmpty");function dt({className:e,...t}){return X(Y.Group,{"data-slot":"command-group",className:m("text-foreground [&_[cmdk-group-heading]]:text-muted-foreground overflow-hidden p-1 [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium",e),...t})}o(dt,"CommandGroup");function pt({className:e,...t}){return X(Y.Separator,{"data-slot":"command-separator",className:m("bg-border -mx-1 h-px",e),...t})}o(pt,"CommandSeparator");function ut({className:e,...t}){return X(Y.Item,{"data-slot":"command-item",className:m("data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",e),...t})}o(ut,"CommandItem");import{jsx as H,jsxs as Q}from"react/jsx-runtime";function ft({options:e,selected:t,onChange:r,placeholder:a,...i}){let[d,p]=po(!1),g=o(n=>{r(t.filter(c=>c.value!==n.value))},"handleUnselect"),v=e.reduce((n,c)=>{let u=c.category||"Uncategorized";return n[u]||(n[u]=[]),n[u].push(c),n},{});return Q(ne,{open:d,onOpenChange:p,...i,children:[H(ie,{children:Q(B,{variant:"outline",role:"combobox","aria-expanded":d,className:"w-full justify-between font-normal",type:"button",children:[H("div",{className:"flex gap-1 flex-wrap overflow-x-auto max-h-[2.5rem] items-center",children:t.length>0?t.map(n=>Q($e,{variant:"secondary",className:"mr-1 mb-1",children:[n.label,H("div",{role:"button",tabIndex:0,"aria-label":`remove ${n.label}`,className:"ml-1 ring-offset-background rounded-full outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 cursor-pointer",onKeyDown:c=>{c.key==="Enter"&&g(n)},onMouseDown:c=>{c.preventDefault(),c.stopPropagation()},onClick:()=>g(n),children:H(go,{className:"h-3 w-3 text-muted-foreground hover:text-foreground"})})]},n.label)):H("span",{className:"text-foreground",children:a})}),H(fo,{className:"size-4"})]})}),H(se,{align:"start",className:"w-full p-0",children:H(lt,{children:Q(mt,{children:[H(ct,{children:"No item found."}),Object.entries(v).map(([n,c],u)=>Q(co,{children:[u>0&&H(pt,{}),H(dt,{heading:n,children:c.map(s=>{let l=t.some(h=>h.value===s.value);return Q(ut,{onSelect:()=>{r(l?t.filter(h=>h.value!==s.value):[...t,s])},children:[H(uo,{className:m("mr-2 h-4 w-4",l?"opacity-100":"opacity-0")}),s.label]},s.label)})})]},n))]})})})]})}o(ft,"MultiSelect");import{jsx as J,jsxs as ho}from"react/jsx-runtime";function gt({label:e,name:t,options:r,defaultValue:a,description:i,onChange:d,$meta:p,component:g,...v}){let{control:n}=Fo(),{components:c}=x(),[u,s]=vo([]);return J(C,{defaultValue:a,control:n,name:t,render:({field:l,fieldState:h})=>{let f=g||c?.countries;if(f){let b={label:e,name:t,options:r,defaultValue:a,description:i,onChange:d,$meta:p,...v};return J(f,{field:{...l,onChange:o(M=>{l.onChange(M),d?.(M)},"onChange")},fieldState:h,fieldData:b})}let _=[...Object.entries(p?.regions||{}).map(([b,M])=>({value:M,label:b,category:"Regions"})),...Object.entries(p?.subregions||{}).map(([b,M])=>({value:M,label:b,category:"Subregions"})),...r.map(b=>({...b,value:b.value,label:b.label,category:"Countries"}))],k=o(b=>{let M=b.map(({value:wt})=>wt);l.onChange(M),d?.(M),s(b)},"handleChange");return ho(R,{"data-field":t,className:`RemoteFlows__CountryField__Item__${t}`,children:[J(S,{className:"RemoteFlows__CountryField__Label",children:e}),J(N,{children:J(ft,{options:_,selected:u,onChange:k,...v})}),i&&J(w,{children:i}),h.error&&J(T,{})]})}})}o(gt,"CountryField");import{useFormContext as _o}from"react-hook-form";import*as vt from"react";import{jsx as yo}from"react/jsx-runtime";var Te=vt.forwardRef(({className:e,...t},r)=>yo("textarea",{className:m("flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",e),ref:r,...t}));Te.displayName="Textarea";import{jsx as q,jsxs as Ie}from"react/jsx-runtime";function Ft({name:e,description:t,label:r,onChange:a,maxLength:i,component:d,...p}){let{components:g}=x(),{control:v}=_o();return q(C,{control:v,name:e,render:({field:n,fieldState:c})=>{let u=d||g?.textarea;if(u){let l={name:e,description:t,label:r,maxLength:i,...p};return q(u,{field:{...n,onChange:o(h=>{n.onChange(h),a?.(h)},"onChange")},fieldState:c,fieldData:l})}let s=n.value?.length??0;return Ie(R,{"data-field":e,className:`RemoteFlows__TextArea__Item__${e}`,children:[q(S,{className:"RemoteFlows__TextArea__Label",children:r}),q(N,{children:q(Te,{...n,value:n.value??"",onChange:l=>{n.onChange(l),a?.(l)},className:m(c.error&&"border-red-500 focus-visible:ring-red-500","RemoteFlows__TextArea__Input"),placeholder:r})}),(t||i)&&Ie("div",{className:"flex items-center justify-between",children:[t&&q(w,{className:"RemoteFlows__TextArea__Description",children:t}),i&&Ie("span",{className:"text-sm ml-auto RemoteFlows__TextArea__MaxLength",children:[s,"/",i]})]}),c.error&&q(T,{className:"RemoteFlows__TextArea__Error"})]})}})}o(Ft,"TextAreaField");import{useFormContext as xo}from"react-hook-form";import{jsx as We}from"react/jsx-runtime";function ht(e){let{components:t}=x(),{control:r}=xo(),a=e.component||t?.email;return a?We(C,{control:r,name:e.name,render:({field:i,fieldState:d})=>We(a,{field:{...i,onChange:o(p=>{i.onChange(p),e.onChange?.(p)},"onChange")},fieldState:d,fieldData:e})}):We(A,{...e,type:"email"})}o(ht,"EmailField");import{useFormContext as Co}from"react-hook-form";import{jsx as yt}from"react/jsx-runtime";function _t(e){let{control:t}=Co();return yt(C,{control:t,name:e.name,render:({field:r})=>yt("input",{...r,type:"hidden"})})}o(_t,"HiddenField");import No,{useEffect as wo,useState as Pt}from"react";import{yupResolver as Do}from"@hookform/resolvers/yup";import{useForm as To,useFormContext as Io,useFieldArray as Wo}from"react-hook-form";import*as I from"yup";import xt from"lodash.groupby";import Z from"lodash.capitalize";var Ct=60,pe=["monday","tuesday","wednesday","thursday","friday","saturday","sunday"];function bo(e){if(e<60)return`${e}m`;let t=Math.floor(e/Ct),r=e%Ct;return r>0?`${t}h${r}m`:`${t}h`}o(bo,"convertBreakDurationToHours");function bt(e){let t=e.reduce((r,a)=>a.hours+r,0);return Number(t.toFixed(2))}o(bt,"calculateTotalWorkHours");function So(e,t){let r=t.map(({day:d})=>d.toLowerCase()),a=r.indexOf(e),i=null;for(;a<r.length&&!i;){let d=r[a],p=r[a+1],g=pe.indexOf(d)+1;pe[g]===p||(i=d),a+=1}return i}o(So,"findLastConsecutiveDay");function Po(e){return e.start_time&&e.end_time&&(typeof e.hours=="number"?e.hours:Number.parseInt(e.hours))>0}o(Po,"shouldSummarizeSchedule");function ko(e){return Number.parseInt(e.break_duration_minutes)>0}o(ko,"shouldSummarizeBreaks");function St(e){let t=e.filter(Po),r=xt(t,g=>`${g.start_time}|${g.end_time}`),a=e.filter(ko),i=xt(a,"break_duration_minutes"),d=Object.keys(r).map(g=>{let v=r[g],n=v[0].day,[c,u]=g.split("|"),s=`from <span>${c.replace(":","h")}</span> to <span>${u.replace(":","h")}</span>`,l=So(n,v),f=(l?v.findIndex(_=>_.day===l):-1)===v.length-1;return v.length===1?`${Z(n)}, ${s}`:!f||!l?v.reduce((_,k,b)=>{let M=Z(k.day);return b===v.length-1?`${_}and ${M}, ${s}`:`${_}<span>${M}</span>, `},""):`<span>${Z(n)}</span> to <span>${Z(l)}</span>, ${s}`}),p=Object.keys(i).reverse().map((g,v)=>{let n=v===0,c=i[g],u=bo(parseInt(g,10));if(Object.keys(i).length===1)return`With ${u} daily breaks`;if(c.length===1){let s=`${u} break on ${Z(c[0].day)}.`;return n?`With ${s}`:s}return c.reduce((s,l,h)=>{let f=Z(l.day);return h===0?`${s} ${f}`:h===c.length-1?`${s}, and ${f}.`:`${s}, ${f}`},n?`With ${u} break on`:`${u} break on`)});return{workHoursSummary:d,breakSummary:p}}o(St,"buildWorkScheduleSummary");function Le(e){let{checked:t,start_time:r,end_time:a,break_duration_minutes:i}=e;if(!t)return 0;let[d,p]=r.split(":").map(Number),[g,v]=a.split(":").map(Number),n=d*60+p,s=(g*60+v-n-Number.parseInt(i||"0"))/60;return s===Math.floor(s)?s:Number(s.toFixed(2))}o(Le,"calculateHours");var Ro={monday:"Mon",tuesday:"Tue",wednesday:"Wed",thursday:"Thu",friday:"Fri",saturday:"Sat",sunday:"Sun"};function ue(e){return Ro[e]}o(ue,"getShortWeekday");import{jsx as F,jsxs as E}from"react/jsx-runtime";var Lo=I.object({day:I.string().required(),checked:I.boolean().required(),start_time:I.string().matches(/^([01]\d|2[0-3]):([0-5]\d)$/,"Invalid time format (HH:mm)").when("checked",{is:!0,then:o(e=>e.required("Required"),"then"),otherwise:o(e=>e.optional().nullable(),"otherwise")}),end_time:I.string().matches(/^([01]\d|2[0-3]):([0-5]\d)$/,"Invalid time format (HH:mm)").when("checked",{is:!0,then:o(e=>e.required("Required"),"then"),otherwise:o(e=>e.optional().nullable(),"otherwise")}),hours:I.number().default(0),break_duration_minutes:I.string().default("0")}),Mo=I.object({schedule:I.array(Lo)});function $o({defaultSchedule:e,onSubmit:t}){let[r,a]=Pt(!1),i=pe.map(f=>{let _=e.find(k=>k.day.toLowerCase()===ue(f).toLowerCase()||k.day.toLowerCase()===f.toLowerCase());return _?{..._,day:ue(f),checked:!0}:{...e[0],checked:!1,day:ue(f)}}),d=To({defaultValues:{schedule:i},resolver:Do(Mo)}),{handleSubmit:p,watch:g,reset:v,control:n,formState:c}=d,{fields:u}=Wo({name:"schedule",control:n}),s=g("schedule");function l(f){let _=f.schedule.filter(({checked:k})=>k).map(k=>({...k,hours:Le(k)}));t(_),a(!1)}o(l,"handleSubmitWorkingHours");function h(){v(),a(!1)}return o(h,"handleCancel"),F("div",{className:"flex items-center justify-between",children:E(Re,{open:r,onOpenChange:a,children:[F(st,{asChild:!0,children:F(B,{variant:"link",className:"flex items-center p-0 RemoteFlows__WorkScheduleSelectionForm__Trigger",children:"Edit Schedule"})}),E(Ne,{className:"max-w-5xl max-h-[90vh] overflow-y-auto px-8 py-4 RemoteFlows__WorkScheduleSelectionForm__Content",children:[F(we,{children:F(De,{className:"RemoteFlows__WorkScheduleSelectionForm__Title",children:"Edit employee working hours"})}),F(Me,{...d,children:E("form",{className:"space-y-4 RemoteFlows__WorkScheduleSelectionForm__Form",children:[E("div",{className:"rounded-lg",children:[F("p",{className:"text-gray-600 text-sm mb-4 RemoteFlows__WorkScheduleSelectionForm__Description",children:"The times displayed are in the employee's time zone in the 24-hour format."}),E("div",{className:"grid grid-cols-12 gap-4 text-sm font-medium text-gray-500 uppercase tracking-wide RemoteFlows__WorkScheduleSelectionForm__Header",children:[F("div",{className:"col-span-2"}),F("div",{className:"col-span-3 text-center",children:"START"}),F("div",{className:"col-span-1 text-center"}),F("div",{className:"col-span-3 text-center",children:"END"}),F("div",{className:"col-span-2 text-center",children:"HOURS"})]}),F("div",{className:"RemoteFlows__WorkScheduleSelectionForm__Rows",children:u.map((f,_)=>{let k=s[_],b=Le(k);return E(No.Fragment,{children:[E("div",{className:"grid grid-cols-12 gap-4 items-center py-2 RemoteFlows__WorkScheduleSelectionForm__Row-Hours",children:[F("div",{className:"col-span-2 flex items-center gap-3",children:F(re,{label:f.day,name:`schedule.${_}.checked`})}),F("div",{className:"col-span-3",children:F(A,{name:`schedule.${_}.start_time`,includeErrorMessage:!1})}),F("div",{className:"col-span-1 text-center text-gray-500",children:"to"}),F("div",{className:"col-span-3",children:F(A,{name:`schedule.${_}.end_time`,includeErrorMessage:!1})}),F("div",{className:"col-span-2 text-center text-gray-600",children:isNaN(b)?"-":`${b} hours`})]}),E("div",{className:"grid grid-cols-12 gap-4 items-center py-2 RemoteFlows__WorkScheduleSelectionForm__Row-Break",children:[F("div",{className:"col-span-2 text-gray-500",children:"Break"}),F("div",{className:"col-span-2",children:F(A,{name:`schedule.${_}.break_duration_minutes`,includeErrorMessage:!1})}),F("div",{className:"col-span-2 text-gray-500",children:"minutes"}),F("div",{className:"col-span-4"})]})]},f.id)})})]}),Object.keys(c.errors).length>0&&F("p",{className:"text-destructive text-sm mb-0",children:"Invalid time format (HH:mm)"}),E("div",{className:"flex gap-4 pt-4",children:[F(B,{type:"button",className:"reset-button",variant:"outline",onClick:h,children:"Cancel"}),F(B,{type:"button",className:"submit-button",onClick:p(l),children:"Save Schedule"})]})]})})]})]})})}o($o,"WorkScheduleSelectionForm");function kt(e){let{components:t}=x(),{setValue:r,control:a,watch:i}=Io(),d=i(e.name),[p,g]=Pt(d),{workHoursSummary:v,breakSummary:n}=St(p),c=bt(p);wo(()=>{r(e.name,p)},[p,e.name,r]);function u(l){g(l)}o(u,"onSubmit");let s=e.component||t?.["work-schedule"];return s?F(C,{control:a,name:e.name,render:({field:l,fieldState:h})=>F(s,{field:{...l,onChange:o(f=>{l.onChange(f),e.onChange?.(f)},"onChange")},fieldState:h,fieldData:{...e,defaultFormattedValue:{workHoursSummary:v,breakSummary:n,totalWorkHours:c}}})}):E("div",{className:"flex flex-col gap-3 RemoteFlows__WorkScheduleField",children:[F("p",{className:"text-sm RemoteFlows__WorkScheduleField__Title",children:"Work hours"}),E("div",{className:"flex flex-col gap-1 RemoteFlows__WorkScheduleField__Summary",children:[F("p",{className:"text-sm text-gray-500 RemoteFlows__WorkScheduleField__Summary__WorkHours",dangerouslySetInnerHTML:{__html:v.join(", ")}}),F("p",{className:"text-sm text-gray-500 RemoteFlows__WorkScheduleField__Summary__Break",children:n.join()}),E("p",{className:"text-sm text-gray-500 RemoteFlows__WorkScheduleField__Summary__Total",children:["Total of ",F("span",{children:c})," hours per week"]}),F($o,{defaultSchedule:p,onSubmit:u})]})]})}o(kt,"WorkScheduleField");var ce={checkbox:re,text:A,email:ht,money:be,select:it,radio:Qe,number:be,file:Ke,fieldset:Ue,date:Ae,textarea:Ft,countries:gt,hidden:_t,"work-schedule":kt};import{useEffect as Ho}from"react";import{useFormContext as Eo}from"react-hook-form";import{Fragment as Bo,jsx as fe,jsxs as Ao}from"react/jsx-runtime";function Rt({name:e,value:t,description:r,statement:a}){let{setValue:i}=Eo();return Ho(()=>{i(e,t)},[]),fe("div",{children:a?Ao(Bo,{children:[fe("p",{className:`text-sm RemoteFlows__ForcedValue__Title__${e}`,dangerouslySetInnerHTML:{__html:a?.title}}),fe("p",{className:`text-xs RemoteFlows__ForcedValue__Description__${e}`,dangerouslySetInnerHTML:{__html:a?.description}})]}):fe("p",{className:`text-xs RemoteFlows__ForcedValue__Description__${e}`,dangerouslySetInnerHTML:{__html:r}})})}o(Rt,"ForcedValueField");import{Fragment as Go,jsx as j,jsxs as Nt}from"react/jsx-runtime";function Oo(e){return e.const!==void 0&&e.const===e.default&&e.inputType!=="checkbox"&&e.inputType!=="hidden"}o(Oo,"checkFieldHasForcedValue");var Mi=o(({fields:e,components:t})=>!e||e.length===0?null:j(Go,{children:e.map(r=>{if(r.isVisible===!1||r.deprecated)return null;if(Oo(r))return j(Rt,{name:r.name,description:r.description,value:r.const,statement:r.statement},r.name);if(r.Component){let{Component:i}=r;return j(i,{...r},r.name)}let a=ce[r.inputType];return r.inputType==="fieldset"?j(a,{...r,components:t}):a?Nt(zo,{children:[j(a,{...r,component:t&&t[r.inputType]}),r.statement?j(me,{...r.statement}):null]},r.name):Nt("p",{className:"error",children:["Field type ",r.inputType," not supported"]})})}),"JSONSchemaFormFields");export{Mi as a};
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{a as $e}from"./chunk-XO3JWN33.js";import{a as A}from"./chunk-RLETCEUU.js";import{a as ge,b as B}from"./chunk-GEYFQVQI.js";import{b as x}from"./chunk-3ZWDIEEM.js";import{a as Me,b as C,c as R,d as S,e as N,f as w,g as T}from"./chunk-VNSF5IOL.js";import{a as m}from"./chunk-KPHSEIR3.js";import{a as o}from"./chunk-P37U34EQ.js";import{Fragment as zo}from"react";import*as He from"react";import*as ee from"@radix-ui/react-checkbox";import{Check as Dt}from"lucide-react";import{jsx as ve}from"react/jsx-runtime";var te=He.forwardRef(({className:e,...t},r)=>ve(ee.Root,{ref:r,className:m("peer h-4 w-4 shrink-0 rounded-sm border border-input ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-checkbox data-[state=checked]:text-primary",e),...t,children:ve(ee.Indicator,{className:m("flex items-center justify-center text-current"),children:ve(Dt,{className:"h-4 w-4"})})}));te.displayName=ee.Root.displayName;import{useFormContext as Tt}from"react-hook-form";import{Fragment as It,jsx as z,jsxs as oe}from"react/jsx-runtime";function re({name:e,defaultValue:t,description:r,label:a,onChange:i,multiple:d,options:p,component:g,...v}){let{components:n}=x(),{control:c}=Tt(),u=o((s,l,h)=>{let f=h.value?[...h.value]:[];l?f.includes(s)||h.onChange([...f,s]):h.onChange(f.filter(_=>_!==s))},"handleCheckboxChange");return z(C,{control:c,name:e,defaultValue:t,render:({field:s,fieldState:l})=>{let h=g||n?.checkbox;if(h){let f={name:e,description:r,label:a,defaultValue:t,multiple:d,options:p,...v};return z(h,{field:{...s,onChange:o(_=>{if(d){let{checked:k,value:b}=_.target;u(b,k,s),i?.(k);return}s.onChange(_),i?.(_)},"onChange")},fieldState:l,fieldData:f})}return oe(R,{"data-field":e,className:m(`RemoteFlows__CheckBoxField__Item__${e}`),children:[z(N,{children:oe(It,{children:[p&&d?z(S,{children:a}):null,p&&d?p.map(f=>oe("div",{className:"flex space-x-2",children:[z(te,{id:f.value,onCheckedChange:_=>{u(f.value,_===!0,s),i?.(_,f.value)},checked:s.value?.includes(f.value),className:"RemoteFlows__CheckBox__Input"}),z(S,{htmlFor:f.value,className:"mb-0 RemoteFlows__CheckBox__Label",children:f.label})]},f.value)):oe("div",{className:"flex space-x-2",children:[z(te,{id:e,onCheckedChange:f=>{s.onChange(f),i?.(f)},checked:s.value,className:"RemoteFlows__CheckBox__Input"}),z(S,{htmlFor:e,className:"mb-0 RemoteFlows__CheckBox__Label",children:a})]})]})}),r&&z(w,{children:r}),l.error&&z(T,{})]})}})}o(re,"CheckBoxField");import{CalendarIcon as $t}from"lucide-react";import{useFormContext as Ht}from"react-hook-form";import{ChevronLeft as Wt,ChevronRight as Lt}from"lucide-react";import{DayPicker as Mt}from"react-day-picker";import{jsx as Fe}from"react/jsx-runtime";function Ee({className:e,classNames:t,showOutsideDays:r=!0,...a}){return Fe(Mt,{showOutsideDays:r,className:m("p-3",e),classNames:{months:"flex flex-col sm:flex-row gap-2",month:"flex flex-col gap-4",caption:"flex justify-center pt-1 relative items-center w-full",caption_label:"text-sm font-medium",nav:"flex items-center gap-1",nav_button:m(ge({variant:"outline"}),"size-7 bg-transparent p-0 opacity-50 hover:opacity-100"),nav_button_previous:"absolute left-1",nav_button_next:"absolute right-1",table:"w-full border-collapse space-x-1",head_row:"flex",head_cell:"text-muted-foreground rounded-md w-8 font-normal text-[0.8rem]",row:"flex w-full mt-2",cell:m("relative p-0 text-center text-sm focus-within:relative focus-within:z-20 [&:has([aria-selected])]:bg-accent [&:has([aria-selected].day-range-end)]:rounded-r-md",a.mode==="range"?"[&:has(>.day-range-end)]:rounded-r-md [&:has(>.day-range-start)]:rounded-l-md first:[&:has([aria-selected])]:rounded-l-md last:[&:has([aria-selected])]:rounded-r-md":"[&:has([aria-selected])]:rounded-md"),day:m(ge({variant:"ghost"}),"size-8 p-0 font-normal aria-selected:opacity-100"),day_range_start:"day-range-start aria-selected:bg-primary aria-selected:text-primary-foreground",day_range_end:"day-range-end aria-selected:bg-primary aria-selected:text-primary-foreground",day_selected:"bg-primary text-primary-foreground hover:bg-primary hover:text-primary-foreground focus:bg-primary focus:text-primary-foreground",day_today:"bg-accent text-accent-foreground",day_outside:"day-outside text-muted-foreground aria-selected:text-muted-foreground",day_disabled:"text-muted-foreground opacity-50",day_range_middle:"aria-selected:bg-accent aria-selected:text-accent-foreground",day_hidden:"invisible",...t},components:{IconLeft:o(({className:i,...d})=>Fe(Wt,{className:m("size-4",i),...d}),"IconLeft"),IconRight:o(({className:i,...d})=>Fe(Lt,{className:m("size-4",i),...d}),"IconRight")},...a})}o(Ee,"Calendar");import*as O from"@radix-ui/react-popover";import{jsx as ae}from"react/jsx-runtime";function ne({...e}){return ae(O.Root,{"data-slot":"popover",...e})}o(ne,"Popover");function ie({...e}){return ae(O.Trigger,{"data-slot":"popover-trigger",...e})}o(ie,"PopoverTrigger");function se({className:e,align:t="center",sideOffset:r=4,...a}){return ae(O.Portal,{children:ae(O.Content,{"data-slot":"popover-content",align:t,sideOffset:r,className:m("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-72 origin-(--radix-popover-content-transform-origin) rounded-md border p-4 shadow-md outline-hidden",e),...a})})}o(se,"PopoverContent");import{PopoverClose as Et}from"@radix-ui/react-popover";import{format as Be}from"date-fns";import{Fragment as Bt,jsx as W,jsxs as he}from"react/jsx-runtime";function Ae({description:e,label:t,name:r,minDate:a,onChange:i,component:d,...p}){let{components:g}=x(),{control:v}=Ht();return W(C,{control:v,name:r,render:({field:n,fieldState:c})=>{let u=d||g?.date;if(u){let s={description:e,label:t,name:r,minDate:a,onChange:i,...p};return W(u,{field:{...n,onChange:o(l=>{n.onChange(l),i?.(l)},"onChange")},fieldState:c,fieldData:s})}return he(R,{"data-field":r,className:`flex flex-col RemoteFlows__DatePickerField__Item__${r}`,children:[W(S,{className:"RemoteFlows__DatePickerField__Label",children:t}),he(ne,{children:[W(ie,{asChild:!0,children:W(N,{children:W("div",{children:he(B,{type:"button",variant:"outline",className:m("w-full pl-3 text-left font-normal",!n.value&&"text-muted-foreground"),"data-testid":`date-picker-button-${r}`,children:[n.value&&W(Bt,{children:Be(n.value,"yyyy-MM-dd")}),W($t,{className:"ml-auto h-4 w-4 opacity-50"})]})})})}),W(se,{className:"w-auto p-0 RemoteFlows__DatepickerField__PopoverContent",align:"start",children:W(Ee,{mode:"single",className:"RemoteFlows__DatepickerField__Calendar",selected:n.value?new Date(n.value):void 0,onSelect:s=>{n.onChange(s?Be(s,"yyyy-MM-dd"):null),i?.(s)},defaultMonth:a?new Date(a):void 0,components:{DayContent:o(s=>W(Et,{children:s.date.getDate()}),"DayContent")},...a&&{disabled:o(s=>s<new Date(a),"disabled")}})})]}),e?W(w,{children:e}):null,c.error&&W(T,{className:"RemoteFlows__DatePickerField__Error"})]})}})}o(Ae,"DatePickerField");import{cva as At}from"class-variance-authority";import{jsx as ye}from"react/jsx-runtime";var zt=At("relative w-full rounded-lg border px-4 py-3 text-sm grid has-[>svg]:grid-cols-[calc(var(--spacing)*4)_1fr] grid-cols-[0_1fr] has-[>svg]:gap-x-3 gap-y-0.5 items-start [&>svg]:size-4 [&>svg]:translate-y-0.5 [&>svg]:text-current",{variants:{variant:{default:"bg-card text-card-foreground",destructive:"text-destructive bg-card [&>svg]:text-current *:data-[slot=alert-description]:text-destructive/90",warning:"bg-card bg-warning border-warning-border [&>svg]:text-current"}},defaultVariants:{variant:"default"}});function ze({className:e,variant:t,...r}){return ye("div",{"data-slot":"alert",role:"alert",className:m(zt({variant:t}),e),...r})}o(ze,"Alert");function Oe({className:e,...t}){return ye("div",{"data-slot":"alert-title",className:m("col-start-2 line-clamp-1 min-h-4 font-medium tracking-tight",e),...t})}o(Oe,"AlertTitle");function Ge({className:e,...t}){return ye("div",{"data-slot":"alert-description",className:m("text-muted-foreground col-start-2 grid justify-items-start gap-1 text-sm [&_p]:leading-relaxed",e),...t})}o(Ge,"AlertDescription");import{AlertCircle as Ot}from"lucide-react";import{jsx as le,jsxs as Gt}from"react/jsx-runtime";function me({title:e,description:t,severity:r}){let{components:a}=x();if(a?.statement){let i=a?.statement;return le(i,{data:{title:e,description:t,severity:r}})}return Gt(ze,{variant:"warning",children:[le(Ot,{className:"h-4 w-4"}),e&&le(Oe,{children:e}),le(Ge,{children:t})]})}o(me,"Statement");import{jsx as _e,jsxs as Ve}from"react/jsx-runtime";import{createElement as Vt}from"react";function Ue({label:e,name:t,fields:r,description:a,components:i,statement:d}){return Ve("fieldset",{className:m("border-1 border-input p-4 rounded-xl",`RemoteFlows__FieldSetField__${t}`),children:[_e("legend",{className:"text-sm font-semibold px-2",children:e}),a?_e("div",{className:"mb-5 RemoteFlows__FieldSetField__Description",dangerouslySetInnerHTML:{__html:a}}):null,Ve("div",{className:"grid gap-4",children:[r.map(p=>{let g=ce[p.type];return p.isVisible===!1||p.deprecated?null:Vt(g,{...p,key:p.name,name:`${t}.${p.name}`,component:i?.[p.type]})}),d?_e(me,{...d}):null]})]})}o(Ue,"FieldSetField");import{useFormContext as Yt}from"react-hook-form";import{useState as Ut,useRef as Jt}from"react";import{Upload as qt,X as Kt}from"lucide-react";import{jsx as V,jsxs as xe}from"react/jsx-runtime";function Je({onChange:e,className:t,multiple:r}){let[a,i]=Ut([]),d=Jt(null),p=o(n=>{n.preventDefault(),d.current?.click()},"handleClick"),g=o(n=>{if(n.target.files&&n.target.files.length>0){let c=Array.from(n.target.files);i(c),e(n)}},"handleChange"),v=o(n=>{i(c=>c.filter(u=>u!==n))},"onRemoveFile");return xe("div",{className:m("flex flex-col items-start gap-4",t),children:[V("input",{type:"file",ref:d,onChange:g,className:"hidden","aria-label":"File upload",multiple:r}),xe(B,{type:"button",onClick:p,className:"gap-2",children:[V(qt,{className:"h-4 w-4"}),"Choose File"]}),a.length===0&&V("div",{className:"text-sm",children:r?V("span",{className:"font-medium",children:"No files selected. You can select multiple files"}):V("span",{className:"font-medium",children:"No file selected."})}),a.length>0&&a.map((n,c)=>xe("div",{className:"text-sm flex items-center gap-2",children:["Selected file: ",V("span",{className:"font-medium",children:n.name})," (",Math.round(n.size/1024)," KB)",V(B,{variant:"ghost",onClick:()=>v(n),children:V(Kt,{})})]},c))]})}o(Je,"FileUploader");import{jsx as U,jsxs as Qt}from"react/jsx-runtime";var Xt=o(e=>new Promise((t,r)=>{let a=new FileReader;a.readAsDataURL(e),a.onload=()=>t(a.result),a.onerror=i=>r(i)}),"toBase64"),qe=o(async e=>{let t=e.target.files?Array.from(e.target.files):[];return await Promise.all(t.map(async a=>{let i=await Xt(a);return{name:a.name,content:i.split(",")[1]}}))},"convertFilesToBase64");function Ke({name:e,description:t,label:r,multiple:a,onChange:i,component:d,...p}){let{components:g}=x(),{control:v}=Yt();return U(C,{control:v,name:e,render:({field:n,fieldState:c})=>{let u=d||g?.file;if(u){let s={name:e,description:t,label:r,multiple:a,...p};return U(u,{field:{...n,value:null,onChange:o(async l=>{let h=await qe(l);n.onChange(h),i?.(h)},"onChange")},fieldState:c,fieldData:s})}return Qt(R,{"data-field":e,className:`RemoteFlows__FileUpload__Item__${e}`,children:[U(S,{className:"RemoteFlows__FileUpload__Label",children:r}),U(N,{children:U(Je,{onChange:async s=>{let l=await qe(s);n.onChange(l),i?.(l)},multiple:a,className:m("RemoteFlows__FileUpload__Input")})}),t&&U("div",{className:"flex items-center justify-between",children:U(w,{className:"RemoteFlows__FileUpload__Description",children:t})}),c.error&&U(T,{className:"RemoteFlows__FileUpload__Error"})]})}})}o(Ke,"FileUploadField");import{useFormContext as Zt}from"react-hook-form";import{jsx as Ce}from"react/jsx-runtime";function be(e){let{components:t}=x(),{control:r}=Zt(),a=e.component||t?.number;return a?Ce(C,{control:r,name:e.name,render:({field:i,fieldState:d})=>Ce(a,{field:{...i,onChange:o(p=>{i.onChange(p),e.onChange?.(p)},"onChange")},fieldState:d,fieldData:e})}):Ce(A,{...e,type:"text",inputMode:"decimal",pattern:"^[0-9.]*$"})}o(be,"NumberField");import*as K from"@radix-ui/react-radio-group";import{CircleIcon as jt}from"lucide-react";import{jsx as de}from"react/jsx-runtime";function Ye({className:e,...t}){return de(K.Root,{"data-slot":"radio-group",className:m("grid gap-3",e),...t})}o(Ye,"RadioGroup");function Xe({className:e,...t}){return de(K.Item,{"data-slot":"radio-group-item",className:m("border-input text-primary focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive aspect-square size-4 shrink-0 rounded-full border shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50",e),...t,children:de(K.Indicator,{"data-slot":"radio-group-indicator",className:"relative flex items-center justify-center",children:de(jt,{className:"fill-radio absolute top-1/2 left-1/2 size-2 -translate-x-1/2 -translate-y-1/2"})})})}o(Xe,"RadioGroupItem");import{useFormContext as eo}from"react-hook-form";import{Fragment as to,jsx as $,jsxs as Se}from"react/jsx-runtime";function Qe({name:e,defaultValue:t,description:r,label:a,options:i,onChange:d,component:p,...g}){let{components:v}=x(),{control:n}=eo();return $(C,{control:n,name:e,defaultValue:t,render:({field:c,fieldState:u})=>{let s=p||v?.radio;if(s){let l={name:e,defaultValue:t,description:r,label:a,options:i,...g};return $(s,{field:{...c,onChange:o(h=>{c.onChange(h),d?.(h)},"onChange")},fieldState:u,fieldData:l})}return Se(R,{className:m("space-y-3",`RemoteFlows__RadioGroupField__Item__${e}`),"data-field":e,children:[$(S,{children:a}),$(N,{children:$(Ye,{"aria-label":a||e,onValueChange:l=>{c.onChange(l),d?.(l)},value:c.value,className:"flex flex-col space-y-3",children:i?.map(l=>$(to,{children:Se(R,{"data-field":e,className:"flex items-start space-x-3 space-y-0 gap-0 RemoteFlows__RadioField__Item",children:[$(N,{children:$(Xe,{value:l.value,className:"RemoteFlows__RadioField__Input"})}),Se("div",{children:[$(S,{className:"font-normal mb-0 RemoteFlows__RadioField__Label",children:l.label}),l.description&&$(w,{className:"mt-2",children:l.description})]})]},l.value)}))})}),r&&$(w,{children:r}),u.error&&$(T,{})]})}})}o(Qe,"RadioGroupField");import*as y from"@radix-ui/react-select";import{CheckIcon as oo,ChevronDownIcon as Ze,ChevronUpIcon as ro}from"lucide-react";import{jsx as P,jsxs as Pe}from"react/jsx-runtime";function je({...e}){return P(y.Root,{"data-slot":"select",...e})}o(je,"Select");function et({...e}){return P(y.Group,{"data-slot":"select-group",...e})}o(et,"SelectGroup");function tt({...e}){return P(y.Value,{"data-slot":"select-value",...e})}o(tt,"SelectValue");function ot({className:e,children:t,...r}){return Pe(y.Trigger,{"data-slot":"select-trigger",className:m("border-input data-[placeholder]:text-muted-foreground [&_svg:not([class*='text-'])]:text-muted-foreground aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive flex w-full items-center justify-between rounded-xl border bg-transparent px-4 py-7 text-sm whitespace-nowrap transition-[color] outline-none disabled:cursor-not-allowed disabled:opacity-50 *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-2 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4","focus-visible:border-focused",e),...r,children:[t,P(y.Icon,{asChild:!0,className:"absolute right-4",children:P(Ze,{className:"size-4"})})]})}o(ot,"SelectTrigger");function rt({className:e,children:t,position:r="popper",...a}){return P(y.Portal,{children:Pe(y.Content,{"data-slot":"select-content",className:m("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-xl border",r==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",e),position:r,...a,children:[P(ao,{}),P(y.Viewport,{className:m(r==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] scroll-my-1"),children:t}),P(no,{})]})})}o(rt,"SelectContent");function at({className:e,children:t,...r}){return Pe(y.Item,{"data-slot":"select-item",className:m("focus:bg-accent focus:text-accent-foreground min-h-11 justify-between [&_svg:not([class*='text-'])]:text-muted-foreground flex w-full cursor-default items-center gap-2 py-2 px-4 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2",e),...r,children:[P(y.ItemText,{children:t}),P("span",{className:"flex size-3.5 items-center justify-center",children:P(y.ItemIndicator,{children:P(oo,{className:"size-4"})})})]})}o(at,"SelectItem");function ao({className:e,...t}){return P(y.ScrollUpButton,{"data-slot":"select-scroll-up-button",className:m("flex cursor-default items-center justify-center py-1",e),...t,children:P(ro,{className:"size-4"})})}o(ao,"SelectScrollUpButton");function no({className:e,...t}){return P(y.ScrollDownButton,{"data-slot":"select-scroll-down-button",className:m("flex cursor-default items-center justify-center py-1",e),...t,children:P(Ze,{className:"size-4"})})}o(no,"SelectScrollDownButton");import{useFormContext as io}from"react-hook-form";import{jsx as L,jsxs as nt}from"react/jsx-runtime";function it({label:e,name:t,options:r,defaultValue:a,description:i,onChange:d,component:p,...g}){let{control:v}=io(),{components:n}=x();return L(C,{defaultValue:a,control:v,name:t,render:({field:c,fieldState:u})=>{let s=p||n?.select;if(s){let l={label:e,name:t,options:r,defaultValue:a,description:i,onChange:d,...g};return L(s,{field:{...c,onChange:o(h=>{c.onChange(h),d?.(h)},"onChange")},fieldState:u,fieldData:l})}return nt(R,{"data-field":t,className:`RemoteFlows__SelectField__Item__${t}`,children:[L(S,{className:"RemoteFlows__SelectField__Label",children:e}),L(N,{children:L("div",{className:"relative",children:nt(je,{value:c.value||"",onValueChange:l=>{c.onChange(l),d?.(l)},children:[L(ot,{className:"RemoteFlows__SelectField__Trigger","aria-invalid":!!u.error,"aria-label":e,children:L("span",{className:"absolute",children:L(tt,{placeholder:e})})}),L(rt,{className:"RemoteFlows__SelectField__Content",children:L(et,{className:"RemoteFlows__SelectField__Group",children:r.map(l=>L(at,{value:l.value,className:"RemoteFlows__SelectField__SelectItem",children:l.label},l.value))})})]})})}),i&&L(w,{children:i}),u.error&&L(T,{})]})}})}o(it,"SelectField");import{useState as vo}from"react";import{useFormContext as Fo}from"react-hook-form";import{Fragment as co,useState as po}from"react";import{Check as uo,ChevronDownIcon as fo,X as go}from"lucide-react";import{Command as Y}from"cmdk";import{SearchIcon as Xa}from"lucide-react";import*as D from"@radix-ui/react-dialog";import{XIcon as so}from"lucide-react";import{jsx as G,jsxs as ke}from"react/jsx-runtime";function Re({...e}){return G(D.Root,{"data-slot":"dialog",...e})}o(Re,"Dialog");function st({...e}){return G(D.Trigger,{"data-slot":"dialog-trigger",...e})}o(st,"DialogTrigger");function lo({...e}){return G(D.Portal,{"data-slot":"dialog-portal",...e})}o(lo,"DialogPortal");function mo({className:e,...t}){return G(D.Overlay,{"data-slot":"dialog-overlay",className:m("data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",e),...t})}o(mo,"DialogOverlay");function Ne({className:e,children:t,...r}){return ke(lo,{"data-slot":"dialog-portal",children:[G(mo,{}),ke(D.Content,{"data-slot":"dialog-content",className:m("bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border p-6 shadow-lg duration-200 sm:max-w-lg",e),...r,children:[t,ke(D.Close,{className:"ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 RemoteFlows__Dialog__Close",children:[G(so,{}),G("span",{className:"sr-only",children:"Close"})]})]})]})}o(Ne,"DialogContent");function we({className:e,...t}){return G("div",{"data-slot":"dialog-header",className:m("flex flex-col gap-2 text-center sm:text-left",e),...t})}o(we,"DialogHeader");function De({className:e,...t}){return G(D.Title,{"data-slot":"dialog-title",className:m("text-lg leading-none font-semibold",e),...t})}o(De,"DialogTitle");import{jsx as X,jsxs as en}from"react/jsx-runtime";function lt({className:e,...t}){return X(Y,{"data-slot":"command",className:m("bg-popover text-popover-foreground flex h-full w-full flex-col overflow-hidden rounded-md",e),...t})}o(lt,"Command");function mt({className:e,...t}){return X(Y.List,{"data-slot":"command-list",className:m("max-h-[300px] scroll-py-1 overflow-x-hidden overflow-y-auto",e),...t})}o(mt,"CommandList");function ct({...e}){return X(Y.Empty,{"data-slot":"command-empty",className:"py-6 text-center text-sm",...e})}o(ct,"CommandEmpty");function dt({className:e,...t}){return X(Y.Group,{"data-slot":"command-group",className:m("text-foreground [&_[cmdk-group-heading]]:text-muted-foreground overflow-hidden p-1 [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium",e),...t})}o(dt,"CommandGroup");function pt({className:e,...t}){return X(Y.Separator,{"data-slot":"command-separator",className:m("bg-border -mx-1 h-px",e),...t})}o(pt,"CommandSeparator");function ut({className:e,...t}){return X(Y.Item,{"data-slot":"command-item",className:m("data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",e),...t})}o(ut,"CommandItem");import{jsx as H,jsxs as Q}from"react/jsx-runtime";function ft({options:e,selected:t,onChange:r,placeholder:a,...i}){let[d,p]=po(!1),g=o(n=>{r(t.filter(c=>c.value!==n.value))},"handleUnselect"),v=e.reduce((n,c)=>{let u=c.category||"Uncategorized";return n[u]||(n[u]=[]),n[u].push(c),n},{});return Q(ne,{open:d,onOpenChange:p,...i,children:[H(ie,{children:Q(B,{variant:"outline",role:"combobox","aria-expanded":d,className:"w-full justify-between font-normal",type:"button",children:[H("div",{className:"flex gap-1 flex-wrap overflow-x-auto max-h-[2.5rem] items-center",children:t.length>0?t.map(n=>Q($e,{variant:"secondary",className:"mr-1 mb-1",children:[n.label,H("div",{role:"button",tabIndex:0,"aria-label":`remove ${n.label}`,className:"ml-1 ring-offset-background rounded-full outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 cursor-pointer",onKeyDown:c=>{c.key==="Enter"&&g(n)},onMouseDown:c=>{c.preventDefault(),c.stopPropagation()},onClick:()=>g(n),children:H(go,{className:"h-3 w-3 text-muted-foreground hover:text-foreground"})})]},n.label)):H("span",{className:"text-foreground",children:a})}),H(fo,{className:"size-4"})]})}),H(se,{align:"start",className:"w-full p-0",children:H(lt,{children:Q(mt,{children:[H(ct,{children:"No item found."}),Object.entries(v).map(([n,c],u)=>Q(co,{children:[u>0&&H(pt,{}),H(dt,{heading:n,children:c.map(s=>{let l=t.some(h=>h.value===s.value);return Q(ut,{onSelect:()=>{r(l?t.filter(h=>h.value!==s.value):[...t,s])},children:[H(uo,{className:m("mr-2 h-4 w-4",l?"opacity-100":"opacity-0")}),s.label]},s.label)})})]},n))]})})})]})}o(ft,"MultiSelect");import{jsx as J,jsxs as ho}from"react/jsx-runtime";function gt({label:e,name:t,options:r,defaultValue:a,description:i,onChange:d,$meta:p,component:g,...v}){let{control:n}=Fo(),{components:c}=x(),[u,s]=vo([]);return J(C,{defaultValue:a,control:n,name:t,render:({field:l,fieldState:h})=>{let f=g||c?.countries;if(f){let b={label:e,name:t,options:r,defaultValue:a,description:i,onChange:d,$meta:p,...v};return J(f,{field:{...l,onChange:o(M=>{l.onChange(M),d?.(M)},"onChange")},fieldState:h,fieldData:b})}let _=[...Object.entries(p?.regions||{}).map(([b,M])=>({value:M,label:b,category:"Regions"})),...Object.entries(p?.subregions||{}).map(([b,M])=>({value:M,label:b,category:"Subregions"})),...r.map(b=>({...b,value:b.value,label:b.label,category:"Countries"}))],k=o(b=>{let M=b.map(({value:wt})=>wt);l.onChange(M),d?.(M),s(b)},"handleChange");return ho(R,{"data-field":t,className:`RemoteFlows__CountryField__Item__${t}`,children:[J(S,{className:"RemoteFlows__CountryField__Label",children:e}),J(N,{children:J(ft,{options:_,selected:u,onChange:k,...v})}),i&&J(w,{children:i}),h.error&&J(T,{})]})}})}o(gt,"CountryField");import{useFormContext as _o}from"react-hook-form";import*as vt from"react";import{jsx as yo}from"react/jsx-runtime";var Te=vt.forwardRef(({className:e,...t},r)=>yo("textarea",{className:m("flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",e),ref:r,...t}));Te.displayName="Textarea";import{jsx as q,jsxs as Ie}from"react/jsx-runtime";function Ft({name:e,description:t,label:r,onChange:a,maxLength:i,component:d,...p}){let{components:g}=x(),{control:v}=_o();return q(C,{control:v,name:e,render:({field:n,fieldState:c})=>{let u=d||g?.textarea;if(u){let l={name:e,description:t,label:r,maxLength:i,...p};return q(u,{field:{...n,onChange:o(h=>{n.onChange(h),a?.(h)},"onChange")},fieldState:c,fieldData:l})}let s=n.value?.length??0;return Ie(R,{"data-field":e,className:`RemoteFlows__TextArea__Item__${e}`,children:[q(S,{className:"RemoteFlows__TextArea__Label",children:r}),q(N,{children:q(Te,{...n,value:n.value??"",onChange:l=>{n.onChange(l),a?.(l)},className:m(c.error&&"border-red-500 focus-visible:ring-red-500","RemoteFlows__TextArea__Input"),placeholder:r})}),(t||i)&&Ie("div",{className:"flex items-center justify-between",children:[t&&q(w,{className:"RemoteFlows__TextArea__Description",children:t}),i&&Ie("span",{className:"text-sm ml-auto RemoteFlows__TextArea__MaxLength",children:[s,"/",i]})]}),c.error&&q(T,{className:"RemoteFlows__TextArea__Error"})]})}})}o(Ft,"TextAreaField");import{useFormContext as xo}from"react-hook-form";import{jsx as We}from"react/jsx-runtime";function ht(e){let{components:t}=x(),{control:r}=xo(),a=e.component||t?.email;return a?We(C,{control:r,name:e.name,render:({field:i,fieldState:d})=>We(a,{field:{...i,onChange:o(p=>{i.onChange(p),e.onChange?.(p)},"onChange")},fieldState:d,fieldData:e})}):We(A,{...e,type:"email"})}o(ht,"EmailField");import{useFormContext as Co}from"react-hook-form";import{jsx as yt}from"react/jsx-runtime";function _t(e){let{control:t}=Co();return yt(C,{control:t,name:e.name,render:({field:r})=>yt("input",{...r,type:"hidden"})})}o(_t,"HiddenField");import No,{useEffect as wo,useState as Pt}from"react";import{yupResolver as Do}from"@hookform/resolvers/yup";import{useForm as To,useFormContext as Io,useFieldArray as Wo}from"react-hook-form";import*as I from"yup";import xt from"lodash.groupby";import Z from"lodash.capitalize";var Ct=60,pe=["monday","tuesday","wednesday","thursday","friday","saturday","sunday"];function bo(e){if(e<60)return`${e}m`;let t=Math.floor(e/Ct),r=e%Ct;return r>0?`${t}h${r}m`:`${t}h`}o(bo,"convertBreakDurationToHours");function bt(e){let t=e.reduce((r,a)=>a.hours+r,0);return Number(t.toFixed(2))}o(bt,"calculateTotalWorkHours");function So(e,t){let r=t.map(({day:d})=>d.toLowerCase()),a=r.indexOf(e),i=null;for(;a<r.length&&!i;){let d=r[a],p=r[a+1],g=pe.indexOf(d)+1;pe[g]===p||(i=d),a+=1}return i}o(So,"findLastConsecutiveDay");function Po(e){return e.start_time&&e.end_time&&(typeof e.hours=="number"?e.hours:Number.parseInt(e.hours))>0}o(Po,"shouldSummarizeSchedule");function ko(e){return Number.parseInt(e.break_duration_minutes)>0}o(ko,"shouldSummarizeBreaks");function St(e){let t=e.filter(Po),r=xt(t,g=>`${g.start_time}|${g.end_time}`),a=e.filter(ko),i=xt(a,"break_duration_minutes"),d=Object.keys(r).map(g=>{let v=r[g],n=v[0].day,[c,u]=g.split("|"),s=`from <span>${c.replace(":","h")}</span> to <span>${u.replace(":","h")}</span>`,l=So(n,v),f=(l?v.findIndex(_=>_.day===l):-1)===v.length-1;return v.length===1?`${Z(n)}, ${s}`:!f||!l?v.reduce((_,k,b)=>{let M=Z(k.day);return b===v.length-1?`${_}and ${M}, ${s}`:`${_}<span>${M}</span>, `},""):`<span>${Z(n)}</span> to <span>${Z(l)}</span>, ${s}`}),p=Object.keys(i).reverse().map((g,v)=>{let n=v===0,c=i[g],u=bo(parseInt(g,10));if(Object.keys(i).length===1)return`With ${u} daily breaks`;if(c.length===1){let s=`${u} break on ${Z(c[0].day)}.`;return n?`With ${s}`:s}return c.reduce((s,l,h)=>{let f=Z(l.day);return h===0?`${s} ${f}`:h===c.length-1?`${s}, and ${f}.`:`${s}, ${f}`},n?`With ${u} break on`:`${u} break on`)});return{workHoursSummary:d,breakSummary:p}}o(St,"buildWorkScheduleSummary");function Le(e){let{checked:t,start_time:r,end_time:a,break_duration_minutes:i}=e;if(!t)return 0;let[d,p]=r.split(":").map(Number),[g,v]=a.split(":").map(Number),n=d*60+p,s=(g*60+v-n-Number.parseInt(i||"0"))/60;return s===Math.floor(s)?s:Number(s.toFixed(2))}o(Le,"calculateHours");var Ro={monday:"Mon",tuesday:"Tue",wednesday:"Wed",thursday:"Thu",friday:"Fri",saturday:"Sat",sunday:"Sun"};function ue(e){return Ro[e]}o(ue,"getShortWeekday");import{jsx as F,jsxs as E}from"react/jsx-runtime";var Lo=I.object({day:I.string().required(),checked:I.boolean().required(),start_time:I.string().matches(/^([01]\d|2[0-3]):([0-5]\d)$/,"Invalid time format (HH:mm)").when("checked",{is:!0,then:o(e=>e.required("Required"),"then"),otherwise:o(e=>e.optional().nullable(),"otherwise")}),end_time:I.string().matches(/^([01]\d|2[0-3]):([0-5]\d)$/,"Invalid time format (HH:mm)").when("checked",{is:!0,then:o(e=>e.required("Required"),"then"),otherwise:o(e=>e.optional().nullable(),"otherwise")}),hours:I.number().default(0),break_duration_minutes:I.string().default("0")}),Mo=I.object({schedule:I.array(Lo)});function $o({defaultSchedule:e,onSubmit:t}){let[r,a]=Pt(!1),i=pe.map(f=>{let _=e.find(k=>k.day.toLowerCase()===ue(f).toLowerCase()||k.day.toLowerCase()===f.toLowerCase());return _?{..._,day:ue(f),checked:!0}:{...e[0],checked:!1,day:ue(f)}}),d=To({defaultValues:{schedule:i},resolver:Do(Mo)}),{handleSubmit:p,watch:g,reset:v,control:n,formState:c}=d,{fields:u}=Wo({name:"schedule",control:n}),s=g("schedule");function l(f){let _=f.schedule.filter(({checked:k})=>k).map(k=>({...k,hours:Le(k)}));t(_),a(!1)}o(l,"handleSubmitWorkingHours");function h(){v(),a(!1)}return o(h,"handleCancel"),F("div",{className:"flex items-center justify-between",children:E(Re,{open:r,onOpenChange:a,children:[F(st,{asChild:!0,children:F(B,{variant:"link",className:"flex items-center p-0 RemoteFlows__WorkScheduleSelectionForm__Trigger",children:"Edit Schedule"})}),E(Ne,{className:"max-w-5xl max-h-[90vh] overflow-y-auto px-8 py-4 RemoteFlows__WorkScheduleSelectionForm__Content",children:[F(we,{children:F(De,{className:"RemoteFlows__WorkScheduleSelectionForm__Title",children:"Edit employee working hours"})}),F(Me,{...d,children:E("form",{className:"space-y-4 RemoteFlows__WorkScheduleSelectionForm__Form",children:[E("div",{className:"rounded-lg",children:[F("p",{className:"text-gray-600 text-sm mb-4 RemoteFlows__WorkScheduleSelectionForm__Description",children:"The times displayed are in the employee's time zone in the 24-hour format."}),E("div",{className:"grid grid-cols-12 gap-4 text-sm font-medium text-gray-500 uppercase tracking-wide RemoteFlows__WorkScheduleSelectionForm__Header",children:[F("div",{className:"col-span-2"}),F("div",{className:"col-span-3 text-center",children:"START"}),F("div",{className:"col-span-1 text-center"}),F("div",{className:"col-span-3 text-center",children:"END"}),F("div",{className:"col-span-2 text-center",children:"HOURS"})]}),F("div",{className:"RemoteFlows__WorkScheduleSelectionForm__Rows",children:u.map((f,_)=>{let k=s[_],b=Le(k);return E(No.Fragment,{children:[E("div",{className:"grid grid-cols-12 gap-4 items-center py-2 RemoteFlows__WorkScheduleSelectionForm__Row-Hours",children:[F("div",{className:"col-span-2 flex items-center gap-3",children:F(re,{label:f.day,name:`schedule.${_}.checked`})}),F("div",{className:"col-span-3",children:F(A,{name:`schedule.${_}.start_time`,includeErrorMessage:!1})}),F("div",{className:"col-span-1 text-center text-gray-500",children:"to"}),F("div",{className:"col-span-3",children:F(A,{name:`schedule.${_}.end_time`,includeErrorMessage:!1})}),F("div",{className:"col-span-2 text-center text-gray-600",children:isNaN(b)?"-":`${b} hours`})]}),E("div",{className:"grid grid-cols-12 gap-4 items-center py-2 RemoteFlows__WorkScheduleSelectionForm__Row-Break",children:[F("div",{className:"col-span-2 text-gray-500",children:"Break"}),F("div",{className:"col-span-2",children:F(A,{name:`schedule.${_}.break_duration_minutes`,includeErrorMessage:!1})}),F("div",{className:"col-span-2 text-gray-500",children:"minutes"}),F("div",{className:"col-span-4"})]})]},f.id)})})]}),Object.keys(c.errors).length>0&&F("p",{className:"text-destructive text-sm mb-0",children:"Invalid time format (HH:mm)"}),E("div",{className:"flex gap-4 pt-4",children:[F(B,{type:"button",className:"reset-button",variant:"outline",onClick:h,children:"Cancel"}),F(B,{type:"button",className:"submit-button",onClick:p(l),children:"Save Schedule"})]})]})})]})]})})}o($o,"WorkScheduleSelectionForm");function kt(e){let{components:t}=x(),{setValue:r,control:a,watch:i}=Io(),d=i(e.name),[p,g]=Pt(d),{workHoursSummary:v,breakSummary:n}=St(p),c=bt(p);wo(()=>{r(e.name,p)},[p,e.name,r]);function u(l){g(l)}o(u,"onSubmit");let s=e.component||t?.["work-schedule"];return s?F(C,{control:a,name:e.name,render:({field:l,fieldState:h})=>F(s,{field:{...l,onChange:o(f=>{l.onChange(f),e.onChange?.(f)},"onChange")},fieldState:h,fieldData:{...e,defaultFormattedValue:{workHoursSummary:v,breakSummary:n,totalWorkHours:c}}})}):E("div",{className:"flex flex-col gap-3 RemoteFlows__WorkScheduleField",children:[F("p",{className:"text-sm RemoteFlows__WorkScheduleField__Title",children:"Work hours"}),E("div",{className:"flex flex-col gap-1 RemoteFlows__WorkScheduleField__Summary",children:[F("p",{className:"text-sm text-gray-500 RemoteFlows__WorkScheduleField__Summary__WorkHours",dangerouslySetInnerHTML:{__html:v.join(", ")}}),F("p",{className:"text-sm text-gray-500 RemoteFlows__WorkScheduleField__Summary__Break",children:n.join()}),E("p",{className:"text-sm text-gray-500 RemoteFlows__WorkScheduleField__Summary__Total",children:["Total of ",F("span",{children:c})," hours per week"]}),F($o,{defaultSchedule:p,onSubmit:u})]})]})}o(kt,"WorkScheduleField");var ce={checkbox:re,text:A,email:ht,money:be,select:it,radio:Qe,number:be,file:Ke,fieldset:Ue,date:Ae,textarea:Ft,countries:gt,hidden:_t,"work-schedule":kt};import{useEffect as Ho}from"react";import{useFormContext as Eo}from"react-hook-form";import{Fragment as Bo,jsx as fe,jsxs as Ao}from"react/jsx-runtime";function Rt({name:e,value:t,description:r,statement:a}){let{setValue:i}=Eo();return Ho(()=>{i(e,t)},[]),fe("div",{children:a?Ao(Bo,{children:[fe("p",{className:`text-sm RemoteFlows__ForcedValue__Title__${e}`,dangerouslySetInnerHTML:{__html:a?.title}}),fe("p",{className:`text-xs RemoteFlows__ForcedValue__Description__${e}`,dangerouslySetInnerHTML:{__html:a?.description}})]}):fe("p",{className:`text-xs RemoteFlows__ForcedValue__Description__${e}`,dangerouslySetInnerHTML:{__html:r}})})}o(Rt,"ForcedValueField");import{Fragment as Go,jsx as j,jsxs as Nt}from"react/jsx-runtime";function Oo(e){return e.const!==void 0&&e.const===e.default&&e.inputType!=="checkbox"&&e.inputType!=="hidden"}o(Oo,"checkFieldHasForcedValue");var Mi=o(({fields:e,components:t})=>!e||e.length===0?null:j(Go,{children:e.map(r=>{if(r.isVisible===!1||r.deprecated)return null;if(Oo(r))return j(Rt,{name:r.name,description:r.description,value:r.const,statement:r.statement},r.name);if(r.Component){let{Component:i}=r;return j(i,{...r},r.name)}let a=ce[r.inputType];return r.inputType==="fieldset"?j(a,{...r,components:t}):a?Nt(zo,{children:[j(a,{...r,component:t&&t[r.inputType]}),r.statement?j(me,{...r.statement}):null]},r.name):Nt("p",{className:"error",children:["Field type ",r.inputType," not supported"]})})}),"JSONSchemaFormFields");export{Mi as a};
|
|
2
|
+
//# sourceMappingURL=chunk-2NLOH7NZ.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as m}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{a as m}from"./chunk-BYKZON2I.js";import{b as a}from"./chunk-PGWKJ6FK.js";import{b as t}from"./chunk-QW4JPW6J.js";import{d as s}from"./chunk-MH6KKP6K.js";import{a as e}from"./chunk-P37U34EQ.js";import{jsx as E}from"react/jsx-runtime";function P({components:d,onSubmit:l,onError:i,onSuccess:f}){let{onboardingBag:o}=a(),p=o.fields??[],c=s(p,o.initialValues.benefits);return E(m,{defaultValues:c,components:d,onSubmit:e(async n=>{try{await l?.(n);let r=await o.onSubmit(n);if(r?.data){await f?.(r.data),o?.next();return}if(r?.error){let u=t(r?.fieldErrors||[],o.meta?.fields?.benefits);i?.({error:r.error,rawError:r.rawError,fieldErrors:u})}}catch(r){i?.({error:r,rawError:r,fieldErrors:[]})}},"handleSubmit")})}e(P,"BenefitsStep");export{P as a};
|
|
2
|
+
//# sourceMappingURL=chunk-4J55VB37.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{a as s}from"./chunk-P37U34EQ.js";var p={select_country:{index:0,name:"select_country"},basic_information:{index:1,name:"basic_information"},contract_details:{index:2,name:"contract_details"},benefits:{index:3,name:"benefits"},review:{index:4,name:"review"}},c={basic_information:{index:0,name:"basic_information"},contract_details:{index:1,name:"contract_details"},benefits:{index:2,name:"benefits"},review:{index:3,name:"review"}};function l(o,a){return a?Object.fromEntries(Object.entries(o).map(([t,r])=>{if(r===void 0)return[t,void 0];let e=a.find(n=>n.name===t);if(e?.isVisible===!1||e?.deprecated)return[t,void 0];if(e?.type==="radio"||e?.type==="select"){let n=e.options.find(i=>i.value===r);return n?[t,{prettyValue:n?.label,label:e?.label,inputType:e?.type}]:void 0}if(e?.type==="checkbox"&&e?.const)return[t,{prettyValue:!0,label:e.label,inputType:e?.type}];if(e?.type==="countries"&&Array.isArray(r))return[t,{prettyValue:r.join(),label:e.label,inputType:e?.type}];if(e?.type==="fieldset"){let n=l(r,e.fields);if(!n.label&&n.value){let i={...n.value,label:e.label,inputType:e?.type};return[t,i]}return[t,n]}if(e?.type==="money")return[t,{prettyValue:r,label:e.label,inputType:e?.type,desiredCurrency:e?.desiredCurrency}];if(e)return[t,{prettyValue:r,label:e.label,inputType:e?.type}]}).filter(Boolean)):{}}s(l,"prettifyFormValues");var d=["invited","created_awaiting_reserve","created_reserve_paid"];export{p as a,c as b,l as c,d};
|
|
2
|
+
//# sourceMappingURL=chunk-4UBZTJMC.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/flows/Onboarding/utils.ts"],"sourcesContent":["import { Employment } from '@/src/flows/Onboarding/types';\nimport { Step } from '@/src/flows/useStepState';\nimport { Fields } from '@remoteoss/json-schema-form';\n\ntype StepKeys =\n | 'select_country'\n | 'basic_information'\n | 'contract_details'\n | 'benefits'\n | 'review';\n\nexport const STEPS: Record<StepKeys, Step<StepKeys>> = {\n select_country: {\n index: 0,\n name: 'select_country',\n },\n basic_information: { index: 1, name: 'basic_information' },\n contract_details: { index: 2, name: 'contract_details' },\n benefits: { index: 3, name: 'benefits' },\n review: { index: 4, name: 'review' },\n} as const;\n\nexport const STEPS_WITHOUT_SELECT_COUNTRY: Record<\n Exclude<StepKeys, 'select_country'>,\n Step<Exclude<StepKeys, 'select_country'>>\n> = {\n basic_information: { index: 0, name: 'basic_information' },\n contract_details: { index: 1, name: 'contract_details' },\n benefits: { index: 2, name: 'benefits' },\n review: { index: 3, name: 'review' },\n} as const;\n\n/**\n * Function to prettify form values. Returns a pretty value and label for each field.\n * @param values - Form values to prettify\n * @param fields - Form fields\n * @returns Prettified form values\n */\n// @ts-expect-error need to check function return type\nexport function prettifyFormValues(\n values: Record<string, unknown>,\n fields: Fields | undefined,\n) {\n if (!fields) {\n return {};\n }\n return Object.fromEntries(\n Object.entries(values)\n // @ts-expect-error need to check function return type\n .map(([key, value]) => {\n if (value === undefined) {\n return [key, undefined];\n }\n\n const field = fields.find((field) => field.name === key);\n\n if (field?.isVisible === false || field?.deprecated) {\n return [key, undefined];\n }\n\n if (field?.type === 'radio' || field?.type === 'select') {\n const option = (\n field.options as Array<{ value: string; label: string }>\n ).find((option) => option.value === value);\n\n if (option) {\n return [\n key,\n {\n prettyValue: option?.label,\n label: field?.label,\n inputType: field?.type,\n },\n ];\n }\n return;\n }\n\n if (field?.type === 'checkbox' && field?.const) {\n return [\n key,\n { prettyValue: true, label: field.label, inputType: field?.type },\n ];\n }\n\n if (field?.type === 'countries' && Array.isArray(value)) {\n return [\n key,\n {\n prettyValue: value.join(),\n label: field.label,\n inputType: field?.type,\n },\n ];\n }\n\n if (field?.type === 'fieldset') {\n // @ts-expect-error need to check function return type\n const prettiedFieldset = prettifyFormValues(\n value as Record<string, unknown>,\n field.fields as Fields,\n );\n\n // Handles benefits fieldset in specific\n if (!prettiedFieldset.label && prettiedFieldset.value) {\n const prettyValue: Record<string, unknown> = {\n ...prettiedFieldset.value,\n label: field.label,\n inputType: field?.type,\n };\n return [key, prettyValue];\n }\n\n return [key, prettiedFieldset];\n }\n\n if (field?.type === 'money') {\n return [\n key,\n {\n prettyValue: value,\n label: field.label,\n inputType: field?.type,\n desiredCurrency: field?.desiredCurrency,\n },\n ];\n }\n\n if (field) {\n return [\n key,\n { prettyValue: value, label: field.label, inputType: field?.type },\n ];\n }\n })\n .filter(Boolean),\n );\n}\n\n/**\n * Array of employment statuses that are allowed to proceed to the review step.\n * These statuses indicate that the employment is in a final state and the employment cannot be modified further.\n * @type {Employment['status'][]}\n * @constant\n */\nexport const reviewStepAllowedEmploymentStatus: Employment['status'][] = [\n 'invited',\n 'created_awaiting_reserve',\n 'created_reserve_paid',\n];\n"],"mappings":"wCAWO,IAAMA,EAA0C,CACrD,eAAgB,CACd,MAAO,EACP,KAAM,gBACR,EACA,kBAAmB,CAAE,MAAO,EAAG,KAAM,mBAAoB,EACzD,iBAAkB,CAAE,MAAO,EAAG,KAAM,kBAAmB,EACvD,SAAU,CAAE,MAAO,EAAG,KAAM,UAAW,EACvC,OAAQ,CAAE,MAAO,EAAG,KAAM,QAAS,CACrC,EAEaC,EAGT,CACF,kBAAmB,CAAE,MAAO,EAAG,KAAM,mBAAoB,EACzD,iBAAkB,CAAE,MAAO,EAAG,KAAM,kBAAmB,EACvD,SAAU,CAAE,MAAO,EAAG,KAAM,UAAW,EACvC,OAAQ,CAAE,MAAO,EAAG,KAAM,QAAS,C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,CACLF,EACA,CAAE,YAAaC,EAAO,MAAOC,EAAM,MAAO,UAAWA,GAAO,IAAK,CACnE,CAEJ,CAAC,EACA,OAAO,OAAO,CACnB,EA5FS,CAAC,CA6FZ,CAlGgBI,EAAAT,EAAA,sBA0GT,IAAMU,EAA4D,CACvE,UACA,2BACA,sBACF","names":["STEPS","STEPS_WITHOUT_SELECT_COUNTRY","prettifyFormValues","values","fields","key","value","field","option","prettiedFieldset","prettyValue","__name","reviewStepAllowedEmploymentStatus"]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as s}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{a as s}from"./chunk-BYKZON2I.js";import{b as t}from"./chunk-PGWKJ6FK.js";import{b as e}from"./chunk-QW4JPW6J.js";import{a as i}from"./chunk-P37U34EQ.js";import{jsx as c}from"react/jsx-runtime";function S({onSubmit:m,onSuccess:d,onError:a}){let{onboardingBag:o}=t(),l=i(async n=>{try{await m?.(o.parseFormValues(n));let r=await o.onSubmit(n);if(r?.data){await d?.(r?.data),o?.next();return}if(r?.error){let p=e(r?.fieldErrors||[],o.meta?.fields?.basic_information);a?.({error:r?.error,rawError:r?.rawError,fieldErrors:p})}}catch(r){a?.({error:r,rawError:r,fieldErrors:[]})}},"handleSubmit"),f=o.stepState.values?.basic_information||o.initialValues.basic_information;return c(s,{defaultValues:f,onSubmit:l})}i(S,"BasicInformationStep");export{S as a};
|
|
2
|
+
//# sourceMappingURL=chunk-6ACAZ6EG.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{b as f}from"./chunk-MRYRNB7Y.js";import{a as l}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{b as f}from"./chunk-MRYRNB7Y.js";import{a as l}from"./chunk-2NLOH7NZ.js";import{b as s}from"./chunk-CFIJKJXD.js";import{a}from"./chunk-VNSF5IOL.js";import{a as n}from"./chunk-P37U34EQ.js";import{useEffect as y}from"react";import{useForm as T}from"react-hook-form";import{jsx as e}from"react/jsx-runtime";function A({fields:m,onSubmit:d}){let{formId:F,terminationBag:o}=f(),u=s(o.handleValidation),i=T({resolver:u,defaultValues:o?.initialValues,shouldUnregister:!1,mode:"onBlur"});y(()=>{let p=i?.watch(r=>{Object.keys(r).some(t=>r[t]!==o?.initialValues?.[t])&&o?.checkFieldUpdates(r)});return()=>p?.unsubscribe()},[]);let c=m||(o?.fields??[]);return e(a,{...i,children:e("form",{id:F,onSubmit:i.handleSubmit(d),className:"space-y-4 RemoteFlows__TerminationForm",children:e(l,{fields:c})})})}n(A,"TerminationForm");export{A as a};
|
|
2
|
+
//# sourceMappingURL=chunk-6SWZH7KI.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as S}from"./chunk-XFD3ULUF.js";import{a as P}from"./chunk-WWANHPT7.js";import{a as h}from"./chunk-DR7VGNO2.js";import{a as F}from"./chunk-S4XU4SE7.js";import{a as T}from"./chunk-PWUYHFON.js";import{a as y}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{a as S}from"./chunk-XFD3ULUF.js";import{a as P}from"./chunk-WWANHPT7.js";import{a as h}from"./chunk-DR7VGNO2.js";import{a as F}from"./chunk-S4XU4SE7.js";import{a as T}from"./chunk-PWUYHFON.js";import{a as y}from"./chunk-QW4JPW6J.js";import{b as p}from"./chunk-WKK63LAY.js";import{a as V}from"./chunk-PJBAQZ6G.js";import{d as _}from"./chunk-3ZWDIEEM.js";import{c as s}from"./chunk-MH6KKP6K.js";import{a as e}from"./chunk-P37U34EQ.js";import{createHeadlessForm as g,modify as x}from"@remoteoss/json-schema-form";import{useMutation as A,useQuery as K}from"@tanstack/react-query";import L from"lodash.omitby";import q from"lodash.isnull";import z from"lodash.omit";function R(o){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,...o}}e(R,"buildInitialValues");var B=e(()=>{let{client:o}=_();return A({mutationFn:e(n=>p({client:o,headers:{Authorization:""},body:n}),"mutationFn")})},"useCreateTermination"),I=e(({formValues:o,jsfModify:n,step:m})=>K({queryKey:["rmt-flows-termination-schema",m],queryFn:e(()=>h[m]??S,"queryFn"),select:e(({data:u})=>{let i=u?.schema||{};if(n){let{schema:d}=x(i,n);i=d}return g(i||{},{initialValues:o||{}})},"select")}),"useTerminationSchema"),ue=e(({employmentId:o,options:n})=>{let{fieldValues:m,setFieldValues:u,stepState:i,previousStep:f,nextStep:d}=V(F),k={...i.values?.[i.currentStep.name],...m},{data:r,isLoading:w}=I({formValues:k,jsfModify:n?.jsfModify,step:i.currentStep.name}),l=g(P.data.schema),c=B(),{mutateAsync:b}=y(c);async function C(a){if(!o)throw new Error("Employment id is missing");if(r){let t=s(a,l.fields,{isPartialValidation:!0}),{customer_informed_employee:j}=t,D=j==="yes"?{employee_awareness:{date:t.customer_informed_employee_date,note:t.customer_informed_employee_description}}:void 0,H=T(t,["agrees_to_pto_amount","confidential","customer_informed_employee","will_challenge_termination"]),J=z(H,"customer_informed_employee_date","customer_informed_employee_description"),O=L({...J,...D},q);return b({employment_id:o,termination_details:O,type:"termination"})}}e(C,"onSubmit");function M(){f()}e(M,"back");function v(){d()}e(v,"next");let E=R({...i.values?.employee_communication,...i.values?.termination_details,...i.values?.paid_time_off,...i.values?.additional_information});return{employmentId:o,stepState:i,fields:r?.fields||[],isLoading:w,isSubmitting:c.isPending,initialValues:E,handleValidation:e(a=>{if(r){let t=s(a,r?.fields);return r?.handleValidation(t)}return null},"handleValidation"),checkFieldUpdates:e(a=>{if(l){let t=s(a,l?.fields,{isPartialValidation:!0});u(t)}},"checkFieldUpdates"),parseFormValues:e(a=>s(a,l.fields,{isPartialValidation:!0}),"parseFormValues"),onSubmit:C,back:M,next:v}},"useTermination");export{ue as a};
|
|
2
|
+
//# sourceMappingURL=chunk-AI2TYE56.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as s}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{a as s}from"./chunk-BYKZON2I.js";import{b as n}from"./chunk-PGWKJ6FK.js";import{b as i}from"./chunk-QW4JPW6J.js";import{a as e}from"./chunk-P37U34EQ.js";import{jsx as p}from"react/jsx-runtime";function F({onSubmit:l,onError:t,onSuccess:d}){let{onboardingBag:o}=n(),m=e(async a=>{try{await l?.(o.parseFormValues(a));let r=await o.onSubmit(a);if(r?.data){await d?.(r.data),o?.next();return}if(r?.error){let c=i(r?.fieldErrors||[],o.meta?.fields?.contract_details);t?.({error:r.error,rawError:r.rawError,fieldErrors:c})}}catch(r){t?.({error:r,rawError:r,fieldErrors:[]})}},"handleSubmit");return p(s,{defaultValues:o.stepState.values?.contract_details||o.initialValues.contract_details,onSubmit:m})}e(F,"ContractDetailsStep");export{F as a};
|
|
2
|
+
//# sourceMappingURL=chunk-BMEK4OFQ.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{b as l}from"./chunk-PGWKJ6FK.js";import{a as d}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{b as l}from"./chunk-PGWKJ6FK.js";import{a as d}from"./chunk-2NLOH7NZ.js";import{b as s}from"./chunk-CFIJKJXD.js";import{a}from"./chunk-VNSF5IOL.js";import{a as t}from"./chunk-P37U34EQ.js";import{useEffect as f}from"react";import{useForm as b}from"react-hook-form";import{jsx as e}from"react/jsx-runtime";function w({defaultValues:i,onSubmit:c,components:p}){let{formId:F,onboardingBag:o}=l(),u=s(o.handleValidation),r=b({resolver:u,defaultValues:i,shouldUnregister:!1,mode:"onBlur"});return f(()=>{o.employmentId&&o?.checkFieldUpdates(r.getValues())},[]),f(()=>{let y=r?.watch(n=>{Object.keys(n).some(m=>n[m]!==i[m])&&o?.checkFieldUpdates(n)});return()=>y?.unsubscribe()},[]),e(a,{...r,children:e("form",{id:F,onSubmit:r.handleSubmit(c),className:"space-y-4 RemoteFlows__OnboardingForm",children:e(d,{components:p,fields:o.fields})})})}t(w,"OnboardingForm");export{w as a};
|
|
2
|
+
//# sourceMappingURL=chunk-BYKZON2I.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{m as N}from"./chunk-AN7L3GVL.js";import{a as q}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{m as N}from"./chunk-AN7L3GVL.js";import{a as q}from"./chunk-RLETCEUU.js";import{b as M}from"./chunk-3ZWDIEEM.js";import{a as t,b as u,c as Se}from"./chunk-P37U34EQ.js";var F=u((pt,P)=>{"use strict";function Te(e){var n=typeof e;return e!=null&&(n=="object"||n=="function")}t(Te,"isObject");P.exports=Te});var W=u((vt,L)=>{"use strict";var he=typeof global=="object"&&global&&global.Object===Object&&global;L.exports=he});var w=u((yt,D)=>{"use strict";var Ce=W(),xe=typeof self=="object"&&self&&self.Object===Object&&self,je=Ce||xe||Function("return this")();D.exports=je});var $=u((St,B)=>{"use strict";var _e=w(),Oe=t(function(){return _e.Date.now()},"now");B.exports=Oe});var J=u((ht,H)=>{"use strict";var Ee=/\s/;function Re(e){for(var n=e.length;n--&&Ee.test(e.charAt(n)););return n}t(Re,"trimmedEndIndex");H.exports=Re});var V=u((xt,U)=>{"use strict";var qe=J(),Fe=/^\s+/;function we(e){return e&&e.slice(0,qe(e)+1).replace(Fe,"")}t(we,"baseTrim");U.exports=we});var I=u((_t,X)=>{"use strict";var Ie=w(),ke=Ie.Symbol;X.exports=ke});var Y=u((Ot,Q)=>{"use strict";var z=I(),K=Object.prototype,Ae=K.hasOwnProperty,Ge=K.toString,j=z?z.toStringTag:void 0;function Me(e){var n=Ae.call(e,j),o=e[j];try{e[j]=void 0;var i=!0}catch{}var a=Ge.call(e);return i&&(n?e[j]=o:delete e[j]),a}t(Me,"getRawTag");Q.exports=Me});var ee=u((Rt,Z)=>{"use strict";var Ne=Object.prototype,Pe=Ne.toString;function Le(e){return Pe.call(e)}t(Le,"objectToString");Z.exports=Le});var oe=u((Ft,re)=>{"use strict";var te=I(),We=Y(),De=ee(),Be="[object Null]",$e="[object Undefined]",ne=te?te.toStringTag:void 0;function He(e){return e==null?e===void 0?$e:Be:ne&&ne in Object(e)?We(e):De(e)}t(He,"baseGetTag");re.exports=He});var ae=u((It,ie)=>{"use strict";function Je(e){return e!=null&&typeof e=="object"}t(Je,"isObjectLike");ie.exports=Je});var ce=u((At,se)=>{"use strict";var Ue=oe(),Ve=ae(),Xe="[object Symbol]";function ze(e){return typeof e=="symbol"||Ve(e)&&Ue(e)==Xe}t(ze,"isSymbol");se.exports=ze});var me=u((Mt,fe)=>{"use strict";var Ke=V(),ue=F(),Qe=ce(),le=NaN,Ye=/^[-+]0x[0-9a-f]+$/i,Ze=/^0b[01]+$/i,et=/^0o[0-7]+$/i,tt=parseInt;function nt(e){if(typeof e=="number")return e;if(Qe(e))return le;if(ue(e)){var n=typeof e.valueOf=="function"?e.valueOf():e;e=ue(n)?n+"":n}if(typeof e!="string")return e===0?e:+e;e=Ke(e);var o=Ze.test(e);return o||et.test(e)?tt(e.slice(2),o?2:8):Ye.test(e)?le:+e}t(nt,"toNumber");fe.exports=nt});var pe=u((Pt,ge)=>{"use strict";var rt=F(),k=$(),de=me(),ot="Expected a function",it=Math.max,at=Math.min;function st(e,n,o){var i,a,m,f,s,d,b=0,S=!1,g=!1,v=!0;if(typeof e!="function")throw new TypeError(ot);n=de(n)||0,rt(o)&&(S=!!o.leading,g="maxWait"in o,m=g?it(de(o.maxWait)||0,n):m,v="trailing"in o?!!o.trailing:v);function T(r){var l=i,p=a;return i=a=void 0,b=r,f=e.apply(p,l),f}t(T,"invokeFunc");function O(r){return b=r,s=setTimeout(y,n),S?T(r):f}t(O,"leadingEdge");function E(r){var l=r-d,p=r-b,G=n-l;return g?at(G,m-p):G}t(E,"remainingWait");function R(r){var l=r-d,p=r-b;return d===void 0||l>=n||l<0||g&&p>=m}t(R,"shouldInvoke");function y(){var r=k();if(R(r))return h(r);s=setTimeout(y,E(r))}t(y,"timerExpired");function h(r){return s=void 0,v&&i?T(r):(i=a=void 0,f)}t(h,"trailingEdge");function c(){s!==void 0&&clearTimeout(s),b=0,i=d=a=s=void 0}t(c,"cancel");function C(){return s===void 0?f:h(k())}t(C,"flush");function x(){var r=k(),l=R(r);if(i=arguments,a=this,d=r,l){if(s===void 0)return O(d);if(g)return clearTimeout(s),s=setTimeout(y,n),T(d)}return s===void 0&&(s=setTimeout(y,n)),f}return t(x,"debounced"),x.cancel=c,x.flush=C,x}t(st,"debounce");ge.exports=st});import{useState as lt,useCallback as ft}from"react";import{useFormContext as mt}from"react-hook-form";var ve=Se(pe(),1);import{useCallback as ct,useEffect as ut,useRef as be}from"react";function A(e,n){let o=be(e);ut(()=>{o.current=e},[e]);let i=be((0,ve.default)(a=>{o.current(a)},n)).current;return ct(a=>{i(a)},[i])}t(A,"useDebounce");import{Fragment as gt,jsx as _,jsxs as ye}from"react/jsx-runtime";var dt=t(({description:e,showConversion:n,currency:o,onClick:i})=>{let{components:a}=M(),m=n?`Hide ${o} conversion`:`Show ${o} conversion`,f=a?.button;return ye("span",{className:"RemoteFlows-AnnualGrossSalary-description",children:[e," ",f?_(f,{className:"RemoteFlows-AnnualGrossSalary-button","data-type":"inline",onClick:i,children:m}):_("button",{className:"RemoteFlows-AnnualGrossSalary-button",onClick:i,children:m})]})},"DescriptionWithConversion"),Kt=t(({currency:e,desiredCurrency:n,description:o,...i})=>{let[a,m]=lt(!1),{setValue:f,watch:s}=mt(),d=s(i.name),b=e&&n&&e!==n,{mutateAsync:S}=N(),g=ft(async(c,C,x,r)=>{if(c)try{let l=await S({source_currency:C,target_currency:x,amount:Number(c)});if(l.data?.data?.conversion_data?.target_amount){let p=l.data.data.conversion_data.target_amount;p&&f(r,p?.toString())}}catch(l){console.error("Error converting currency:",l)}},[S,f]),v=A(c=>g(c,e,n,"annual_gross_salary_conversion"),500),T=A(c=>g(c,n,e,i.name),500),O=t(c=>{a&&v(c.target.value)},"handleAnnualGrossSalaryChange"),E=t(c=>{T(c.target.value)},"handleConversionChange"),y=b?_(dt,{currency:n,description:o,showConversion:a,onClick:t(c=>{c.preventDefault(),m(C=>!C),!a&&d&&v(d)},"toggleConversion")}):o,{annual_gross_salary_conversion_properties:h}=i;return ye(gt,{children:[_(q,{...i,additionalProps:{currency:e},description:y,type:"text",inputMode:"decimal",pattern:"^[0-9.]*$",onChange:O}),a&&_(q,{additionalProps:{currency:n},name:"annual_gross_salary_conversion",label:h?.label||"Conversion",description:h?.description||"Estimated amount. This is an estimation. We calculate conversions based on spot rates that are subject to fluctuation over time.",type:"text",inputMode:"decimal",pattern:"^[0-9.]*$",onChange:E})]})},"AnnualGrossSalary");export{Kt as a};
|
|
2
|
+
//# sourceMappingURL=chunk-CVTAWW6F.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../node_modules/lodash/isObject.js","../node_modules/lodash/_freeGlobal.js","../node_modules/lodash/_root.js","../node_modules/lodash/now.js","../node_modules/lodash/_trimmedEndIndex.js","../node_modules/lodash/_baseTrim.js","../node_modules/lodash/_Symbol.js","../node_modules/lodash/_getRawTag.js","../node_modules/lodash/_objectToString.js","../node_modules/lodash/_baseGetTag.js","../node_modules/lodash/isObjectLike.js","../node_modules/lodash/isSymbol.js","../node_modules/lodash/toNumber.js","../node_modules/lodash/debounce.js","../src/flows/Onboarding/AnnualGrossSalary.tsx","../src/common/hooks.ts"],"sourcesContent":["/**\n * Checks if `value` is the\n * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)\n * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is an object, else `false`.\n * @example\n *\n * _.isObject({});\n * // => true\n *\n * _.isObject([1, 2, 3]);\n * // => true\n *\n * _.isObject(_.noop);\n * // => true\n *\n * _.isObject(null);\n * // => false\n */\nfunction isObject(value) {\n var type = typeof value;\n return value != null && (type == 'object' || type == 'function');\n}\n\nmodule.exports = isObject;\n","/** Detect free variable `global` from Node.js. */\nvar freeGlobal = typeof global == 'object' && global && global.Object === Object && global;\n\nmodule.exports = freeGlobal;\n","var freeGlobal = require('./_freeGlobal');\n\n/** Detect free variable `self`. */\nvar freeSelf = typeof self == 'object' && self && self.Object === Object && self;\n\n/** Used as a reference to the global object. */\nvar root = freeGlobal || freeSelf || Function('return this')();\n\nmodule.exports = root;\n","var root = require('./_root');\n\n/**\n * Gets the timestamp of the number of milliseconds that have elapsed since\n * the Unix epoch (1 January 1970 00:00:00 UTC).\n *\n * @static\n * @memberOf _\n * @since 2.4.0\n * @category Date\n * @returns {number} Returns the timestamp.\n * @example\n *\n * _.defer(function(stamp) {\n * console.log(_.now() - stamp);\n * }, _.now());\n * // => Logs the number of milliseconds it took for the deferred invocation.\n */\nvar now = function() {\n return root.Date.now();\n};\n\nmodule.exports = now;\n","/** Used to match a single whitespace character. */\nvar reWhitespace = /\\s/;\n\n/**\n * Used by `_.trim` and `_.trimEnd` to get the index of the last non-whitespace\n * character of `string`.\n *\n * @private\n * @param {string} string The string to inspect.\n * @returns {number} Returns the index of the last non-whitespace character.\n */\nfunction trimmedEndIndex(string) {\n var index = string.length;\n\n while (index-- && reWhitespace.test(string.charAt(index))) {}\n return index;\n}\n\nmodule.exports = trimmedEndIndex;\n","var trimmedEndIndex = require('./_trimmedEndIndex');\n\n/** Used to match leading whitespace. */\nvar reTrimStart = /^\\s+/;\n\n/**\n * The base implementation of `_.trim`.\n *\n * @private\n * @param {string} string The string to trim.\n * @returns {string} Returns the trimmed string.\n */\nfunction baseTrim(string) {\n return string\n ? string.slice(0, trimmedEndIndex(string) + 1).replace(reTrimStart, '')\n : string;\n}\n\nmodule.exports = baseTrim;\n","var root = require('./_root');\n\n/** Built-in value references. */\nvar Symbol = root.Symbol;\n\nmodule.exports = Symbol;\n","var Symbol = require('./_Symbol');\n\n/** Used for built-in method references. */\nvar objectProto = Object.prototype;\n\n/** Used to check objects for own properties. */\nvar hasOwnProperty = objectProto.hasOwnProperty;\n\n/**\n * Used to resolve the\n * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)\n * of values.\n */\nvar nativeObjectToString = objectProto.toString;\n\n/** Built-in value references. */\nvar symToStringTag = Symbol ? Symbol.toStringTag : undefined;\n\n/**\n * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.\n *\n * @private\n * @param {*} value The value to query.\n * @returns {string} Returns the raw `toStringTag`.\n */\nfunction getRawTag(value) {\n var isOwn = hasOwnProperty.call(value, symToStringTag),\n tag = value[symToStringTag];\n\n try {\n value[symToStringTag] = undefined;\n var unmasked = true;\n } catch (e) {}\n\n var result = nativeObjectToString.call(value);\n if (unmasked) {\n if (isOwn) {\n value[symToStringTag] = tag;\n } else {\n delete value[symToStringTag];\n }\n }\n return result;\n}\n\nmodule.exports = getRawTag;\n","/** Used for built-in method references. */\nvar objectProto = Object.prototype;\n\n/**\n * Used to resolve the\n * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)\n * of values.\n */\nvar nativeObjectToString = objectProto.toString;\n\n/**\n * Converts `value` to a string using `Object.prototype.toString`.\n *\n * @private\n * @param {*} value The value to convert.\n * @returns {string} Returns the converted string.\n */\nfunction objectToString(value) {\n return nativeObjectToString.call(value);\n}\n\nmodule.exports = objectToString;\n","var Symbol = require('./_Symbol'),\n getRawTag = require('./_getRawTag'),\n objectToString = require('./_objectToString');\n\n/** `Object#toString` result references. */\nvar nullTag = '[object Null]',\n undefinedTag = '[object Undefined]';\n\n/** Built-in value references. */\nvar symToStringTag = Symbol ? Symbol.toStringTag : undefined;\n\n/**\n * The base implementation of `getTag` without fallbacks for buggy environments.\n *\n * @private\n * @param {*} value The value to query.\n * @returns {string} Returns the `toStringTag`.\n */\nfunction baseGetTag(value) {\n if (value == null) {\n return value === undefined ? undefinedTag : nullTag;\n }\n return (symToStringTag && symToStringTag in Object(value))\n ? getRawTag(value)\n : objectToString(value);\n}\n\nmodule.exports = baseGetTag;\n","/**\n * Checks if `value` is object-like. A value is object-like if it's not `null`\n * and has a `typeof` result of \"object\".\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is object-like, else `false`.\n * @example\n *\n * _.isObjectLike({});\n * // => true\n *\n * _.isObjectLike([1, 2, 3]);\n * // => true\n *\n * _.isObjectLike(_.noop);\n * // => false\n *\n * _.isObjectLike(null);\n * // => false\n */\nfunction isObjectLike(value) {\n return value != null && typeof value == 'object';\n}\n\nmodule.exports = isObjectLike;\n","var baseGetTag = require('./_baseGetTag'),\n isObjectLike = require('./isObjectLike');\n\n/** `Object#toString` result references. */\nvar symbolTag = '[object Symbol]';\n\n/**\n * Checks if `value` is classified as a `Symbol` primitive or object.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.\n * @example\n *\n * _.isSymbol(Symbol.iterator);\n * // => true\n *\n * _.isSymbol('abc');\n * // => false\n */\nfunction isSymbol(value) {\n return typeof value == 'symbol' ||\n (isObjectLike(value) && baseGetTag(value) == symbolTag);\n}\n\nmodule.exports = isSymbol;\n","var baseTrim = require('./_baseTrim'),\n isObject = require('./isObject'),\n isSymbol = require('./isSymbol');\n\n/** Used as references for various `Number` constants. */\nvar NAN = 0 / 0;\n\n/** Used to detect bad signed hexadecimal string values. */\nvar reIsBadHex = /^[-+]0x[0-9a-f]+$/i;\n\n/** Used to detect binary string values. */\nvar reIsBinary = /^0b[01]+$/i;\n\n/** Used to detect octal string values. */\nvar reIsOctal = /^0o[0-7]+$/i;\n\n/** Built-in method references without a dependency on `root`. */\nvar freeParseInt = parseInt;\n\n/**\n * Converts `value` to a number.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to process.\n * @returns {number} Returns the number.\n * @example\n *\n * _.toNumber(3.2);\n * // => 3.2\n *\n * _.toNumber(Number.MIN_VALUE);\n * // => 5e-324\n *\n * _.toNumber(Infinity);\n * // => Infinity\n *\n * _.toNumber('3.2');\n * // => 3.2\n */\nfunction toNumber(value) {\n if (typeof value == 'number') {\n return value;\n }\n if (isSymbol(value)) {\n return NAN;\n }\n if (isObject(value)) {\n var other = typeof value.valueOf == 'function' ? value.valueOf() : value;\n value = isObject(other) ? (other + '') : other;\n }\n if (typeof value != 'string') {\n return value === 0 ? value : +value;\n }\n value = baseTrim(value);\n var isBinary = reIsBinary.test(value);\n return (isBinary || reIsOctal.test(value))\n ? freeParseInt(value.slice(2), isBinary ? 2 : 8)\n : (reIsBadHex.test(value) ? NAN : +value);\n}\n\nmodule.exports = toNumber;\n","var isObject = require('./isObject'),\n now = require('./now'),\n toNumber = require('./toNumber');\n\n/** Error message constants. */\nvar FUNC_ERROR_TEXT = 'Expected a function';\n\n/* Built-in method references for those with the same name as other `lodash` methods. */\nvar nativeMax = Math.max,\n nativeMin = Math.min;\n\n/**\n * Creates a debounced function that delays invoking `func` until after `wait`\n * milliseconds have elapsed since the last time the debounced function was\n * invoked. The debounced function comes with a `cancel` method to cancel\n * delayed `func` invocations and a `flush` method to immediately invoke them.\n * Provide `options` to indicate whether `func` should be invoked on the\n * leading and/or trailing edge of the `wait` timeout. The `func` is invoked\n * with the last arguments provided to the debounced function. Subsequent\n * calls to the debounced function return the result of the last `func`\n * invocation.\n *\n * **Note:** If `leading` and `trailing` options are `true`, `func` is\n * invoked on the trailing edge of the timeout only if the debounced function\n * is invoked more than once during the `wait` timeout.\n *\n * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred\n * until to the next tick, similar to `setTimeout` with a timeout of `0`.\n *\n * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)\n * for details over the differences between `_.debounce` and `_.throttle`.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Function\n * @param {Function} func The function to debounce.\n * @param {number} [wait=0] The number of milliseconds to delay.\n * @param {Object} [options={}] The options object.\n * @param {boolean} [options.leading=false]\n * Specify invoking on the leading edge of the timeout.\n * @param {number} [options.maxWait]\n * The maximum time `func` is allowed to be delayed before it's invoked.\n * @param {boolean} [options.trailing=true]\n * Specify invoking on the trailing edge of the timeout.\n * @returns {Function} Returns the new debounced function.\n * @example\n *\n * // Avoid costly calculations while the window size is in flux.\n * jQuery(window).on('resize', _.debounce(calculateLayout, 150));\n *\n * // Invoke `sendMail` when clicked, debouncing subsequent calls.\n * jQuery(element).on('click', _.debounce(sendMail, 300, {\n * 'leading': true,\n * 'trailing': false\n * }));\n *\n * // Ensure `batchLog` is invoked once after 1 second of debounced calls.\n * var debounced = _.debounce(batchLog, 250, { 'maxWait': 1000 });\n * var source = new EventSource('/stream');\n * jQuery(source).on('message', debounced);\n *\n * // Cancel the trailing debounced invocation.\n * jQuery(window).on('popstate', debounced.cancel);\n */\nfunction debounce(func, wait, options) {\n var lastArgs,\n lastThis,\n maxWait,\n result,\n timerId,\n lastCallTime,\n lastInvokeTime = 0,\n leading = false,\n maxing = false,\n trailing = true;\n\n if (typeof func != 'function') {\n throw new TypeError(FUNC_ERROR_TEXT);\n }\n wait = toNumber(wait) || 0;\n if (isObject(options)) {\n leading = !!options.leading;\n maxing = 'maxWait' in options;\n maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait;\n trailing = 'trailing' in options ? !!options.trailing : trailing;\n }\n\n function invokeFunc(time) {\n var args = lastArgs,\n thisArg = lastThis;\n\n lastArgs = lastThis = undefined;\n lastInvokeTime = time;\n result = func.apply(thisArg, args);\n return result;\n }\n\n function leadingEdge(time) {\n // Reset any `maxWait` timer.\n lastInvokeTime = time;\n // Start the timer for the trailing edge.\n timerId = setTimeout(timerExpired, wait);\n // Invoke the leading edge.\n return leading ? invokeFunc(time) : result;\n }\n\n function remainingWait(time) {\n var timeSinceLastCall = time - lastCallTime,\n timeSinceLastInvoke = time - lastInvokeTime,\n timeWaiting = wait - timeSinceLastCall;\n\n return maxing\n ? nativeMin(timeWaiting, maxWait - timeSinceLastInvoke)\n : timeWaiting;\n }\n\n function shouldInvoke(time) {\n var timeSinceLastCall = time - lastCallTime,\n timeSinceLastInvoke = time - lastInvokeTime;\n\n // Either this is the first call, activity has stopped and we're at the\n // trailing edge, the system time has gone backwards and we're treating\n // it as the trailing edge, or we've hit the `maxWait` limit.\n return (lastCallTime === undefined || (timeSinceLastCall >= wait) ||\n (timeSinceLastCall < 0) || (maxing && timeSinceLastInvoke >= maxWait));\n }\n\n function timerExpired() {\n var time = now();\n if (shouldInvoke(time)) {\n return trailingEdge(time);\n }\n // Restart the timer.\n timerId = setTimeout(timerExpired, remainingWait(time));\n }\n\n function trailingEdge(time) {\n timerId = undefined;\n\n // Only invoke if we have `lastArgs` which means `func` has been\n // debounced at least once.\n if (trailing && lastArgs) {\n return invokeFunc(time);\n }\n lastArgs = lastThis = undefined;\n return result;\n }\n\n function cancel() {\n if (timerId !== undefined) {\n clearTimeout(timerId);\n }\n lastInvokeTime = 0;\n lastArgs = lastCallTime = lastThis = timerId = undefined;\n }\n\n function flush() {\n return timerId === undefined ? result : trailingEdge(now());\n }\n\n function debounced() {\n var time = now(),\n isInvoking = shouldInvoke(time);\n\n lastArgs = arguments;\n lastThis = this;\n lastCallTime = time;\n\n if (isInvoking) {\n if (timerId === undefined) {\n return leadingEdge(lastCallTime);\n }\n if (maxing) {\n // Handle invocations in a tight loop.\n clearTimeout(timerId);\n timerId = setTimeout(timerExpired, wait);\n return invokeFunc(lastCallTime);\n }\n }\n if (timerId === undefined) {\n timerId = setTimeout(timerExpired, wait);\n }\n return result;\n }\n debounced.cancel = cancel;\n debounced.flush = flush;\n return debounced;\n}\n\nmodule.exports = debounce;\n","import { ReactNode, useState, useCallback } from 'react';\nimport { useFormContext } from 'react-hook-form';\nimport { TextField } from '@/src/components/form/fields/TextField';\nimport { useConvertCurrency } from '@/src/flows/Onboarding/api';\nimport { JSFField } from '@/src/types/remoteFlows';\nimport { useFormFields } from '@/src/context';\nimport { useDebounce } from '@/src/common/hooks';\n\ntype DescriptionWithConversionProps = {\n description: ReactNode;\n showConversion: boolean;\n currency: string;\n onClick: (evt: React.MouseEvent<HTMLButtonElement>) => void;\n};\n\nconst DescriptionWithConversion = ({\n description,\n showConversion,\n currency,\n onClick,\n}: DescriptionWithConversionProps) => {\n const { components } = useFormFields();\n const label = showConversion\n ? `Hide ${currency} conversion`\n : `Show ${currency} conversion`;\n\n const CustomButton = components?.button;\n\n return (\n <span className=\"RemoteFlows-AnnualGrossSalary-description\">\n {description}{' '}\n {CustomButton ? (\n <CustomButton\n className=\"RemoteFlows-AnnualGrossSalary-button\"\n data-type=\"inline\"\n onClick={onClick}\n >\n {label}\n </CustomButton>\n ) : (\n <button\n className=\"RemoteFlows-AnnualGrossSalary-button\"\n onClick={onClick}\n >\n {label}\n </button>\n )}\n </span>\n );\n};\n\ntype AnnualGrossSalaryProps = JSFField & {\n currency: string;\n desiredCurrency: string;\n annual_gross_salary_conversion_properties?: {\n label?: string;\n description?: string;\n };\n};\n\nexport const AnnualGrossSalary = ({\n currency,\n desiredCurrency,\n description,\n ...props\n}: AnnualGrossSalaryProps) => {\n const [showConversion, setShowConversion] = useState(false);\n const { setValue, watch } = useFormContext();\n const annualGrossSalary = watch(props.name);\n\n const canShowConversion =\n currency && desiredCurrency && currency !== desiredCurrency;\n\n const { mutateAsync: convertCurrency } = useConvertCurrency();\n\n const convertCurrencyCallback = useCallback(\n async (\n value: string,\n sourceCurrency: string,\n targetCurrency: string,\n targetField: string,\n ) => {\n if (!value) return;\n\n try {\n const response = await convertCurrency({\n source_currency: sourceCurrency,\n target_currency: targetCurrency,\n amount: Number(value),\n });\n if (response.data?.data?.conversion_data?.target_amount) {\n const amount = response.data.data.conversion_data.target_amount;\n if (amount) {\n setValue(targetField, amount?.toString());\n }\n }\n } catch (error) {\n console.error('Error converting currency:', error);\n }\n },\n [convertCurrency, setValue],\n );\n\n const debouncedConvertCurrency = useDebounce(\n (value: string) =>\n convertCurrencyCallback(\n value,\n currency,\n desiredCurrency,\n 'annual_gross_salary_conversion',\n ),\n 500,\n );\n const debouncedConvertCurrencyReverse = useDebounce(\n (value: string) =>\n convertCurrencyCallback(value, desiredCurrency, currency, props.name),\n 500,\n );\n\n const handleAnnualGrossSalaryChange = (\n evt: React.ChangeEvent<HTMLInputElement>,\n ) => {\n if (showConversion) {\n debouncedConvertCurrency(evt.target.value);\n }\n };\n\n const handleConversionChange = (evt: React.ChangeEvent<HTMLInputElement>) => {\n debouncedConvertCurrencyReverse(evt.target.value);\n };\n\n const toggleConversion = (evt: React.MouseEvent<HTMLButtonElement>) => {\n evt.preventDefault();\n setShowConversion((prev) => !prev);\n\n if (!showConversion && annualGrossSalary) {\n debouncedConvertCurrency(annualGrossSalary);\n }\n };\n\n const extraDescription = canShowConversion ? (\n <DescriptionWithConversion\n currency={desiredCurrency}\n description={description}\n showConversion={showConversion}\n onClick={toggleConversion}\n />\n ) : (\n description\n );\n\n const { annual_gross_salary_conversion_properties: conversionField } = props;\n\n return (\n <>\n <TextField\n {...props}\n description={extraDescription}\n type=\"text\"\n inputMode=\"decimal\"\n pattern=\"^[0-9.]*$\"\n onChange={handleAnnualGrossSalaryChange}\n />\n {/** A problem on this field is that the label, description are fixed. */}\n {showConversion && (\n <TextField\n name=\"annual_gross_salary_conversion\"\n label={conversionField?.label || 'Conversion'}\n description={\n conversionField?.description ||\n 'Estimated amount. This is an estimation. We calculate conversions based on spot rates that are subject to fluctuation over time.'\n }\n type=\"text\"\n inputMode=\"decimal\"\n pattern=\"^[0-9.]*$\"\n onChange={handleConversionChange}\n />\n )}\n </>\n );\n};\n","import { useCallback, useEffect, useRef } from 'react';\nimport debounce from 'lodash/debounce';\n\nexport function useDebounce(\n callback: (value: string) => Promise<void>,\n delay: number,\n) {\n const callbackRef = useRef(callback);\n\n useEffect(() => {\n callbackRef.current = callback;\n }, [callback]);\n\n const debouncedFn = useRef(\n debounce((value: string) => {\n callbackRef.current(value);\n }, delay),\n ).current;\n\n return useCallback(\n (value: string) => {\n debouncedFn(value);\n },\n [debouncedFn],\n );\n}\n"],"mappings":"+KAAA,IAAAA,EAAAC,EAAA,CAAAC,GAAAC,IAAA,cAyBA,SAASC,GAASC,EAAO,CACvB,IAAIC,EAAO,OAAOD,EAClB,OAAOA,GAAS,OAASC,GAAQ,UAAYA,GAAQ,WACvD,CAHSC,EAAAH,GAAA,YAKTD,EAAO,QAAUC,KC9BjB,IAAAI,EAAAC,EAAA,CAAAC,GAAAC,IAAA,cACA,IAAIC,GAAa,OAAO,QAAU,UAAY,QAAU,OAAO,SAAW,QAAU,OAEpFD,EAAO,QAAUC,KCHjB,IAAAC,EAAAC,EAAA,CAAAC,GAAAC,IAAA,kBAAIC,GAAa,IAGbC,GAAW,OAAO,MAAQ,UAAY,MAAQ,KAAK,SAAW,QAAU,KAGxEC,GAAOF,IAAcC,IAAY,SAAS,aAAa,EAAE,EAE7DF,EAAO,QAAUG,KCRjB,IAAAC,EAAAC,EAAA,CAAAC,GAAAC,IAAA,kBAAIC,GAAO,IAkBPC,GAAMC,EAAA,UAAW,CACnB,OAAOF,GAAK,KAAK,IAAI,CACvB,EAFU,OAIVD,EAAO,QAAUE,KCtBjB,IAAAE,EAAAC,EAAA,CAAAC,GAAAC,IAAA,cACA,IAAIC,GAAe,KAUnB,SAASC,GAAgBC,EAAQ,CAG/B,QAFIC,EAAQD,EAAO,OAEZC,KAAWH,GAAa,KAAKE,EAAO,OAAOC,CAAK,CAAC,GAAG,CAC3D,OAAOA,CACT,CALSC,EAAAH,GAAA,mBAOTF,EAAO,QAAUE,KClBjB,IAAAI,EAAAC,EAAA,CAAAC,GAAAC,IAAA,kBAAI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BC,EACjB,OAAQ,OAAOF,CAAK,CACtB,CAAC,EACD,GAAII,EAAS,MAAM,MAAM,iBAAiB,cAAe,CACvD,IAAMC,EAASD,EAAS,KAAK,KAAK,gBAAgB,cAC9CC,GACFd,EAASY,EAAaE,GAAQ,SAAS,CAAC,CAE5C,CACF,OAASC,EAAO,CACd,QAAQ,MAAM,6BAA8BA,CAAK,CACnD,CACF,EACA,CAACV,EAAiBL,CAAQ,CAC5B,EAEMgB,EAA2BC,EAC9BR,GACCF,EACEE,EACApB,EACAO,EACA,gCACF,EACF,GACF,EACMsB,EAAkCD,EACrCR,GACCF,EAAwBE,EAAOb,EAAiBP,EAAUQ,EAAM,IAAI,EACtE,GACF,EAEMsB,EAAgCjC,EACpCkC,GACG,CACChC,GACF4B,EAAyBI,EAAI,OAAO,KAAK,CAE7C,EANsC,iCAQhCC,EAAyBnC,EAACkC,GAA6C,CAC3EF,EAAgCE,EAAI,OAAO,KAAK,CAClD,EAF+B,0BAazBE,EAAmBlB,EACvBrB,EAACE,GAAA,CACC,SAAUW,EACV,YAAaT,EACb,eAAgBC,EAChB,QAdqBF,EAACkC,GAA6C,CACrEA,EAAI,eAAe,EACnBtB,EAAmByB,GAAS,CAACA,CAAI,EAE7B,CAACnC,GAAkBe,GACrBa,EAAyBb,CAAiB,CAE9C,EAPyB,oBAevB,EAEAhB,EAGI,CAAE,0CAA2CqC,CAAgB,EAAI3B,EAEvE,OACEb,GAAAF,GAAA,CACE,UAAAC,EAAC0C,EAAA,CACE,GAAG5B,EACJ,YAAayB,EACb,KAAK,OACL,UAAU,UACV,QAAQ,YACR,SAAUH,EACZ,EAEC/B,GACCL,EAAC0C,EAAA,CACC,KAAK,iCACL,MAAOD,GAAiB,OAAS,aACjC,YACEA,GAAiB,aACjB,mIAEF,KAAK,OACL,UAAU,UACV,QAAQ,YACR,SAAUH,EACZ,GAEJ,CAEJ,EAxHiC","names":["require_isObject","__commonJSMin","exports","module","isObject","value","type","__name","require_freeGlobal","__commonJSMin","exports","module","freeGlobal","require_root","__commonJSMin","exports","module","freeGlobal","freeSelf","root","require_now","__commonJSMin","exports","module","root","now","__name","require_trimmedEndIndex","__commonJSMin","exports","module","reWhitespace","trimmedEndIndex","string","index","__name","require_baseTrim","__commonJSMin","exports","module","trimmedEndIndex","reTrimStart","baseTrim","string","__name","require_Symbol","__commonJSMin","exports","module","root","Symbol","require_getRawTag","__commonJSMin","exports","module","Symbol","objectProto","hasOwnProperty","nativeObjectToString","symToStringTag","getRawTag","value","isOwn","tag","unmasked","result","__name","require_objectToString","__commonJSMin","exports","module","objectProto","nativeObjectToString","objectToString","value","__name","require_baseGetTag","__commonJSMin","exports","module","Symbol","getRawTag","objectToString","nullTag","undefinedTag","symToStringTag","baseGetTag","value","__name","require_isObjectLike","__commonJSMin","exports","module","isObjectLike","value","__name","require_isSymbol","__commonJSMin","exports","module","baseGetTag","isObjectLike","symbolTag","isSymbol","value","__name","require_toNumber","__commonJSMin","exports","module","baseTrim","isObject","isSymbol","NAN","reIsBadHex","reIsBinary","reIsOctal","freeParseInt","toNumber","value","other","isBinary","__name","require_debounce","__commonJSMin","exports","module","isObject","now","toNumber","FUNC_ERROR_TEXT","nativeMax","nativeMin","debounce","func","wait","options","lastArgs","lastThis","maxWait","result","timerId","lastCallTime","lastInvokeTime","leading","maxing","trailing","invokeFunc","time","args","thisArg","__name","leadingEdge","timerExpired","remainingWait","timeSinceLastCall","timeSinceLastInvoke","timeWaiting","shouldInvoke","trailingEdge","cancel","flush","debounced","isInvoking","useState","useCallback","useFormContext","import_debounce","useCallback","useEffect","useRef","useDebounce","callback","delay","callbackRef","useRef","useEffect","debouncedFn","debounce","value","useCallback","__name","Fragment","jsx","jsxs","DescriptionWithConversion","__name","description","showConversion","currency","onClick","components","useFormFields","label","CustomButton","AnnualGrossSalary","desiredCurrency","props","setShowConversion","useState","setValue","watch","useFormContext","annualGrossSalary","canShowConversion","convertCurrency","useConvertCurrency","convertCurrencyCallback","useCallback","value","sourceCurrency","targetCurrency","targetField","response","amount","error","debouncedConvertCurrency","useDebounce","debouncedConvertCurrencyReverse","handleAnnualGrossSalaryChange","evt","handleConversionChange","extraDescription","prev","conversionField","TextField"]}
|
|
1
|
+
{"version":3,"sources":["../node_modules/lodash/isObject.js","../node_modules/lodash/_freeGlobal.js","../node_modules/lodash/_root.js","../node_modules/lodash/now.js","../node_modules/lodash/_trimmedEndIndex.js","../node_modules/lodash/_baseTrim.js","../node_modules/lodash/_Symbol.js","../node_modules/lodash/_getRawTag.js","../node_modules/lodash/_objectToString.js","../node_modules/lodash/_baseGetTag.js","../node_modules/lodash/isObjectLike.js","../node_modules/lodash/isSymbol.js","../node_modules/lodash/toNumber.js","../node_modules/lodash/debounce.js","../src/flows/Onboarding/AnnualGrossSalary.tsx","../src/common/hooks.ts"],"sourcesContent":["/**\n * Checks if `value` is the\n * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)\n * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is an object, else `false`.\n * @example\n *\n * _.isObject({});\n * // => true\n *\n * _.isObject([1, 2, 3]);\n * // => true\n *\n * _.isObject(_.noop);\n * // => true\n *\n * _.isObject(null);\n * // => false\n */\nfunction isObject(value) {\n var type = typeof value;\n return value != null && (type == 'object' || type == 'function');\n}\n\nmodule.exports = isObject;\n","/** Detect free variable `global` from Node.js. */\nvar freeGlobal = typeof global == 'object' && global && global.Object === Object && global;\n\nmodule.exports = freeGlobal;\n","var freeGlobal = require('./_freeGlobal');\n\n/** Detect free variable `self`. */\nvar freeSelf = typeof self == 'object' && self && self.Object === Object && self;\n\n/** Used as a reference to the global object. */\nvar root = freeGlobal || freeSelf || Function('return this')();\n\nmodule.exports = root;\n","var root = require('./_root');\n\n/**\n * Gets the timestamp of the number of milliseconds that have elapsed since\n * the Unix epoch (1 January 1970 00:00:00 UTC).\n *\n * @static\n * @memberOf _\n * @since 2.4.0\n * @category Date\n * @returns {number} Returns the timestamp.\n * @example\n *\n * _.defer(function(stamp) {\n * console.log(_.now() - stamp);\n * }, _.now());\n * // => Logs the number of milliseconds it took for the deferred invocation.\n */\nvar now = function() {\n return root.Date.now();\n};\n\nmodule.exports = now;\n","/** Used to match a single whitespace character. */\nvar reWhitespace = /\\s/;\n\n/**\n * Used by `_.trim` and `_.trimEnd` to get the index of the last non-whitespace\n * character of `string`.\n *\n * @private\n * @param {string} string The string to inspect.\n * @returns {number} Returns the index of the last non-whitespace character.\n */\nfunction trimmedEndIndex(string) {\n var index = string.length;\n\n while (index-- && reWhitespace.test(string.charAt(index))) {}\n return index;\n}\n\nmodule.exports = trimmedEndIndex;\n","var trimmedEndIndex = require('./_trimmedEndIndex');\n\n/** Used to match leading whitespace. */\nvar reTrimStart = /^\\s+/;\n\n/**\n * The base implementation of `_.trim`.\n *\n * @private\n * @param {string} string The string to trim.\n * @returns {string} Returns the trimmed string.\n */\nfunction baseTrim(string) {\n return string\n ? string.slice(0, trimmedEndIndex(string) + 1).replace(reTrimStart, '')\n : string;\n}\n\nmodule.exports = baseTrim;\n","var root = require('./_root');\n\n/** Built-in value references. */\nvar Symbol = root.Symbol;\n\nmodule.exports = Symbol;\n","var Symbol = require('./_Symbol');\n\n/** Used for built-in method references. */\nvar objectProto = Object.prototype;\n\n/** Used to check objects for own properties. */\nvar hasOwnProperty = objectProto.hasOwnProperty;\n\n/**\n * Used to resolve the\n * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)\n * of values.\n */\nvar nativeObjectToString = objectProto.toString;\n\n/** Built-in value references. */\nvar symToStringTag = Symbol ? Symbol.toStringTag : undefined;\n\n/**\n * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.\n *\n * @private\n * @param {*} value The value to query.\n * @returns {string} Returns the raw `toStringTag`.\n */\nfunction getRawTag(value) {\n var isOwn = hasOwnProperty.call(value, symToStringTag),\n tag = value[symToStringTag];\n\n try {\n value[symToStringTag] = undefined;\n var unmasked = true;\n } catch (e) {}\n\n var result = nativeObjectToString.call(value);\n if (unmasked) {\n if (isOwn) {\n value[symToStringTag] = tag;\n } else {\n delete value[symToStringTag];\n }\n }\n return result;\n}\n\nmodule.exports = getRawTag;\n","/** Used for built-in method references. */\nvar objectProto = Object.prototype;\n\n/**\n * Used to resolve the\n * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)\n * of values.\n */\nvar nativeObjectToString = objectProto.toString;\n\n/**\n * Converts `value` to a string using `Object.prototype.toString`.\n *\n * @private\n * @param {*} value The value to convert.\n * @returns {string} Returns the converted string.\n */\nfunction objectToString(value) {\n return nativeObjectToString.call(value);\n}\n\nmodule.exports = objectToString;\n","var Symbol = require('./_Symbol'),\n getRawTag = require('./_getRawTag'),\n objectToString = require('./_objectToString');\n\n/** `Object#toString` result references. */\nvar nullTag = '[object Null]',\n undefinedTag = '[object Undefined]';\n\n/** Built-in value references. */\nvar symToStringTag = Symbol ? Symbol.toStringTag : undefined;\n\n/**\n * The base implementation of `getTag` without fallbacks for buggy environments.\n *\n * @private\n * @param {*} value The value to query.\n * @returns {string} Returns the `toStringTag`.\n */\nfunction baseGetTag(value) {\n if (value == null) {\n return value === undefined ? undefinedTag : nullTag;\n }\n return (symToStringTag && symToStringTag in Object(value))\n ? getRawTag(value)\n : objectToString(value);\n}\n\nmodule.exports = baseGetTag;\n","/**\n * Checks if `value` is object-like. A value is object-like if it's not `null`\n * and has a `typeof` result of \"object\".\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is object-like, else `false`.\n * @example\n *\n * _.isObjectLike({});\n * // => true\n *\n * _.isObjectLike([1, 2, 3]);\n * // => true\n *\n * _.isObjectLike(_.noop);\n * // => false\n *\n * _.isObjectLike(null);\n * // => false\n */\nfunction isObjectLike(value) {\n return value != null && typeof value == 'object';\n}\n\nmodule.exports = isObjectLike;\n","var baseGetTag = require('./_baseGetTag'),\n isObjectLike = require('./isObjectLike');\n\n/** `Object#toString` result references. */\nvar symbolTag = '[object Symbol]';\n\n/**\n * Checks if `value` is classified as a `Symbol` primitive or object.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.\n * @example\n *\n * _.isSymbol(Symbol.iterator);\n * // => true\n *\n * _.isSymbol('abc');\n * // => false\n */\nfunction isSymbol(value) {\n return typeof value == 'symbol' ||\n (isObjectLike(value) && baseGetTag(value) == symbolTag);\n}\n\nmodule.exports = isSymbol;\n","var baseTrim = require('./_baseTrim'),\n isObject = require('./isObject'),\n isSymbol = require('./isSymbol');\n\n/** Used as references for various `Number` constants. */\nvar NAN = 0 / 0;\n\n/** Used to detect bad signed hexadecimal string values. */\nvar reIsBadHex = /^[-+]0x[0-9a-f]+$/i;\n\n/** Used to detect binary string values. */\nvar reIsBinary = /^0b[01]+$/i;\n\n/** Used to detect octal string values. */\nvar reIsOctal = /^0o[0-7]+$/i;\n\n/** Built-in method references without a dependency on `root`. */\nvar freeParseInt = parseInt;\n\n/**\n * Converts `value` to a number.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to process.\n * @returns {number} Returns the number.\n * @example\n *\n * _.toNumber(3.2);\n * // => 3.2\n *\n * _.toNumber(Number.MIN_VALUE);\n * // => 5e-324\n *\n * _.toNumber(Infinity);\n * // => Infinity\n *\n * _.toNumber('3.2');\n * // => 3.2\n */\nfunction toNumber(value) {\n if (typeof value == 'number') {\n return value;\n }\n if (isSymbol(value)) {\n return NAN;\n }\n if (isObject(value)) {\n var other = typeof value.valueOf == 'function' ? value.valueOf() : value;\n value = isObject(other) ? (other + '') : other;\n }\n if (typeof value != 'string') {\n return value === 0 ? value : +value;\n }\n value = baseTrim(value);\n var isBinary = reIsBinary.test(value);\n return (isBinary || reIsOctal.test(value))\n ? freeParseInt(value.slice(2), isBinary ? 2 : 8)\n : (reIsBadHex.test(value) ? NAN : +value);\n}\n\nmodule.exports = toNumber;\n","var isObject = require('./isObject'),\n now = require('./now'),\n toNumber = require('./toNumber');\n\n/** Error message constants. */\nvar FUNC_ERROR_TEXT = 'Expected a function';\n\n/* Built-in method references for those with the same name as other `lodash` methods. */\nvar nativeMax = Math.max,\n nativeMin = Math.min;\n\n/**\n * Creates a debounced function that delays invoking `func` until after `wait`\n * milliseconds have elapsed since the last time the debounced function was\n * invoked. The debounced function comes with a `cancel` method to cancel\n * delayed `func` invocations and a `flush` method to immediately invoke them.\n * Provide `options` to indicate whether `func` should be invoked on the\n * leading and/or trailing edge of the `wait` timeout. The `func` is invoked\n * with the last arguments provided to the debounced function. Subsequent\n * calls to the debounced function return the result of the last `func`\n * invocation.\n *\n * **Note:** If `leading` and `trailing` options are `true`, `func` is\n * invoked on the trailing edge of the timeout only if the debounced function\n * is invoked more than once during the `wait` timeout.\n *\n * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred\n * until to the next tick, similar to `setTimeout` with a timeout of `0`.\n *\n * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)\n * for details over the differences between `_.debounce` and `_.throttle`.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Function\n * @param {Function} func The function to debounce.\n * @param {number} [wait=0] The number of milliseconds to delay.\n * @param {Object} [options={}] The options object.\n * @param {boolean} [options.leading=false]\n * Specify invoking on the leading edge of the timeout.\n * @param {number} [options.maxWait]\n * The maximum time `func` is allowed to be delayed before it's invoked.\n * @param {boolean} [options.trailing=true]\n * Specify invoking on the trailing edge of the timeout.\n * @returns {Function} Returns the new debounced function.\n * @example\n *\n * // Avoid costly calculations while the window size is in flux.\n * jQuery(window).on('resize', _.debounce(calculateLayout, 150));\n *\n * // Invoke `sendMail` when clicked, debouncing subsequent calls.\n * jQuery(element).on('click', _.debounce(sendMail, 300, {\n * 'leading': true,\n * 'trailing': false\n * }));\n *\n * // Ensure `batchLog` is invoked once after 1 second of debounced calls.\n * var debounced = _.debounce(batchLog, 250, { 'maxWait': 1000 });\n * var source = new EventSource('/stream');\n * jQuery(source).on('message', debounced);\n *\n * // Cancel the trailing debounced invocation.\n * jQuery(window).on('popstate', debounced.cancel);\n */\nfunction debounce(func, wait, options) {\n var lastArgs,\n lastThis,\n maxWait,\n result,\n timerId,\n lastCallTime,\n lastInvokeTime = 0,\n leading = false,\n maxing = false,\n trailing = true;\n\n if (typeof func != 'function') {\n throw new TypeError(FUNC_ERROR_TEXT);\n }\n wait = toNumber(wait) || 0;\n if (isObject(options)) {\n leading = !!options.leading;\n maxing = 'maxWait' in options;\n maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait;\n trailing = 'trailing' in options ? !!options.trailing : trailing;\n }\n\n function invokeFunc(time) {\n var args = lastArgs,\n thisArg = lastThis;\n\n lastArgs = lastThis = undefined;\n lastInvokeTime = time;\n result = func.apply(thisArg, args);\n return result;\n }\n\n function leadingEdge(time) {\n // Reset any `maxWait` timer.\n lastInvokeTime = time;\n // Start the timer for the trailing edge.\n timerId = setTimeout(timerExpired, wait);\n // Invoke the leading edge.\n return leading ? invokeFunc(time) : result;\n }\n\n function remainingWait(time) {\n var timeSinceLastCall = time - lastCallTime,\n timeSinceLastInvoke = time - lastInvokeTime,\n timeWaiting = wait - timeSinceLastCall;\n\n return maxing\n ? nativeMin(timeWaiting, maxWait - timeSinceLastInvoke)\n : timeWaiting;\n }\n\n function shouldInvoke(time) {\n var timeSinceLastCall = time - lastCallTime,\n timeSinceLastInvoke = time - lastInvokeTime;\n\n // Either this is the first call, activity has stopped and we're at the\n // trailing edge, the system time has gone backwards and we're treating\n // it as the trailing edge, or we've hit the `maxWait` limit.\n return (lastCallTime === undefined || (timeSinceLastCall >= wait) ||\n (timeSinceLastCall < 0) || (maxing && timeSinceLastInvoke >= maxWait));\n }\n\n function timerExpired() {\n var time = now();\n if (shouldInvoke(time)) {\n return trailingEdge(time);\n }\n // Restart the timer.\n timerId = setTimeout(timerExpired, remainingWait(time));\n }\n\n function trailingEdge(time) {\n timerId = undefined;\n\n // Only invoke if we have `lastArgs` which means `func` has been\n // debounced at least once.\n if (trailing && lastArgs) {\n return invokeFunc(time);\n }\n lastArgs = lastThis = undefined;\n return result;\n }\n\n function cancel() {\n if (timerId !== undefined) {\n clearTimeout(timerId);\n }\n lastInvokeTime = 0;\n lastArgs = lastCallTime = lastThis = timerId = undefined;\n }\n\n function flush() {\n return timerId === undefined ? result : trailingEdge(now());\n }\n\n function debounced() {\n var time = now(),\n isInvoking = shouldInvoke(time);\n\n lastArgs = arguments;\n lastThis = this;\n lastCallTime = time;\n\n if (isInvoking) {\n if (timerId === undefined) {\n return leadingEdge(lastCallTime);\n }\n if (maxing) {\n // Handle invocations in a tight loop.\n clearTimeout(timerId);\n timerId = setTimeout(timerExpired, wait);\n return invokeFunc(lastCallTime);\n }\n }\n if (timerId === undefined) {\n timerId = setTimeout(timerExpired, wait);\n }\n return result;\n }\n debounced.cancel = cancel;\n debounced.flush = flush;\n return debounced;\n}\n\nmodule.exports = debounce;\n","import { ReactNode, useState, useCallback } from 'react';\nimport { useFormContext } from 'react-hook-form';\nimport { TextField } from '@/src/components/form/fields/TextField';\nimport { useConvertCurrency } from '@/src/flows/Onboarding/api';\nimport { JSFField } from '@/src/types/remoteFlows';\nimport { useFormFields } from '@/src/context';\nimport { useDebounce } from '@/src/common/hooks';\n\ntype DescriptionWithConversionProps = {\n description: ReactNode;\n showConversion: boolean;\n currency: string;\n onClick: (evt: React.MouseEvent<HTMLButtonElement>) => void;\n};\n\nconst DescriptionWithConversion = ({\n description,\n showConversion,\n currency,\n onClick,\n}: DescriptionWithConversionProps) => {\n const { components } = useFormFields();\n const label = showConversion\n ? `Hide ${currency} conversion`\n : `Show ${currency} conversion`;\n\n const CustomButton = components?.button;\n\n return (\n <span className=\"RemoteFlows-AnnualGrossSalary-description\">\n {description}{' '}\n {CustomButton ? (\n <CustomButton\n className=\"RemoteFlows-AnnualGrossSalary-button\"\n data-type=\"inline\"\n onClick={onClick}\n >\n {label}\n </CustomButton>\n ) : (\n <button\n className=\"RemoteFlows-AnnualGrossSalary-button\"\n onClick={onClick}\n >\n {label}\n </button>\n )}\n </span>\n );\n};\n\ntype AnnualGrossSalaryProps = JSFField & {\n currency: string;\n desiredCurrency: string;\n annual_gross_salary_conversion_properties?: {\n label?: string;\n description?: string;\n };\n};\n\nexport const AnnualGrossSalary = ({\n currency,\n desiredCurrency,\n description,\n ...props\n}: AnnualGrossSalaryProps) => {\n const [showConversion, setShowConversion] = useState(false);\n const { setValue, watch } = useFormContext();\n const annualGrossSalary = watch(props.name);\n\n const canShowConversion =\n currency && desiredCurrency && currency !== desiredCurrency;\n\n const { mutateAsync: convertCurrency } = useConvertCurrency();\n\n const convertCurrencyCallback = useCallback(\n async (\n value: string,\n sourceCurrency: string,\n targetCurrency: string,\n targetField: string,\n ) => {\n if (!value) return;\n\n try {\n const response = await convertCurrency({\n source_currency: sourceCurrency,\n target_currency: targetCurrency,\n amount: Number(value),\n });\n if (response.data?.data?.conversion_data?.target_amount) {\n const amount = response.data.data.conversion_data.target_amount;\n if (amount) {\n setValue(targetField, amount?.toString());\n }\n }\n } catch (error) {\n console.error('Error converting currency:', error);\n }\n },\n [convertCurrency, setValue],\n );\n\n const debouncedConvertCurrency = useDebounce(\n (value: string) =>\n convertCurrencyCallback(\n value,\n currency,\n desiredCurrency,\n 'annual_gross_salary_conversion',\n ),\n 500,\n );\n const debouncedConvertCurrencyReverse = useDebounce(\n (value: string) =>\n convertCurrencyCallback(value, desiredCurrency, currency, props.name),\n 500,\n );\n\n const handleAnnualGrossSalaryChange = (\n evt: React.ChangeEvent<HTMLInputElement>,\n ) => {\n if (showConversion) {\n debouncedConvertCurrency(evt.target.value);\n }\n };\n\n const handleConversionChange = (evt: React.ChangeEvent<HTMLInputElement>) => {\n debouncedConvertCurrencyReverse(evt.target.value);\n };\n\n const toggleConversion = (evt: React.MouseEvent<HTMLButtonElement>) => {\n evt.preventDefault();\n setShowConversion((prev) => !prev);\n\n if (!showConversion && annualGrossSalary) {\n debouncedConvertCurrency(annualGrossSalary);\n }\n };\n\n const extraDescription = canShowConversion ? (\n <DescriptionWithConversion\n currency={desiredCurrency}\n description={description}\n showConversion={showConversion}\n onClick={toggleConversion}\n />\n ) : (\n description\n );\n\n const { annual_gross_salary_conversion_properties: conversionField } = props;\n\n return (\n <>\n <TextField\n {...props}\n additionalProps={{ currency: currency }}\n description={extraDescription}\n type=\"text\"\n inputMode=\"decimal\"\n pattern=\"^[0-9.]*$\"\n onChange={handleAnnualGrossSalaryChange}\n />\n {/** A problem on this field is that the label, description are fixed. */}\n {showConversion && (\n <TextField\n additionalProps={{ currency: desiredCurrency }}\n name=\"annual_gross_salary_conversion\"\n label={conversionField?.label || 'Conversion'}\n description={\n conversionField?.description ||\n 'Estimated amount. This is an estimation. We calculate conversions based on spot rates that are subject to fluctuation over time.'\n }\n type=\"text\"\n inputMode=\"decimal\"\n pattern=\"^[0-9.]*$\"\n onChange={handleConversionChange}\n />\n )}\n </>\n );\n};\n","import { useCallback, useEffect, useRef } from 'react';\nimport debounce from 'lodash/debounce';\n\nexport function useDebounce(\n callback: (value: string) => Promise<void>,\n delay: number,\n) {\n const callbackRef = useRef(callback);\n\n useEffect(() => {\n callbackRef.current = callback;\n }, [callback]);\n\n const debouncedFn = useRef(\n debounce((value: string) => {\n callbackRef.current(value);\n }, delay),\n ).current;\n\n return useCallback(\n (value: string) => {\n debouncedFn(value);\n },\n [debouncedFn],\n );\n}\n"],"mappings":"+KAAA,IAAAA,EAAAC,EAAA,CAAAC,GAAAC,IAAA,cAyBA,SAASC,GAASC,EAAO,CACvB,IAAIC,EAAO,OAAOD,EAClB,OAAOA,GAAS,OAASC,GAAQ,UAAYA,GAAQ,WACvD,CAHSC,EAAAH,GAAA,YAKTD,EAAO,QAAUC,KC9BjB,IAAAI,EAAAC,EAAA,C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I,OAAO,KAAK,CAE7C,EANsC,iCAQhCC,EAAyBnC,EAACkC,GAA6C,CAC3EF,EAAgCE,EAAI,OAAO,KAAK,CAClD,EAF+B,0BAazBE,EAAmBlB,EACvBrB,EAACE,GAAA,CACC,SAAUW,EACV,YAAaT,EACb,eAAgBC,EAChB,QAdqBF,EAACkC,GAA6C,CACrEA,EAAI,eAAe,EACnBtB,EAAmByB,GAAS,CAACA,CAAI,EAE7B,CAACnC,GAAkBe,GACrBa,EAAyBb,CAAiB,CAE9C,EAPyB,oBAevB,EAEAhB,EAGI,CAAE,0CAA2CqC,CAAgB,EAAI3B,EAEvE,OACEb,GAAAF,GAAA,CACE,UAAAC,EAAC0C,EAAA,CACE,GAAG5B,EACJ,gBAAiB,CAAE,SAAUR,CAAS,EACtC,YAAaiC,EACb,KAAK,OACL,UAAU,UACV,QAAQ,YACR,SAAUH,EACZ,EAEC/B,GACCL,EAAC0C,EAAA,CACC,gBAAiB,CAAE,SAAU7B,CAAgB,EAC7C,KAAK,iCACL,MAAO4B,GAAiB,OAAS,aACjC,YACEA,GAAiB,aACjB,mIAEF,KAAK,OACL,UAAU,UACV,QAAQ,YACR,SAAUH,EACZ,GAEJ,CAEJ,EA1HiC","names":["require_isObject","__commonJSMin","exports","module","isObject","value","type","__name","require_freeGlobal","__commonJSMin","exports","module","freeGlobal","require_root","__commonJSMin","exports","module","freeGlobal","freeSelf","root","require_now","__commonJSMin","exports","module","root","now","__name","require_trimmedEndIndex","__commonJSMin","exports","module","reWhitespace","trimmedEndIndex","string","index","__name","require_baseTrim","__commonJSMin","exports","module","trimmedEndIndex","reTrimStart","baseTrim","string","__name","require_Symbol","__commonJSMin","exports","module","root","Symbol","require_getRawTag","__commonJSMin","exports","module","Symbol","objectProto","hasOwnProperty","nativeObjectToString","symToStringTag","getRawTag","value","isOwn","tag","unmasked","result","__name","require_objectToString","__commonJSMin","exports","module","objectProto","nativeObjectToString","objectToString","value","__name","require_baseGetTag","__commonJSMin","exports","module","Symbol","getRawTag","objectToString","nullTag","undefinedTag","symToStringTag","baseGetTag","value","__name","require_isObjectLike","__commonJSMin","exports","module","isObjectLike","value","__name","require_isSymbol","__commonJSMin","exports","module","baseGetTag","isObjectLike","symbolTag","isSymbol","value","__name","require_toNumber","__commonJSMin","exports","module","baseTrim","isObject","isSymbol","NAN","reIsBadHex","reIsBinary","reIsOctal","freeParseInt","toNumber","value","other","isBinary","__name","require_debounce","__commonJSMin","exports","module","isObject","now","toNumber","FUNC_ERROR_TEXT","nativeMax","nativeMin","debounce","func","wait","options","lastArgs","lastThis","maxWait","result","timerId","lastCallTime","lastInvokeTime","leading","maxing","trailing","invokeFunc","time","args","thisArg","__name","leadingEdge","timerExpired","remainingWait","timeSinceLastCall","timeSinceLastInvoke","timeWaiting","shouldInvoke","trailingEdge","cancel","flush","debounced","isInvoking","useState","useCallback","useFormContext","import_debounce","useCallback","useEffect","useRef","useDebounce","callback","delay","callbackRef","useRef","useEffect","debouncedFn","debounce","value","useCallback","__name","Fragment","jsx","jsxs","DescriptionWithConversion","__name","description","showConversion","currency","onClick","components","useFormFields","label","CustomButton","AnnualGrossSalary","desiredCurrency","props","setShowConversion","useState","setValue","watch","useFormContext","annualGrossSalary","canShowConversion","convertCurrency","useConvertCurrency","convertCurrencyCallback","useCallback","value","sourceCurrency","targetCurrency","targetField","response","amount","error","debouncedConvertCurrency","useDebounce","debouncedConvertCurrencyReverse","handleAnnualGrossSalaryChange","evt","handleConversionChange","extraDescription","prev","conversionField","TextField"]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{a as le,b as me,c as S,d as de}from"./chunk-4UBZTJMC.js";import{a as Ee}from"./chunk-CVTAWW6F.js";import{a as fe,b as ue,c as ye,f as pe,g as _e,h as Se,i as be,j as ge,l as Fe}from"./chunk-AN7L3GVL.js";import{a as w}from"./chunk-QW4JPW6J.js";import{a as ce}from"./chunk-PJBAQZ6G.js";import{c as _,d as T}from"./chunk-MH6KKP6K.js";import{a as r}from"./chunk-P37U34EQ.js";import{useEffect as xe,useMemo as l,useRef as Ge,useState as he}from"react";import We from"lodash.mergewith";import{jsx as Qe}from"react/jsx-runtime";var Ke={employment_basic_information:"basic_information",contract_details:"contract_details"},Ye={select_country:null,basic_information:"employment_basic_information",contract_details:"contract_details",benefits:null,review:null},ze=r(({isLoadingBasicInformationForm:m,isLoadingContractDetailsForm:R,isLoadingEmployment:N,isLoadingBenefitsOffersSchema:v,isLoadingBenefitOffers:a,isLoadingCompany:j,isLoadingCountries:u,employmentStatus:o,employmentId:J,currentStepName:i,basicInformationFields:P,contractDetailsFields:c})=>{let b=m||R||N||v||a||j||u,B=o&&de.includes(o),g=!!(J&&B&&i!=="review"),I=b||g,y=!!(g&&!b&&P.length>0&&c.length>0);return{isLoading:I,isNavigatingToReview:y,isEmploymentReadOnly:B}},"getLoadingStates"),st=r(({employmentId:m,companyId:R,countryCode:N,type:v,options:a,skipSteps:j})=>{let u=Ge({select_country:{},basic_information:{},contract_details:{},benefits:{}}),[o,J]=he(m),[i,P]=he(N||null),{data:c,isLoading:b,refetch:B}=fe(o);c?.country?.code&&i!==c.country.code&&P(c.country.code);let{data:g,isLoading:I}=ye(o),{data:y,isLoading:A,refetch:U}=ue(R),Oe=j?.includes("select_country")?me:le,{fieldValues:F,stepState:e,setFieldValues:Ve,previousStep:Ce,nextStep:Le,goToStep:D,setStepValues:H}=ce(Oe),{selectCountryForm:k,isLoading:x}=Fe({jsfModify:a?.jsfModify?.select_country,jsonSchemaVersion:a?.jsonSchemaVersion,queryOptions:{enabled:e.currentStep.name==="select_country"}}),G=Se(a),W=be(a),K=ge(a),{mutateAsync:Me}=w(G),{mutateAsync:Y}=w(W),{mutateAsync:Te}=w(K),Pe=Ye[e.currentStep.name]||"employment_basic_information",Be=Ke[Pe],Ie=c?.[Be]||{},z=r(({form:n,options:s={}})=>pe({countryCode:i,form:n,fieldValues:Object.keys(F).length>0?{...e.values?.[e.currentStep.name],...F}:Ie,options:{...s,queryOptions:{enabled:s.queryOptions?.enabled??!0}}}),"useJSONSchema"),ke=!!(i&&(e.currentStep.name==="basic_information"||m)),we=!!(i&&(e.currentStep.name==="contract_details"||m)),{data:d,isLoading:Q}=z({form:"employment_basic_information",options:{jsfModify:a?.jsfModify?.basic_information,queryOptions:{enabled:ke}}}),p=a?.jsfModify?.contract_details?.fields?.annual_gross_salary,q=p&&typeof p=="object"&&"presentation"in p?p.presentation:void 0,Re=l(()=>({fields:{annual_gross_salary:{...p,presentation:{annual_gross_salary_conversion_properties:{label:q?.annual_gross_salary_conversion_properties?.label,description:q?.annual_gross_salary_conversion_properties?.description},desiredCurrency:y?.desired_currency,Component:r(n=>Qe(Ee,{desiredCurrency:y?.desired_currency||"",...n}),"Component")}}}}),[y?.desired_currency,q,p]),{data:f,isLoading:X}=z({form:"contract_details",options:{jsfModify:{...a?.jsfModify?.contract_details,fields:{...a?.jsfModify?.contract_details?.fields,...Re.fields}},queryOptions:{enabled:we}}}),{data:E,isLoading:Z}=_e(o,F,a),$=l(()=>{if(e.currentStep.name==="benefits"){let n={...e.values?.[e.currentStep.name],...F};return We({},g,n)}return{}},[e.currentStep.name,g,e.values,F]),t=l(()=>({select_country:k?.fields||[],basic_information:d?.fields||[],contract_details:f?.fields||[],benefits:E?.fields||[],review:[]}),[k?.fields,d?.fields,f?.fields,E?.fields]),{country:{code:ee}={},basic_information:te={},contract_details:ne={},status:oe}=c||{},ae=e.currentStep.name,h=l(()=>T(t.select_country,{country:i||ee||""}),[t.select_country,i,ee]),O=l(()=>T(t.basic_information,te||{}),[t.basic_information,te]),V=l(()=>T(t.contract_details,ne||{}),[t.contract_details,ne]),C=l(()=>T(t.benefits,$),[t.benefits,$]),Ne=l(()=>({select_country:h,basic_information:O,contract_details:V,benefits:C}),[h,O,V,C]),{isLoading:ve,isNavigatingToReview:ie,isEmploymentReadOnly:je}=l(()=>ze({isLoadingBasicInformationForm:Q,isLoadingContractDetailsForm:X,isLoadingEmployment:b,isLoadingBenefitsOffersSchema:Z,isLoadingBenefitOffers:I,isLoadingCompany:A,isLoadingCountries:x,employmentId:m,employmentStatus:oe,basicInformationFields:t.basic_information,contractDetailsFields:t.contract_details,currentStepName:ae}),[Q,X,b,Z,I,A,x,m,oe,t.basic_information,t.contract_details,ae]);xe(()=>{ie&&(u.current={select_country:S(h,t.select_country),basic_information:S(O,t.basic_information),contract_details:S(V,t.contract_details),benefits:S(C,t.benefits)},H({select_country:h,basic_information:O,contract_details:V,benefits:C,review:{}}),D("review"))},[O,C,V,D,ie,h,H,t.basic_information,t.benefits,t.contract_details,t.select_country]);let se=r(n=>k&&e.currentStep.name==="select_country"?n:d&&e.currentStep.name==="basic_information"?_(n,d?.fields,{isPartialValidation:!0}):f&&e.currentStep.name==="contract_details"?_(n,f?.fields,{isPartialValidation:!0}):{},"parseFormValues");async function Je(n){let s=e.currentStep.name;s in u.current&&(u.current[s]=S(n,t[s]));let L=se(n);switch(U(),e.currentStep.name){case"select_country":return P(L.country),Promise.resolve({data:{countryCode:L.country}});case"basic_information":{let re=!o&&i,Ue=o&&i&&c?.country&&c?.country.code!==i;if(re||Ue){let He={basic_information:L,type:v,country_code:i};try{let M=await Me(He);return await U(),J(M.data?.data?.employment?.id),M}catch(M){throw console.error("Error creating onboarding:",M),M}}else if(o)return Y({employmentId:o,basic_information:L,pricing_plan_details:{frequency:"monthly"}});return}case"contract_details":return Y({employmentId:o,...{contract_details:L,pricing_plan_details:{frequency:"monthly"}}});case"benefits":return Te({employmentId:o,...n})}}r(Je,"onSubmit");function De(){Ce()}r(De,"back");function qe(){Le()}r(qe,"next");function Ae(n){D(n)}return r(Ae,"goTo"),{employmentId:o,creditRiskStatus:y?.default_legal_entity_credit_risk_status,stepState:e,fields:t[e.currentStep.name],isLoading:ve,isSubmitting:G.isPending||W.isPending||K.isPending,initialValues:Ne,handleValidation:r(n=>{if(e.currentStep.name==="select_country")return k.handleValidation(n);if(e.currentStep.name==="benefits"&&E){let s=_(n,E?.fields);return E?.handleValidation(s)}if(d&&e.currentStep.name==="basic_information"){let s=_(n,d?.fields);return d?.handleValidation(s)}if(f&&e.currentStep.name==="contract_details"){let s=_(n,f?.fields);return f?.handleValidation(s)}return null},"handleValidation"),checkFieldUpdates:Ve,parseFormValues:se,onSubmit:Je,back:De,next:qe,goTo:Ae,meta:{fields:u.current},refetchEmployment:B,employment:c,isEmploymentReadOnly:je}},"useOnboarding");export{st as a};
|
|
2
|
+
//# sourceMappingURL=chunk-EIWJKCKN.js.map
|