1import{j as e,L as J}from"./logger-KgGCinx1.js";import{m as c}from"./mycnc__loadShare__react__loadShare__-PAyoiw_s.js";import{m as ce}from"./mycnc__loadShare__react_mf_2_router__loadShare__-BQVaZBX4.js";import{a0 as Q,bz as le,au as X,r as ue,f as de,G as g,D as U,ab as pe,b as me,bU as ge,bV as fe,aG as q,aH as F,Z as ye,bY as he,dU as _e,eZ as xe,bE as De,m as Ce,B as Te,x as je}from"./useRouting-Dqp11Q-s.js";import{g as G}from"./get-D9TZbSFc.js";import{E as Se}from"./ErrorBoundary-DRdeyP5-.js";import{M as Y}from"./Modal-DjqOW1xk.js";import{T as H}from"./Typography-D-W-z5Q1.js";import{T as l}from"./Table-JSQHXNTs.js";import{E as be}from"./enumHelper-BV8V_ezu.js";import{m as Ee,b as Z,S as Ae}from"./ProfileReskin-DfXUmxO4.js";import{u as Ne}from"./useSnackbar-DniIwToJ.js";import{E as Pe}from"./fmsEnums-DBJtWmIu.js";import{u as Ie}from"./useMuiTheme-FYS5ZDPz.js";import"./_commonjsHelpers-DaWZu8wl.js";import"./mycnc__mf_v__runtimeInit__mf_v__-CPFIg_re.js";import"./mycnc__loadShare__react_mf_2_dom__loadShare__-Byf9slX8.js";import"./preload-helper-CkTZxt06.js";import"./ContentBox-BPLlvzE9.js";import"./Pagination-BugqXWiM.js";import"./index-BEIdKsB3.js";import"./valid-DeVcQFyE.js";import"./validateEmail-CnibqrCJ.js";import"./Layout-CuGUsDJS.js";import"./withAuthProtection-BhkOVgnT.js";import"./getImagePath-LH39WJcP.js";import"./useConfiguration-DQJ3-Fg4.js";import"./SpotlightDataTable-MTMQm_lR.js";import"./createNumberMask-K9oEwSPn.js";import"./index-CyDsmSCi.js";import"./deepMerge-BQgLu7NS.js";const Le="LoanoutWidget-module__loanoutWidget___wNB9x",Re="LoanoutWidget-module__ddWidget___ACG16",ke="LoanoutWidget-module__directDepositRedirect___YPjqo",ve="LoanoutWidget-module__directDepositTitle___bPcPb",we="LoanoutWidget-module__directDepositTitleIcon___V1AmE",L={loanoutWidget:Le,ddWidget:Re,directDepositRedirect:ke,directDepositTitle:ve,directDepositTitleIcon:we},Me="Priority-module__root___rc7li",Oe="Priority-module__short___stN-y",V={root:Me,short:Oe},Ue=({children:s,short:r=!1})=>e.jsx("span",{className:Q(V.root,r&&V.short),children:s}),We="AccountsTable-module__empty___DP3Vv",$e={empty:We},Be=({mappings:s,directDeposits:r,setPaperless:C})=>{const _=o=>`DirectDeposit-InfoPanel-${o}`,u=e.jsx(l.Head,{children:e.jsx(l.Row,{children:["Priority","Bank Name","Account Type","Routing Number","Account Number",r.length>1?"Split Amount":"Amount"].filter(Boolean).map(o=>e.jsx(l.Cell,{children:o},_(`TableHeader-${o}`)))})}),x=r.map((o,d)=>{o.isPaperless&&C(!0);const n=d===r.length-1,S=r.length,f=n?S===1?"Full Amount":"Remainder":o.flatAmount?`$${o.flatAmount.toFixed(2)}`:`${parseInt(o.splitPercentage,10)}%`;return e.jsxs(l.Row,{children:[e.jsx(l.Cell,{align:"center",children:e.jsx(Ue,{children:d+1})}),e.jsx(l.Cell,{children:o.bankName||""}),e.jsx(l.Cell,{children:be.valueToOptionLabel(s.bankAccountTypes,o.bankAccountType).replace(" Account","")}),e.jsx(l.Cell,{children:o.routingNumber}),e.jsx(l.Cell,{children:o.bankAccountNumber}),e.jsx(l.Cell,{children:f})]},_(`TableRow-${d}`))});return e.jsxs(l,{children:[u,e.jsx(l.Body,{children:(x||[]).length?x:e.jsx(l.Row,{className:$e.empty,children:e.jsx(l.Cell,{align:"center",colSpan:5,children:"No bank account added yet"})})})]})},qe=100,K=(s,r)=>{const{amountType:C,directDeposits:_,isCanada:u,paperless:x,delivery:o}=r,d=()=>{if(_?.length>1&&C==="%"){const p=h=>parseInt(h.splitPercentage,10)||0;return _.filter(h=>!h.primary).reduce((h,b)=>h+p(b),0)}return 0},{primary:n,__typename:S,forCorps:f,...y}=s,N=C==="%";let i=0;return N?i=n?qe-d():parseInt(s.splitPercentage,10):i=n?100:0,{...y,currencyType:s.currencyType||"US",bankAccountType:parseInt(s.bankAccountType,10),isPaperLess:u?!1:x,isDeliveryRequested:u?!0:o,flatAmount:C==="$"&&!n?parseInt(s.flatAmount,10):0,splitPercentage:i,forCorps:f}},Fe="CopySetup-module__right___Q141-",Ge="CopySetup-module__button___Xy0Iv",Ye="CopySetup-module__existing___uSYgY",R={right:Fe,button:Ge,existing:Ye},He=({loanout:s,modify:r,state:C})=>{const _=Ee(),{country:u}=Z(),x=Ne(),o=le(),[d,n]=c.useState(!1),[S,f]=c.useState(!1),[y,N]=c.useState(null),[i,p]=c.useState(null),[P,h]=c.useState([]),[b,w]=c.useState([]),k=J("Loanouts-CopyDD"),I=u==="CAN",v=JSON.parse(o.getItem("activeLoanOutDD")||"{}"),a=X("GetMyProfiles",{fetchPolicy:"no-cache",scopes:"payroll_employee:edit",request:t=>({country:t}),response:t=>({user:t.data.getCurrentUser,mappings:t.data.getProfileMappingOptions})}),W=ue("updateFullEmployeeProfile",{scopes:"payroll_employee:edit",request:t=>({input:{countryFlag:u,...t}}),response:t=>t.data.updateFullEmployeeProfile}),ee=()=>(n(!0),a(u).then(t=>{N(t.user),h(t.mappings)}).catch(t=>k.error(t)).then(()=>n(!1)));c.useEffect(()=>{ee()},[u]),c.useEffect(()=>{if(y?.profiles){const{caps:t,cnc:T}=Pe.dataSource,j=A=>M=>M.dataSource===A;let D=y.profiles.find(j(T));D||(D=y.profiles.find(j(t))),p(D||G(y,"profiles[0]",null))}},[y]),c.useEffect(()=>{if(!i)return;const t=G(i,"directDeposits",[])||[];w(t);const T=t.filter(A=>(A.forCorps||"").toLowerCase()!=="c"),j=t.filter(A=>(A.forCorps||"").toLowerCase()==="c"),D=de(new Date).diff(new Date(v.reminderDate),"day");T.length>0&&j.length===0&&(!v.reminderDate||D>7)?f(!0):j.length===0&&x({type:"info",title:"Don't forget to update your loan-out direct deposit!",message:"Review your info to ensure you'll get paid to the proper account.",duration:1e4,inline:!1,style:{marginTop:120}})},[i]);const E=b.filter(t=>(t.forCorps||"").toLowerCase()!=="c").map((t,T)=>({...t,primary:T===(b||[]).length-1})),{isDeliveryRequested:te=!1,isPaperLess:oe=!0}=E[0]||{},$=(E[0]||{}).flatAmount?"$":"%",se=(t=null)=>{n(!0);const T=E.find(m=>m.primary),j=E.filter(m=>!m.primary),D=$==="%"?1:2,{basicInfo:A}=i||{},M=A?.dbCode,B={amountType:$,directDeposits:E,isCanada:I,paperless:oe,delivery:te},O=[];if(j.length>
10&&j.forEach((m,ie)=>{const ae={...K(m,B),id:null,splitType:D,sequence:ie+1,forCorps:"C"};O.push(ae)}),T){const m={...K(T,B),id:null,splitType:D,sequence:E.length,forCorps:"C"};O.push(m)}try{W({plaid:!0,...t,basicInfo:{dbCode:M},directDeposits:O||null,isDirectDepositActive:!0,ddCopy:!0}).then(()=>{k.info("Direct deposit setup copied successfully"),r({reload:!0}),f(!1)}).catch(m=>{n(!1),console.error(m)})}catch(m){n(!1),console.error(m)}},re=()=>{o.setItem("activeLoanOutDD",JSON.stringify({reminderDate:new Date,activeLoanOut:s.taxId})),f(!1)},ne=()=>{_(se)()};return e.jsx(Y,{id:"CopyModal",open:S,className:R.existing,children:e.jsx(Y.Content,{children:e.jsxs(g,{container:!0,spacing:3,children:[e.jsx(g,{item:!0,xs:12,children:e.jsxs(g,{container:!0,spacing:3,children:[e.jsx(g,{item:!0,xs:12,children:e.jsx(H,{id:"CopyModal-Title",h4:!0,noMargin:!0,children:"Use existing direct deposit setup?"})}),e.jsx(g,{item:!0,xs:12,children:e.jsxs(H,{short:!0,body2:!0,noMargin:!0,children:["Do you want to apply the direct deposit setup used in your"," ",I?"T4":"W-2"," employee profile? Youâll still be able to make modifications to this setup."]})})]})}),e.jsx(g,{item:!0,xs:12,children:e.jsx(Se,{alert:!0,children:e.jsx(Be,{mappings:P,directDeposits:E,setPaperless:()=>{}})})}),e.jsxs(g,{item:!0,xs:12,className:R.right,children:[e.jsx(U,{tertiary:!0,onClick:re,disabled:d,className:R.button,children:"Iâll set up direct deposit later"}),e.jsx(U,{id:"CopyModal-NoCreateNewButton",secondary:!0,onClick:()=>f(!1),disabled:d,className:R.button,children:"No, create new"}),e.jsx(U,{id:"CopyModal-YesUseExistingButton",onClick:ne,loading:d,className:R.button,children:"Yes, use existing"})]})]})})})},z={C:"C Corp",S:"S Corp",L:"LLC Single Ownership",K:"LLC Partnership",F:"Foreign"},Ve=s=>z[s]?z[s]:s||"",bt=({offer:s=!1})=>{const{t:r}=pe(),C=ce.useNavigate(),{root:_}=me(),u=ge(),{actions:x}=fe(),{country:o}=Z(),d=J("Loanouts"),[n,S]=c.useState(null),f=q(F.OKTA_RE_AUTHENTICATION_AUT),y=q(F.RESKIN_LOANOUTS_UPDATED),N=f&&!1,[i,p]=Ie({loading:!1,saving:!1,reload:!0}),{isFederated:P}=ye(),{onDirtyChange:h,confirmNavigation:b}=c.useContext(Ae),w=X("getLoanout",{fetchPolicy:"network-only",scopes:"payroll_employee:edit",request:(a="US")=>({country:a}),response:a=>a.data.getLoanout||null}),k=async()=>{try{p({loading:!0});const a=await w(o);S(a?{...a,type:Ve(a.type)}:null),p({loading:!1})}catch(a){d.error(a),p({loading:!1})}};c.useEffect(()=>{k()},[o]),c.useEffect(()=>{if(i.reload){const a=setTimeout(()=>{p({reload:!1})},1e3);return()=>clearTimeout(a)}},[i.reload,p]);const I=c.useCallback(async a=>(await x.getTokenWithScopes({name:"mycnc",scopes:a})).accessToken,[x]),v=c.useMemo(()=>({serverUrl:`${he()}/graphql`,getToken:I,offer:null,country:o,skipReAuthAUT:N,onDirtyChange:h,confirmNavigation:b,isFederated:P,reskinUpdated:y}),[I,o,N,h,b,P,y]);return e.jsxs(e.Fragment,{children:[e.jsxs(_e,{style:{padding:0,margin:0,width:"100%"},children:[e.jsx("div",{className:L.loanoutWidget,children:e.jsx(g,{container:!0,spacing:2,style:{alignItems:"center",justifyContent:"center"},children:e.jsx(g,{item:!0,xs:12,md:10,lg:8,children:e.jsx(xe,{config:v})})})}),e.jsx("div",{className:L.ddWidget,children:!s&&!i.loading&&!i.reload&&n?.isValid&&e.jsx(g,{container:!0,spacing:2,style:{alignItems:"center",justifyContent:"center"},children:e.jsx(g,{item:!0,xs:12,md:10,lg:8,style:{paddingBottom:40},children:e.jsx(De,{id:"LoanoutWidget-DirectDepositRedirect",className:"spotlight_container",titleText:e.jsxs("h2",{className:Q("spotlight_heading-xs",L.directDepositTitle),children:[e.jsx("span",{className:L.directDepositTitleIcon,children:e.jsx(je,{iconName:"bank"})}),r("DIRECT_DEPOSIT")]}),children:e.jsxs("div",{className:L.directDepositRedirect,children:[e.jsx(Ce,{iconName:"sparkles",tagText:r("DIRECT_DEPOSIT_REDIRECT_TAG"),colorScheme:"attention"}),e.jsx("h4",{className:"spotlight_heading-xxs",children:r("DIRECT_DEPOSIT_REDIRECT_TITLE")}),e.jsx("p",{className:"spotlight_body-xs",children:r("DIRECT_DEPOSIT_REDIRECT_MESSAGE")}),e.jsx(Te,{id:"DirectDepositRedirect-CTA",onClick:()=>{u("direct_deposit_redirect_loanout_clicked",{source:"loanout_page",workflow:"direct_deposit"}),C(`${_}direct-deposit`)},endAdornment:"arrow-up-right-from-square",size:"xs",children:r("DIRECT_DEPOSIT_REDIRECT_BUTTON")})]})})})})})]}),!s&&!i.loading&&n?.isValid&&e.jsx(He,{loanout:n,modify:p,state:i})]})};export{bt as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.