UNPKG

@accounter/client

Version:
1 lines 112 kB
import{s as e}from"./dist-C51EwTaa.js";import{a as t,i as n,o as r}from"./utils-DdVdMk8X.js";import{Ci as i,Cn as a,Io as o,Ji as s,Jn as c,Lo as l,Na as u,Pa as d,Pn as f,Rn as p,Wa as m,Yi as h,Za as g,_t as _,bi as v,bn as y,ct as b,en as x,gi as S,gr as ee,gt as te,ht as C,lt as ne,mt as re,ot as ie,r as w,st as ae,t as T,v as oe,vn as se,wi as ce,xn as le,xr as ue}from"./error-handling-Dpfd9svJ.js";import{S as de,a as fe,m as pe,r as E,s as me,t as he,y as ge}from"./routes-DUvpW9-n.js";import{_t as _e,a as ve,c as ye,d as be,dt as D,f as xe,i as Se,l as Ce,m as we,n as Te,o as Ee,p as De,r as Oe,s as O,t as ke,u as Ae,ut as k}from"./select-CrsvQyhZ.js";import{r as je,t as Me}from"./charges-table-CNFGsVad.js";import{n as Ne,r as Pe}from"./similar-transactions-modal-DD7YfdjJ.js";import{t as Fe}from"./modify-contract-dialog-Ek2tQK5a.js";import{t as Ie}from"./building-2-BpbnxFOU.js";import{t as Le}from"./circle-check-DmnOCjqW.js";import{t as Re}from"./save-iLb32tUV.js";import{t as A}from"./button-Dzp2INW0.js";import{i as ze,n as Be,r as Ve,t as He}from"./accordion-D0VCW409.js";import{a as Ue,c as We,i as Ge,l as Ke,n as qe,o as Je,r as Ye,s as Xe,t as Ze}from"./alert-dialog-f2YmJQwd.js";import{A as Qe,B as j,C as $e,D as M,E as et,F as N,H as tt,I as nt,J as rt,K as it,L as P,Lt as at,M as ot,N as F,O as st,P as ct,R as I,S as lt,T as ut,U as dt,W as ft,b as pt,h as mt,j as ht,k as L,kt as gt,v as _t,z as R}from"./table--bF0wbxq.js";import{t as vt}from"./subMonths-DGtu7gB6.js";import{$ as yt,A as bt,B as xt,Ci as St,Cr as Ct,D as z,E as wt,Fr as B,I as Tt,Ir as V,It as H,Kr as Et,Lr as Dt,Nr as U,O as Ot,Pr as W,Q as kt,Qr as At,Rr as G,Rt as jt,Wr as Mt,Xr as Nt,Zr as Pt,_t as K,ai as Ft,cn as It,ct as Lt,di as Rt,ei as zt,gt as Bt,ht as Vt,ii as Ht,jt as Ut,k as q,kt as Wt,mi as Gt,mr as Kt,qr as qt,si as Jt,ti as Yt,ui as Xt,vr as Zt,w as Qt,wr as $t,wt as en,xi as tn,xr as nn,zr as J,zt as rn}from"./index-CL8-JoMZ.js";import{t as an}from"./business-extended-info-BGuAmkTk.js";import{t as on}from"./business-header-CYBXKl9H.js";import{t as sn}from"./transactions-table-BD4JxC5K.js";import{A as cn,B as ln,Bt as un,C as dn,Dt as fn,E as pn,Et as mn,F as hn,Ft as gn,G as _n,Ht as vn,J as yn,K as bn,Lt as xn,M as Sn,Mt as Cn,N as wn,O as Tn,Ot as En,Pt as Dn,Q as On,Rt as kn,S as An,St as jn,T as Mn,Tt as Nn,U as Pn,Vt as Fn,W as In,Z as Ln,_ as Rn,a as zn,at as Bn,b as Vn,bt as Hn,c as Un,ct as Wn,d as Gn,dt as Kn,f as qn,ft as Jn,g as Yn,h as Xn,ht as Zn,it as Qn,j as $n,k as er,kt as tr,l as nr,lt as rr,m as ir,n as ar,o as or,ot as sr,p as cr,pt as lr,q as ur,s as dr,st as fr,t as pr,u as mr,ut as hr,v as gr,vt as _r,w as vr,x as yr,xt as br,y as xr,z as Y,zt as Sr}from"./download-csv-BwXjzRkV.js";import{t as Cr}from"./spinner-CIpm0zlo.js";import{n as wr,t as Tr}from"./use-issue-monthly-documents-dWFCMZVs.js";var Er=_e(`chart-line`,[[`path`,{d:`M3 3v16a2 2 0 0 0 2 2h16`,key:`c24i48`}],[`path`,{d:`m19 9-5 5-4-4-3 3`,key:`2osh9i`}]]),Dr=_e(`circle-slash`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`line`,{x1:`9`,x2:`15`,y1:`15`,y2:`9`,key:`1dfufj`}]]),Or=_e(`dollar-sign`,[[`line`,{x1:`12`,x2:`12`,y1:`2`,y2:`22`,key:`7eqyqh`}],[`path`,{d:`M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6`,key:`1b0p4s`}]]),kr=_e(`file-check`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`m9 15 2 2 4-4`,key:`1grp1n`}]]),Ar=_e(`fullscreen`,[[`path`,{d:`M3 7V5a2 2 0 0 1 2-2h2`,key:`aa7l1z`}],[`path`,{d:`M17 3h2a2 2 0 0 1 2 2v2`,key:`4qcy5o`}],[`path`,{d:`M21 17v2a2 2 0 0 1-2 2h-2`,key:`6vwrx8`}],[`path`,{d:`M7 21H5a2 2 0 0 1-2-2v-2`,key:`ioqczr`}],[`rect`,{width:`10`,height:`8`,x:`7`,y:`8`,rx:`1`,key:`vys8me`}]]),jr=_e(`notebook`,[[`path`,{d:`M2 6h4`,key:`aawbzj`}],[`path`,{d:`M2 10h4`,key:`l0bgd4`}],[`path`,{d:`M2 14h4`,key:`1gsvsf`}],[`path`,{d:`M2 18h4`,key:`1bu2t1`}],[`rect`,{width:`16`,height:`20`,x:`4`,y:`2`,rx:`2`,key:`1nb95v`}],[`path`,{d:`M16 2v20`,key:`rotuqe`}]]),Mr=_e(`plug`,[[`path`,{d:`M12 22v-5`,key:`1ega77`}],[`path`,{d:`M15 8V2`,key:`18g5xt`}],[`path`,{d:`M17 8a1 1 0 0 1 1 1v4a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V9a1 1 0 0 1 1-1z`,key:`1xoxul`}],[`path`,{d:`M9 8V2`,key:`14iosj`}]]),X=e(r(),1),Nr=()=>{let[{data:e,fetching:t,error:n},r]=l({query:i});return{data:e?.providerCredentials,fetching:t,error:n,refetch:()=>r({requestPolicy:`network-only`})}},Pr=`delete-provider-credentials`,Fr=()=>{let[{fetching:e},t]=o(c);return{fetching:e,deleteCredentials:(0,X.useCallback)(async e=>{let n=`Failed to disconnect provider`;w.loading(`Disconnecting provider`,{id:Pr});try{let r=T(await t(e),n,Pr,`deleteProviderCredentials`);if(r)return w.success(`Provider disconnected`,{id:Pr}),r.deleteProviderCredentials}catch(e){console.error(`${n}: ${e}`),w.error(`Error`,{id:Pr,description:n,duration:1e5,closeButton:!0})}},[t])}},Ir=`set-deel-credentials`,Lr=()=>{let[{fetching:e},t]=o(s);return{fetching:e,setCredentials:(0,X.useCallback)(async e=>{let n=`Failed to save Deel credentials`;w.loading(`Saving Deel credentials`,{id:Ir});try{let r=T(await t(e),n,Ir,`setDeelCredentials`);if(r)return w.success(`Deel connected`,{id:Ir}),r.setDeelCredentials}catch(e){console.error(`${n}: ${e}`),w.error(`Error`,{id:Ir,description:n,duration:1e5,closeButton:!0})}},[t])}},Z=n(),Rr=M({apiToken:L().min(1,`Required`)});function zr({status:e,onSuccess:t}){let[n,r]=(0,X.useState)(!1),{fetching:i,setCredentials:a}=Lr(),{fetching:o,deleteCredentials:s}=Fr(),c=dt({resolver:mt(Rr),defaultValues:{apiToken:``}});async function l(e){await a(e)&&(r(!1),c.reset(),t())}async function u(){await s({provider:ce.Deel})&&t()}return(0,Z.jsxs)(W,{children:[(0,Z.jsxs)(G,{children:[(0,Z.jsx)(J,{children:`Deel`}),(0,Z.jsx)(V,{children:`Payment processing and payroll integration`})]}),(0,Z.jsx)(B,{children:e?(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Z.jsx)(F,{className:`w-fit bg-green-600 text-white hover:bg-green-600`,children:`Connected`}),(0,Z.jsxs)(`p`,{className:`text-sm text-gray-500`,children:[`Since `,new Date(e.configuredAt).toLocaleDateString(`en-US`)]})]}):(0,Z.jsx)(`p`,{className:`text-sm text-gray-500`,children:`Not connected`})}),(0,Z.jsx)(Dt,{children:e?(0,Z.jsxs)(Ze,{children:[(0,Z.jsx)(Ke,{asChild:!0,children:(0,Z.jsx)(A,{variant:`outline`,disabled:o,children:`Disconnect`})}),(0,Z.jsxs)(Ge,{children:[(0,Z.jsxs)(Xe,{children:[(0,Z.jsx)(We,{children:`Disconnect Deel?`}),(0,Z.jsx)(Ue,{children:`Are you sure you want to disconnect Deel? You can reconnect at any time.`})]}),(0,Z.jsxs)(Je,{children:[(0,Z.jsx)(Ye,{children:`Cancel`}),(0,Z.jsx)(qe,{onClick:u,disabled:o,children:`Disconnect`})]})]})]}):(0,Z.jsxs)(ye,{open:n,onOpenChange:e=>{r(e),e||c.reset()},children:[(0,Z.jsx)(we,{asChild:!0,children:(0,Z.jsx)(A,{children:`Connect`})}),(0,Z.jsxs)(Ce,{children:[(0,Z.jsxs)(xe,{children:[(0,Z.jsx)(De,{children:`Connect Deel`}),(0,Z.jsx)(Ae,{children:`Enter your Deel API token to connect your account.`})]}),(0,Z.jsx)(ct,{...c,children:(0,Z.jsxs)(`form`,{onSubmit:c.handleSubmit(l),className:`space-y-4`,children:[(0,Z.jsx)(P,{control:c.control,name:`apiToken`,render:({field:e})=>(0,Z.jsxs)(I,{children:[(0,Z.jsx)(R,{children:`API Token`}),(0,Z.jsx)(N,{children:(0,Z.jsx)(O,{type:`password`,...e})}),(0,Z.jsx)(j,{})]})}),(0,Z.jsx)(be,{children:(0,Z.jsx)(A,{type:`submit`,disabled:i,children:i?`Saving…`:`Save`})})]})})]})]})})]})}var Br=`set-green-invoice-credentials`,Vr=()=>{let[{fetching:e},t]=o(h);return{fetching:e,setCredentials:(0,X.useCallback)(async e=>{let n=`Failed to save Green Invoice credentials`;w.loading(`Saving Green Invoice credentials`,{id:Br});try{let r=T(await t(e),n,Br,`setGreenInvoiceCredentials`);if(r)return w.success(`Green Invoice connected`,{id:Br}),r.setGreenInvoiceCredentials}catch(e){console.error(`${n}: ${e}`),w.error(`Error`,{id:Br,description:n,duration:1e5,closeButton:!0})}},[t])}},Hr=M({id:L().min(1,`Required`),secret:L().min(1,`Required`)});function Ur({status:e,onSuccess:t}){let[n,r]=(0,X.useState)(!1),{fetching:i,setCredentials:a}=Vr(),{fetching:o,deleteCredentials:s}=Fr(),c=dt({resolver:mt(Hr),defaultValues:{id:``,secret:``}});async function l(e){await a(e)&&(r(!1),c.reset(),t())}async function u(){await s({provider:ce.GreenInvoice})&&t()}return(0,Z.jsxs)(W,{children:[(0,Z.jsxs)(G,{children:[(0,Z.jsx)(J,{children:`Green Invoice`}),(0,Z.jsx)(V,{children:`Automated invoice creation and document sync`})]}),(0,Z.jsx)(B,{children:e?(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Z.jsx)(F,{className:`w-fit bg-green-600 text-white hover:bg-green-600`,children:`Connected`}),(0,Z.jsxs)(`p`,{className:`text-sm text-gray-500`,children:[`Since `,new Date(e.configuredAt).toLocaleDateString(`en-US`)]})]}):(0,Z.jsx)(`p`,{className:`text-sm text-gray-500`,children:`Not connected`})}),(0,Z.jsx)(Dt,{children:e?(0,Z.jsxs)(Ze,{children:[(0,Z.jsx)(Ke,{asChild:!0,children:(0,Z.jsx)(A,{variant:`outline`,disabled:o,children:`Disconnect`})}),(0,Z.jsxs)(Ge,{children:[(0,Z.jsxs)(Xe,{children:[(0,Z.jsx)(We,{children:`Disconnect Green Invoice?`}),(0,Z.jsx)(Ue,{children:`Are you sure you want to disconnect Green Invoice? You can reconnect at any time.`})]}),(0,Z.jsxs)(Je,{children:[(0,Z.jsx)(Ye,{children:`Cancel`}),(0,Z.jsx)(qe,{onClick:u,disabled:o,children:`Disconnect`})]})]})]}):(0,Z.jsxs)(ye,{open:n,onOpenChange:e=>{r(e),e||c.reset()},children:[(0,Z.jsx)(we,{asChild:!0,children:(0,Z.jsx)(A,{children:`Connect`})}),(0,Z.jsxs)(Ce,{children:[(0,Z.jsxs)(xe,{children:[(0,Z.jsx)(De,{children:`Connect Green Invoice`}),(0,Z.jsx)(Ae,{children:`Enter your Green Invoice API credentials to connect your account.`})]}),(0,Z.jsx)(ct,{...c,children:(0,Z.jsxs)(`form`,{onSubmit:c.handleSubmit(l),className:`space-y-4`,children:[(0,Z.jsx)(P,{control:c.control,name:`id`,render:({field:e})=>(0,Z.jsxs)(I,{children:[(0,Z.jsx)(R,{children:`API ID`}),(0,Z.jsx)(N,{children:(0,Z.jsx)(O,{type:`text`,...e})}),(0,Z.jsx)(j,{})]})}),(0,Z.jsx)(P,{control:c.control,name:`secret`,render:({field:e})=>(0,Z.jsxs)(I,{children:[(0,Z.jsx)(R,{children:`API Secret`}),(0,Z.jsx)(N,{children:(0,Z.jsx)(O,{type:`password`,...e})}),(0,Z.jsx)(j,{})]})}),(0,Z.jsx)(be,{children:(0,Z.jsx)(A,{type:`submit`,disabled:i,children:i?`Saving…`:`Save`})})]})})]})]})})]})}function Wr(){let{data:e,fetching:t,refetch:n}=Nr();if(t)return(0,Z.jsx)(`div`,{className:`flex justify-center p-8`,children:(0,Z.jsx)(Cr,{className:`h-10 w-10`})});let r=e?.find(e=>e.provider===ce.GreenInvoice),i=e?.find(e=>e.provider===ce.Deel);return(0,Z.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,Z.jsx)(Ur,{status:r,onSuccess:n}),(0,Z.jsx)(zr,{status:i,onSuccess:n})]})}var Gr=`updateAdminBusiness`,Kr=()=>{let[{fetching:e},t]=o(u);return{fetching:e,updateAdminBusiness:(0,X.useCallback)(async e=>{let n=`Error updating admin business ID [${e.adminBusinessId}]`,r=`${Gr}-${e.adminBusinessId}`;w.loading(`Updating admin business`,{id:r});try{let i=T(await t(e),n,r,`updateAdminBusiness`);if(i)return w.success(`Success`,{id:r,description:`Admin Business Updated`}),i.updateAdminBusiness}catch(e){console.error(`${n}: ${e}`),w.error(`Error`,{id:r,description:n,duration:1e5,closeButton:!0})}},[t])}},qr=M({year:et().min(2e3).max(2100),id:L().min(1,{message:`ID is required`})}),Jr=M({registrationDate:L().min(1,{message:`Business Registration Start Date is required`}),withholdingTaxAnnualIds:pt(qr),withholdingTaxCompanyId:L().min(1,{message:`Withholding Tax Company ID is required`}),socialSecurityEmployerIds:pt(qr),socialSecurityDeductionsId:L().min(1,{message:`Social Security Deductions ID is required`}),taxAdvancesAnnualIds:pt(qr),taxAdvancesRates:pt(M({date:ot(),rate:et().min(0,{message:`Rate must be at least 0`}).max(100,{message:`Rate must be at most 100`})}))}),Yr={WITHHOLDING_TAX:`https://secapp.taxes.gov.il/NikPay/StartPage.aspx#/Home`,TAX_ADVANCES:`https://secapp.taxes.gov.il/gmftashmh/main/entrance`,SOCIAL_SECURITY:`https://b2b.btl.gov.il/BTL.ILG.Payments/ChovDochMaasikInfo.aspx`,VAT:`https://secapp.taxes.gov.il/emdvhmfrt/wLogOnMenu.aspx`},Xr=({href:e,children:t})=>(0,Z.jsxs)(`h3`,{className:`flex flex-row gap-2 text-sm font-semibold text-foreground md:col-span-2`,children:[(0,Z.jsx)(`a`,{href:e,target:`_blank`,rel:`noreferrer`,onClick:e=>e.stopPropagation(),className:`inline-flex items-center font-semibold`,children:(0,Z.jsx)(Jt,{size:12})}),(0,Z.jsx)(`span`,{children:t})]});function Zr(e){return!e||e.__typename!==`LtdFinancialEntity`||!e.adminInfo?{}:{registrationDate:e.adminInfo.registrationDate,withholdingTaxAnnualIds:e.adminInfo.withholdingTaxAnnualIds.sort((e,t)=>t.year-e.year),withholdingTaxCompanyId:e.adminInfo.withholdingTaxCompanyId??void 0,socialSecurityEmployerIds:e.adminInfo.socialSecurityEmployerIds.sort((e,t)=>t.year-e.year),socialSecurityDeductionsId:e.adminInfo.socialSecurityDeductionsId??void 0,taxAdvancesAnnualIds:e.adminInfo.taxAdvancesAnnualIds.sort((e,t)=>t.year-e.year),taxAdvancesRates:e.adminInfo.taxAdvancesRates?.map(e=>({date:e.date,rate:e.rate*100}))}}function Qr(e){return{registrationDate:e.registrationDate?gt(new Date(e.registrationDate)):void 0,withholdingTaxAnnualIds:e.withholdingTaxAnnualIds,withholdingTaxCompanyId:e.withholdingTaxCompanyId,socialSecurityEmployerIds:e.socialSecurityEmployerIds,taxAdvancesRates:e.taxAdvancesRates?.map(e=>({date:e.date,rate:e.rate/100})),taxAdvancesAnnualIds:e.taxAdvancesAnnualIds}}function $r({data:e,refetchBusiness:t}){let n=ft(ie,e),[r,i]=(0,X.useState)(Zr(n)),{updateAdminBusiness:a,fetching:o}=Kr(),s=dt({resolver:mt(Jr),defaultValues:r}),c=async e=>{if(!n)return;let r=fe(e,s.formState.dirtyFields);if(!r)return;let i=Qr(r);await a({adminBusinessId:n.id,fields:i}),t?.()};(0,X.useEffect)(()=>{if(n){let e=Zr(n);i(e),s.reset(e)}},[n,s]);let{fields:l,append:u,remove:d}=tt({control:s.control,name:`taxAdvancesAnnualIds`}),{fields:f,append:p,remove:m}=tt({control:s.control,name:`withholdingTaxAnnualIds`}),{fields:h,append:g,remove:_}=tt({control:s.control,name:`socialSecurityEmployerIds`}),v={withholdingTaxAnnualIds:{append:p,remove:m},taxAdvancesAnnualIds:{append:u,remove:d},socialSecurityEmployerIds:{append:g,remove:_}},y=e=>{v[e].append({year:new Date().getFullYear(),id:``})},b=(e,t)=>{v[e].remove(t)},{fields:x,append:S,remove:ee}=tt({control:s.control,name:`taxAdvancesRates`}),te=()=>{S({date:at(new Date,`yyyy-MM-dd`),rate:0})},C=e=>{ee(e)};return(0,Z.jsxs)(W,{children:[(0,Z.jsxs)(G,{children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(Pt,{className:`h-5 w-5 text-primary`}),(0,Z.jsx)(J,{children:`Admin Business Configuration`})]}),(0,Z.jsx)(V,{children:`Tax and registration information for the business operating this application`})]}),(0,Z.jsx)(ct,{...s,children:(0,Z.jsxs)(`form`,{onSubmit:s.handleSubmit(c),className:`space-y-6`,children:[(0,Z.jsx)(B,{children:(0,Z.jsxs)(`div`,{className:`grid gap-6 md:grid-cols-2`,children:[(0,Z.jsx)(Xr,{href:Yr.VAT,children:`VAT`}),(0,Z.jsx)(K,{className:`md:col-span-2`}),(0,Z.jsx)(Xr,{href:Yr.TAX_ADVANCES,children:`Tax Advances`}),(0,Z.jsx)(K,{className:`md:col-span-2`}),(0,Z.jsx)(Xr,{href:Yr.WITHHOLDING_TAX,children:`Withholding Tax`}),(0,Z.jsx)(P,{control:s.control,name:`withholdingTaxCompanyId`,render:({field:e,fieldState:t})=>(0,Z.jsxs)(I,{children:[(0,Z.jsx)(R,{children:`Company Tax ID`}),(0,Z.jsx)(N,{children:(0,Z.jsx)(O,{placeholder:`Enter company ID`,...e,className:E(t)})}),(0,Z.jsx)(j,{})]})}),(0,Z.jsxs)(`div`,{className:`space-y-4`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Z.jsx)(Ee,{children:`Annual IDs`}),(0,Z.jsx)(A,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>y(`withholdingTaxAnnualIds`),children:(0,Z.jsx)(D,{className:`size-4`})})]}),(0,Z.jsx)(`div`,{className:`space-y-3`,children:f.map((e,t)=>(0,Z.jsxs)(`div`,{className:`flex gap-2 items-start`,children:[(0,Z.jsxs)(`div`,{className:`flex-1 grid grid-cols-2 gap-2`,children:[(0,Z.jsx)(O,{placeholder:`Year`,type:`number`,...s.register(`withholdingTaxAnnualIds.${t}.year`,{valueAsNumber:!0})}),(0,Z.jsx)(O,{placeholder:`ID`,...s.register(`withholdingTaxAnnualIds.${t}.id`)})]}),(0,Z.jsx)(A,{type:`button`,variant:`ghost`,size:`icon`,onClick:()=>b(`withholdingTaxAnnualIds`,t),children:(0,Z.jsx)(k,{className:`size-4`})})]},e.id))})]}),(0,Z.jsx)(K,{className:`md:col-span-2`}),(0,Z.jsx)(Xr,{href:Yr.TAX_ADVANCES,children:`Tax Advances`}),(0,Z.jsxs)(`div`,{className:`space-y-4`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Z.jsx)(Ee,{children:`Annual IDs`}),(0,Z.jsx)(A,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>y(`taxAdvancesAnnualIds`),children:(0,Z.jsx)(D,{className:`size-4`})})]}),(0,Z.jsx)(`div`,{className:`space-y-3`,children:l.map((e,t)=>(0,Z.jsxs)(`div`,{className:`flex gap-2 items-start`,children:[(0,Z.jsxs)(`div`,{className:`flex-1 grid grid-cols-2 gap-2`,children:[(0,Z.jsx)(O,{placeholder:`Year`,type:`number`,...s.register(`taxAdvancesAnnualIds.${t}.year`,{valueAsNumber:!0})}),(0,Z.jsx)(O,{placeholder:`ID`,...s.register(`taxAdvancesAnnualIds.${t}.id`)})]}),(0,Z.jsx)(A,{type:`button`,variant:`ghost`,size:`icon`,onClick:()=>b(`taxAdvancesAnnualIds`,t),children:(0,Z.jsx)(k,{className:`size-4`})})]},e.id))})]}),(0,Z.jsxs)(`div`,{className:`space-y-4`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Z.jsx)(Ee,{children:`Rates (%)`}),(0,Z.jsx)(A,{type:`button`,variant:`outline`,size:`sm`,onClick:te,children:(0,Z.jsx)(D,{className:`size-4`})})]}),(0,Z.jsx)(`div`,{className:`space-y-3`,children:x.map((e,t)=>(0,Z.jsxs)(`div`,{className:`flex gap-2 items-start`,children:[(0,Z.jsxs)(`div`,{className:`flex-1 grid grid-cols-2 gap-2`,children:[(0,Z.jsx)(O,{placeholder:`Date`,type:`date`,...s.register(`taxAdvancesRates.${t}.date`)}),(0,Z.jsx)(O,{placeholder:`Rate`,...s.register(`taxAdvancesRates.${t}.rate`,{valueAsNumber:!0})})]}),(0,Z.jsx)(A,{type:`button`,variant:`ghost`,size:`icon`,onClick:()=>C(t),children:(0,Z.jsx)(k,{className:`size-4`})})]},e.id))})]}),(0,Z.jsx)(K,{className:`md:col-span-2`}),(0,Z.jsx)(Xr,{href:Yr.SOCIAL_SECURITY,children:`Social Security`}),(0,Z.jsx)(P,{control:s.control,name:`socialSecurityDeductionsId`,render:({field:e,fieldState:t})=>(0,Z.jsxs)(I,{children:[(0,Z.jsx)(R,{children:`Deductions ID`}),(0,Z.jsx)(N,{children:(0,Z.jsx)(O,{placeholder:`Enter deductions ID`,...e,className:E(t)})}),(0,Z.jsx)(j,{})]})}),(0,Z.jsxs)(`div`,{className:`space-y-4`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Z.jsx)(Ee,{children:`Annual Employer IDs`}),(0,Z.jsx)(A,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>y(`socialSecurityEmployerIds`),children:(0,Z.jsx)(D,{className:`size-4`})})]}),(0,Z.jsx)(`div`,{className:`space-y-3`,children:h.map((e,t)=>(0,Z.jsxs)(`div`,{className:`flex gap-2 items-start`,children:[(0,Z.jsxs)(`div`,{className:`flex-1 grid grid-cols-2 gap-2`,children:[(0,Z.jsx)(O,{placeholder:`Year`,type:`number`,...s.register(`socialSecurityEmployerIds.${t}.year`,{valueAsNumber:!0})}),(0,Z.jsx)(O,{placeholder:`ID`,...s.register(`socialSecurityEmployerIds.${t}.id`)})]}),(0,Z.jsx)(A,{type:`button`,variant:`ghost`,size:`icon`,onClick:()=>b(`socialSecurityEmployerIds`,t),children:(0,Z.jsx)(k,{className:`size-4`})})]},e.id))})]}),(0,Z.jsx)(K,{className:`md:col-span-2`}),(0,Z.jsx)(P,{control:s.control,name:`registrationDate`,render:({field:e,fieldState:t})=>(0,Z.jsxs)(I,{children:[(0,Z.jsx)(R,{children:`Business Registration Start Date`}),(0,Z.jsx)(N,{children:(0,Z.jsx)(O,{type:`date`,...e,className:E(t)})}),(0,Z.jsx)(j,{})]})})]})}),(0,Z.jsx)(Dt,{className:`flex justify-end border-t mt-4 pt-6`,children:(0,Z.jsxs)(A,{type:`submit`,disabled:o||Object.keys(s.formState.dirtyFields).length===0||!s.formState.isValid,children:[(0,Z.jsx)(Re,{className:`h-4 w-4`}),`Save Changes`]})})]})})]})}function ei({account:e,handleOpenModal:t}){return(0,Z.jsxs)(W,{children:[(0,Z.jsx)(G,{children:(0,Z.jsxs)(`div`,{className:`flex items-start justify-between`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Z.jsx)(`div`,{className:`p-2 rounded-lg bg-primary/10 text-primary`,children:Ne(e.type)}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsxs)(J,{className:`text-lg`,children:[e.name,e.name===e.number?``:` (${e.number})`]}),(0,Z.jsxs)(V,{className:`flex items-center gap-2 mt-1`,children:[(0,Z.jsx)(F,{variant:`outline`,children:Pe(e.type)}),!e.isBusiness&&(0,Z.jsx)(F,{variant:`secondary`,children:`Private`})]})]})]}),(0,Z.jsx)(`div`,{className:`flex gap-1`,children:(0,Z.jsx)(A,{variant:`ghost`,size:`sm`,onClick:()=>t(e),"aria-label":`Edit account ${e.name}`,children:(0,Z.jsx)(Nt,{className:`h-4 w-4`,"aria-hidden":`true`})})})]})}),(0,Z.jsxs)(B,{className:`space-y-4`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`h4`,{className:`text-sm font-medium mb-2`,children:`Currencies & Tax Categories`}),(0,Z.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:e.currencies?.map(e=>(0,Z.jsx)(me,{to:he.TAX_CATEGORIES,target:`_blank`,rel:`noreferrer`,onClick:e=>e.stopPropagation(),children:(0,Z.jsxs)(F,{variant:`secondary`,className:`text-xs`,children:[e.currency,` → `,e.taxCategory.name]})},e.currency))})]}),e.type===ue.BankAccount&&(0,Z.jsxs)(`div`,{className:`border-t pt-4`,children:[(0,Z.jsx)(`h4`,{className:`text-sm font-medium mb-3`,children:`Bank Details`}),(0,Z.jsxs)(`div`,{className:`grid grid-cols-2 md:grid-cols-3 lg:grid-cols-4 gap-3 text-sm`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:`Bank Number:`}),(0,Z.jsx)(`p`,{className:`font-medium`,children:e.bankNumber})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:`Branch Number:`}),(0,Z.jsx)(`p`,{className:`font-medium`,children:e.branchNumber})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:`Extended Bank Number:`}),(0,Z.jsx)(`p`,{className:`font-medium`,children:e.extendedBankNumber})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:`IBAN:`}),(0,Z.jsx)(`p`,{className:`font-medium`,children:e.iban})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:`Swift Code:`}),(0,Z.jsx)(`p`,{className:`font-medium`,children:e.swiftCode})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:`Party Preferred Indication:`}),(0,Z.jsx)(`p`,{className:`font-medium`,children:e.partyPreferredIndication})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:`Party Account Involvement:`}),(0,Z.jsx)(`p`,{className:`font-medium`,children:e.partyAccountInvolvementCode})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:`Account Deal Date:`}),(0,Z.jsx)(`p`,{className:`font-medium`,children:e.accountDealDate})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:`Account Update Date:`}),(0,Z.jsx)(`p`,{className:`font-medium`,children:e.accountUpdateDate})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:`Meteg Dora Net:`}),(0,Z.jsx)(`p`,{className:`font-medium`,children:e.metegDoarNet})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:`Kod Harshaot Peilut:`}),(0,Z.jsx)(`p`,{className:`font-medium`,children:e.kodHarshaatPeilut})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:`Closing Reason Code:`}),(0,Z.jsx)(`p`,{className:`font-medium`,children:e.accountClosingReasonCode})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:`Agreement Opening Date:`}),(0,Z.jsx)(`p`,{className:`font-medium`,children:e.accountAgreementOpeningDate})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:`Branch Type Code:`}),(0,Z.jsx)(`p`,{className:`font-medium`,children:e.branchTypeCode})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:`Mymail Entitlement:`}),(0,Z.jsx)(`p`,{className:`font-medium`,children:e.mymailEntitlementSwitch})]}),(0,Z.jsxs)(`div`,{className:`col-span-2`,children:[(0,Z.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:`Service Authorization:`}),(0,Z.jsx)(`p`,{className:`font-medium`,children:e.serviceAuthorizationDesc})]}),(0,Z.jsxs)(`div`,{className:`col-span-2`,children:[(0,Z.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:`Product Label:`}),(0,Z.jsx)(`p`,{className:`font-medium`,children:e.productLabel})]})]})]})]})]})}var ti=`createFinancialAccount`,ni=()=>{let[{fetching:e},t]=o(f);return{creating:e,createFinancialAccount:(0,X.useCallback)(async e=>{let n=`Error creating new account "${e.input.name}"`,r=`${ti}-${e.input.name}`;w.loading(`Creating account`,{id:r});try{T(await t(e),n,r)&&w.success(`Success`,{id:r,description:`Financial Account ${e.input.name} was successfully created`})}catch(e){console.error(`${n}: ${e}`),w.error(`Error`,{id:r,description:n,duration:1e5,closeButton:!0})}},[t])}},ri=`updateFinancialAccount`,ii=()=>{let[{fetching:e},t]=o(g);return{updating:e,updateFinancialAccount:(0,X.useCallback)(async e=>{let n=`Error updating financial account ID [${e.financialAccountId}]`,r=`${ri}-${e.financialAccountId}`;w.loading(`Updating financial account`,{id:r});try{let i=T(await t(e),n,r,`updateFinancialAccount`);if(i)return w.success(`Success`,{id:r,description:`Financial account updated`}),i.updateFinancialAccount}catch(e){console.error(`${n}: ${e}`),w.error(`Error`,{id:r,description:n,duration:1e5,closeButton:!0})}},[t])}},ai=M({currency:_t(Object.values(p),`Currency is required`),taxCategoryId:ht(`Tax category ID is required`)}),Q=st(e=>{if(e===``||e==null)return;let t=typeof e==`string`?parseInt(e,10):e;return Number.isNaN(t)?void 0:t},et().int().optional()),oi=M({name:L().min(1,`Name is required`),number:L().min(1,`Account number is required`),isBusiness:lt().default(!1).optional(),type:_t(Object.values(ue),`Account type is required`),currencies:pt(ai),bankNumber:Q,branchNumber:Q,iban:st(e=>e===``?void 0:e,L().optional()),swiftCode:st(e=>e===``?void 0:e,L().optional()),extendedBankNumber:Q,partyPreferredIndication:Q,partyAccountInvolvementCode:Q,accountDealDate:Q,accountUpdateDate:Q,metegDoarNet:Q,kodHarshaatPeilut:Q,accountClosingReasonCode:Q,accountAgreementOpeningDate:Q,serviceAuthorizationDesc:L().optional(),branchTypeCode:Q,mymailEntitlementSwitch:Q,productLabel:L().optional()});function si(e){return{name:e.name,number:e.number,isBusiness:e.isBusiness,type:e.type,currencies:e.currencies?.map(e=>({currency:e.currency,taxCategoryId:e.taxCategory.id}))??[],bankNumber:e.bankNumber,branchNumber:e.branchNumber,iban:e.iban,swiftCode:e.swiftCode,extendedBankNumber:e.extendedBankNumber,partyPreferredIndication:e.partyPreferredIndication,partyAccountInvolvementCode:e.partyAccountInvolvementCode,accountDealDate:e.accountDealDate,accountUpdateDate:e.accountUpdateDate,metegDoarNet:e.metegDoarNet,kodHarshaatPeilut:e.kodHarshaatPeilut,accountClosingReasonCode:e.accountClosingReasonCode,accountAgreementOpeningDate:e.accountAgreementOpeningDate,serviceAuthorizationDesc:e.serviceAuthorizationDesc,branchTypeCode:e.branchTypeCode,mymailEntitlementSwitch:e.mymailEntitlementSwitch,productLabel:e.productLabel}}var ci=(0,X.forwardRef)(function({ownerId:e,onDone:t},n){let[r,i]=(0,X.useState)(!1),[a,o]=(0,X.useState)(null),{createFinancialAccount:s,creating:c}=ni(),{updateFinancialAccount:l,updating:u}=ii(),{selectableTaxCategories:d,fetching:f}=jt(),m=dt({resolver:mt(oi),defaultValues:{name:``,number:``,isBusiness:!1,type:ue.BankAccount,currencies:[],bankNumber:void 0,branchNumber:void 0,iban:void 0,swiftCode:void 0,extendedBankNumber:void 0,partyPreferredIndication:void 0,partyAccountInvolvementCode:void 0,accountDealDate:void 0,accountUpdateDate:void 0,metegDoarNet:void 0,kodHarshaatPeilut:void 0,accountClosingReasonCode:void 0,accountAgreementOpeningDate:void 0,serviceAuthorizationDesc:void 0,branchTypeCode:void 0,mymailEntitlementSwitch:void 0,productLabel:void 0},mode:`onBlur`}),{control:h,handleSubmit:g,watch:_,reset:y}=m,b=e=>{e?(o(e),y(si(e))):(o(null),y()),i(!0)};(0,X.useImperativeHandle)(n,()=>({open:b}));let x=tt({control:h,name:`currencies`}),S=()=>{i(!1),o(null),y()},ee=async n=>{console.log(`Submitting form with values:`,n);try{let r=n.isBusiness?v.Business:v.Private,i=n.type===ue.BankAccount&&n.bankNumber!==void 0&&n.branchNumber!==void 0?{bankNumber:n.bankNumber,branchNumber:n.branchNumber,...n.iban!==void 0&&{iban:n.iban},...n.swiftCode!==void 0&&{swiftCode:n.swiftCode},...n.extendedBankNumber!==void 0&&{extendedBankNumber:n.extendedBankNumber},...n.partyPreferredIndication!==void 0&&{partyPreferredIndication:n.partyPreferredIndication},...n.partyAccountInvolvementCode!==void 0&&{partyAccountInvolvementCode:n.partyAccountInvolvementCode},...n.accountDealDate!==void 0&&{accountDealDate:n.accountDealDate},...n.accountUpdateDate!==void 0&&{accountUpdateDate:n.accountUpdateDate},...n.metegDoarNet!==void 0&&{metegDoarNet:n.metegDoarNet},...n.kodHarshaatPeilut!==void 0&&{kodHarshaatPeilut:n.kodHarshaatPeilut},...n.accountClosingReasonCode!==void 0&&{accountClosingReasonCode:n.accountClosingReasonCode},...n.accountAgreementOpeningDate!==void 0&&{accountAgreementOpeningDate:n.accountAgreementOpeningDate},...n.serviceAuthorizationDesc!==void 0&&{serviceAuthorizationDesc:n.serviceAuthorizationDesc},...n.branchTypeCode!==void 0&&{branchTypeCode:n.branchTypeCode},...n.mymailEntitlementSwitch!==void 0&&{mymailEntitlementSwitch:n.mymailEntitlementSwitch},...n.productLabel!==void 0&&{productLabel:n.productLabel}}:void 0;a?await l({financialAccountId:a.id,fields:{name:n.name,number:n.number,type:n.type,privateOrBusiness:r,bankAccountDetails:i,currencies:n.currencies}}):await s({input:{name:n.name,number:n.number,ownerId:e,type:n.type,privateOrBusiness:r,bankAccountDetails:i}}),S(),t?.()}catch{}},te=()=>{x.append({currency:p.Usd,taxCategoryId:``})},C=e=>{x.remove(e)};return(0,Z.jsx)(ye,{open:r,onOpenChange:i,children:(0,Z.jsxs)(Ce,{className:`max-w-4xl max-h-[90vh] overflow-y-auto`,children:[(0,Z.jsxs)(xe,{children:[(0,Z.jsx)(De,{children:a?`Edit Account`:`New Account`}),(0,Z.jsx)(Ae,{children:a?`Update account details and settings`:`Add a new financial account`})]}),(0,Z.jsx)(ct,{...m,children:(0,Z.jsxs)(`form`,{onSubmit:g(ee),className:`space-y-6`,children:[(0,Z.jsxs)(`div`,{className:`space-y-4`,children:[(0,Z.jsx)(`h3`,{className:`text-sm font-semibold`,children:`Basic Information`}),(0,Z.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[(0,Z.jsx)(P,{control:h,name:`name`,render:({field:e})=>(0,Z.jsxs)(I,{className:`space-y-2`,children:[(0,Z.jsx)(R,{children:`Name *`}),(0,Z.jsx)(N,{children:(0,Z.jsx)(O,{...e})}),(0,Z.jsx)(j,{})]})}),(0,Z.jsx)(P,{control:h,name:`number`,render:({field:e})=>(0,Z.jsxs)(I,{className:`space-y-2`,children:[(0,Z.jsx)(R,{children:`Account Number *`}),(0,Z.jsx)(N,{children:(0,Z.jsx)(O,{...e})}),(0,Z.jsx)(j,{})]})}),(0,Z.jsx)(P,{control:h,name:`type`,render:({field:e})=>(0,Z.jsxs)(I,{className:`space-y-2`,children:[(0,Z.jsx)(R,{children:`Account Type *`}),(0,Z.jsxs)(ke,{value:e.value,onValueChange:e.onChange,children:[(0,Z.jsx)(Se,{id:`type`,children:(0,Z.jsx)(ve,{})}),(0,Z.jsx)(Te,{children:Object.values(ue).map(e=>(0,Z.jsx)(Oe,{value:e,children:Pe(e)},e))})]}),(0,Z.jsx)(j,{})]})}),(0,Z.jsx)(P,{control:h,name:`isBusiness`,render:({field:e})=>(0,Z.jsxs)(I,{className:`flex items-center space-x-2`,children:[(0,Z.jsx)(N,{children:(0,Z.jsx)(H,{id:`isBusiness`,checked:e.value,onCheckedChange:e.onChange})}),(0,Z.jsx)(R,{children:`Business Account`})]})})]})]}),(0,Z.jsxs)(`div`,{className:`space-y-4`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Z.jsx)(`h3`,{className:`text-sm font-semibold`,children:`Currencies & Tax Categories`}),(0,Z.jsxs)(A,{type:`button`,variant:`outline`,size:`sm`,onClick:te,"aria-label":`Add currency row`,children:[(0,Z.jsx)(D,{className:`h-4 w-4 mr-2`,"aria-hidden":`true`}),`Add Currency`]})]}),(0,Z.jsx)(`div`,{className:`space-y-3`,children:x.fields.map((e,t)=>(0,Z.jsxs)(`div`,{className:`flex gap-2 items-start`,children:[(0,Z.jsxs)(`div`,{className:`flex-1 grid grid-cols-2 gap-2`,children:[(0,Z.jsx)(P,{control:h,name:`currencies.${t}.currency`,render:({field:e})=>(0,Z.jsxs)(I,{className:`space-y-2`,children:[(0,Z.jsxs)(ke,{value:e.value,onValueChange:e.onChange,children:[(0,Z.jsx)(Se,{id:`currencies.${t}.currency`,children:(0,Z.jsx)(ve,{})}),(0,Z.jsx)(Te,{children:Object.entries(p).map(([e,t])=>(0,Z.jsx)(Oe,{value:t,children:t},e))})]}),(0,Z.jsx)(j,{})]})}),(0,Z.jsx)(P,{control:m.control,name:`currencies.${t}.taxCategoryId`,render:({field:e})=>(0,Z.jsxs)(I,{children:[(0,Z.jsx)(N,{children:(0,Z.jsx)(en,{data:d,disabled:f,value:e.value,onChange:e.onChange,placeholder:`Scroll to see all options`,formPart:!0})}),(0,Z.jsx)(j,{})]})})]}),(0,Z.jsx)(A,{type:`button`,variant:`ghost`,size:`icon`,onClick:()=>C(t),"aria-label":`Remove currency ${_(`currencies.${t}.currency`)||``}`,children:(0,Z.jsx)(k,{className:`h-4 w-4`,"aria-hidden":`true`})})]},e.id))})]}),_(`type`)===ue.BankAccount&&(0,Z.jsxs)(`div`,{className:`space-y-4 border-t pt-4`,children:[(0,Z.jsx)(`h3`,{className:`text-sm font-semibold`,children:`Bank-Specific Details`}),(0,Z.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4`,children:[(0,Z.jsx)(P,{control:h,name:`bankNumber`,render:({field:e})=>(0,Z.jsxs)(I,{className:`space-y-2`,children:[(0,Z.jsx)(R,{children:`Bank Number`}),(0,Z.jsx)(N,{children:(0,Z.jsx)(O,{inputMode:`numeric`,value:e.value??``,onChange:e.onChange})}),(0,Z.jsx)(j,{})]})}),(0,Z.jsx)(P,{control:h,name:`branchNumber`,render:({field:e})=>(0,Z.jsxs)(I,{className:`space-y-2`,children:[(0,Z.jsx)(R,{children:`Branch Number`}),(0,Z.jsx)(N,{children:(0,Z.jsx)(O,{inputMode:`numeric`,value:e.value??``,onChange:e.onChange})}),(0,Z.jsx)(j,{})]})}),(0,Z.jsx)(P,{control:h,name:`iban`,render:({field:e})=>(0,Z.jsxs)(I,{className:`space-y-2`,children:[(0,Z.jsx)(R,{children:`IBAN`}),(0,Z.jsx)(N,{children:(0,Z.jsx)(O,{value:e.value??``,onChange:e.onChange})}),(0,Z.jsx)(j,{})]})}),(0,Z.jsx)(P,{control:h,name:`swiftCode`,render:({field:e})=>(0,Z.jsxs)(I,{className:`space-y-2`,children:[(0,Z.jsx)(R,{children:`Swift Code`}),(0,Z.jsx)(N,{children:(0,Z.jsx)(O,{value:e.value??``,onChange:e.onChange})}),(0,Z.jsx)(j,{})]})}),(0,Z.jsx)(P,{control:h,name:`extendedBankNumber`,render:({field:e})=>(0,Z.jsxs)(I,{className:`space-y-2`,children:[(0,Z.jsx)(R,{children:`Extended Bank Number`}),(0,Z.jsx)(N,{children:(0,Z.jsx)(O,{inputMode:`numeric`,value:e.value??``,onChange:e.onChange})}),(0,Z.jsx)(j,{})]})}),(0,Z.jsx)(P,{control:h,name:`partyPreferredIndication`,render:({field:e})=>(0,Z.jsxs)(I,{className:`space-y-2`,children:[(0,Z.jsx)(R,{children:`Party Preferred Indication`}),(0,Z.jsx)(N,{children:(0,Z.jsx)(O,{inputMode:`numeric`,value:e.value??``,onChange:e.onChange})}),(0,Z.jsx)(j,{})]})}),(0,Z.jsx)(P,{control:h,name:`partyAccountInvolvementCode`,render:({field:e})=>(0,Z.jsxs)(I,{className:`space-y-2`,children:[(0,Z.jsx)(R,{children:`Party Account Involvement Code`}),(0,Z.jsx)(N,{children:(0,Z.jsx)(O,{inputMode:`numeric`,value:e.value??``,onChange:e.onChange})}),(0,Z.jsx)(j,{})]})}),(0,Z.jsx)(P,{control:h,name:`accountDealDate`,render:({field:e})=>(0,Z.jsxs)(I,{className:`space-y-2`,children:[(0,Z.jsx)(R,{children:`Account Deal Date`}),(0,Z.jsx)(N,{children:(0,Z.jsx)(O,{inputMode:`numeric`,placeholder:`YYYYMMDD`,value:e.value??``,onChange:e.onChange})}),(0,Z.jsx)(j,{})]})}),(0,Z.jsx)(P,{control:h,name:`accountUpdateDate`,render:({field:e})=>(0,Z.jsxs)(I,{className:`space-y-2`,children:[(0,Z.jsx)(R,{children:`Account Update Date`}),(0,Z.jsx)(N,{children:(0,Z.jsx)(O,{inputMode:`numeric`,placeholder:`YYYYMMDD`,value:e.value??``,onChange:e.onChange})}),(0,Z.jsx)(j,{})]})}),(0,Z.jsx)(P,{control:h,name:`metegDoarNet`,render:({field:e})=>(0,Z.jsxs)(I,{className:`space-y-2`,children:[(0,Z.jsx)(R,{children:`Meteg Dora Net`}),(0,Z.jsx)(N,{children:(0,Z.jsx)(O,{inputMode:`numeric`,value:e.value??``,onChange:e.onChange})}),(0,Z.jsx)(j,{})]})}),(0,Z.jsx)(P,{control:h,name:`kodHarshaatPeilut`,render:({field:e})=>(0,Z.jsxs)(I,{className:`space-y-2`,children:[(0,Z.jsx)(R,{children:`Kod Harshaot Peilut`}),(0,Z.jsx)(N,{children:(0,Z.jsx)(O,{inputMode:`numeric`,value:e.value??``,onChange:e.onChange})}),(0,Z.jsx)(j,{})]})}),(0,Z.jsx)(P,{control:h,name:`accountClosingReasonCode`,render:({field:e})=>(0,Z.jsxs)(I,{className:`space-y-2`,children:[(0,Z.jsx)(R,{children:`Account Closing Reason Code`}),(0,Z.jsx)(N,{children:(0,Z.jsx)(O,{inputMode:`numeric`,value:e.value??``,onChange:e.onChange})}),(0,Z.jsx)(j,{})]})}),(0,Z.jsx)(P,{control:h,name:`accountAgreementOpeningDate`,render:({field:e})=>(0,Z.jsxs)(I,{className:`space-y-2`,children:[(0,Z.jsx)(R,{children:`Account Agreement Opening Date`}),(0,Z.jsx)(N,{children:(0,Z.jsx)(O,{inputMode:`numeric`,placeholder:`YYYYMMDD`,value:e.value??``,onChange:e.onChange})}),(0,Z.jsx)(j,{})]})}),(0,Z.jsx)(P,{control:h,name:`branchTypeCode`,render:({field:e})=>(0,Z.jsxs)(I,{className:`space-y-2`,children:[(0,Z.jsx)(R,{children:`Branch Type Code`}),(0,Z.jsx)(N,{children:(0,Z.jsx)(O,{inputMode:`numeric`,value:e.value??``,onChange:e.onChange})}),(0,Z.jsx)(j,{})]})}),(0,Z.jsx)(P,{control:h,name:`mymailEntitlementSwitch`,render:({field:e})=>(0,Z.jsxs)(I,{className:`space-y-2`,children:[(0,Z.jsx)(R,{children:`Mymail Entitlement Switch`}),(0,Z.jsx)(N,{children:(0,Z.jsx)(O,{inputMode:`numeric`,value:e.value??``,onChange:e.onChange})}),(0,Z.jsx)(j,{})]})}),(0,Z.jsx)(P,{control:h,name:`serviceAuthorizationDesc`,render:({field:e})=>(0,Z.jsxs)(I,{className:`space-y-2 md:col-span-2`,children:[(0,Z.jsx)(R,{children:`Service Authorization Description`}),(0,Z.jsx)(N,{children:(0,Z.jsx)(O,{...e})}),(0,Z.jsx)(j,{})]})}),(0,Z.jsx)(P,{control:h,name:`productLabel`,render:({field:e})=>(0,Z.jsxs)(I,{className:`space-y-2 md:col-span-2 lg:col-span-3`,children:[(0,Z.jsx)(R,{children:`Product Label`}),(0,Z.jsx)(N,{children:(0,Z.jsx)(O,{...e})}),(0,Z.jsx)(j,{})]})})]})]}),(0,Z.jsxs)(be,{children:[(0,Z.jsx)(A,{type:`button`,variant:`outline`,onClick:S,children:`Cancel`}),(0,Z.jsx)(A,{type:`submit`,disabled:c||u,children:a?u?`Updating…`:`Update Account`:c?`Creating…`:`Create Account`})]})]})})]})})});function li(e){return{id:e.id,name:e.name,number:e.number,isBusiness:e.privateOrBusiness===v.Business,type:e.type,currencies:e.accountTaxCategories.map(e=>({currency:e.currency,taxCategory:{id:e.taxCategory.id,name:e.taxCategory.name}})),...e.__typename===`BankFinancialAccount`?{bankNumber:e.bankNumber,branchNumber:e.branchNumber,iban:e.iban??void 0,swiftCode:e.swiftCode??void 0,extendedBankNumber:e.extendedBankNumber??void 0,partyPreferredIndication:e.partyPreferredIndication??void 0,partyAccountInvolvementCode:e.partyAccountInvolvementCode??void 0,accountDealDate:e.accountDealDate??void 0,accountUpdateDate:e.accountUpdateDate??void 0,metegDoarNet:e.metegDoarNet??void 0,kodHarshaatPeilut:e.kodHarshaatPeilut??void 0,accountClosingReasonCode:e.accountClosingReasonCode??void 0,accountAgreementOpeningDate:e.accountAgreementOpeningDate??void 0,serviceAuthorizationDesc:e.serviceAuthorizationDesc??void 0,branchTypeCode:e.branchTypeCode??void 0,mymailEntitlementSwitch:e.mymailEntitlementSwitch??void 0,productLabel:e.productLabel??void 0}:{}}}function ui({adminId:e}){let[t,n]=(0,X.useState)([]),[{data:r,fetching:i},a]=l({query:oe,variables:{adminId:e}});(0,X.useEffect)(()=>{r?.financialAccountsByOwner&&n(r.financialAccountsByOwner?.map(li)??[])},[r]);let o=(0,X.useRef)(null),s=e=>{o.current?.open(e)};return(0,Z.jsxs)(`div`,{className:`space-y-6`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`h2`,{className:`text-2xl font-semibold tracking-tight`,children:`Financial Accounts`}),(0,Z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Manage bank accounts, credit cards, and crypto wallets`})]}),(0,Z.jsxs)(A,{onClick:()=>s(),"aria-label":`Create new financial account`,children:[(0,Z.jsx)(D,{className:`h-4 w-4 mr-2`,"aria-hidden":`true`}),`New Account`]})]}),i?(0,Z.jsx)(`p`,{children:`Loading...`}):(0,Z.jsxs)(`div`,{className:`grid gap-4`,children:[t.length===0&&(0,Z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No financial accounts added yet.`}),t.map(e=>(0,Z.jsx)(ei,{account:e,handleOpenModal:s},e.id))]}),(0,Z.jsx)(ci,{ownerId:e,ref:o,onDone:()=>a()})]})}function di({businessId:e}){return(0,Z.jsxs)(W,{children:[(0,Z.jsxs)(G,{className:`flex w-full justify-between items-center`,children:[(0,Z.jsx)(`div`,{className:`flex items-center justify-between`,children:(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(J,{children:`Balance`}),(0,Z.jsx)(V,{children:`Business balance overview`})]})}),(0,Z.jsx)(me,{to:he.BUSINESSES.DETAIL_LEDGER(e),children:(0,Z.jsx)(A,{variant:`outline`,size:`icon`,children:(0,Z.jsx)(Ar,{})})})]}),(0,Z.jsx)(B,{children:(0,Z.jsx)(`div`,{className:`rounded-md border`,children:(0,Z.jsx)(an,{businessID:e,filter:{}})})})]})}function fi({businessId:e}){let{userContext:t}=(0,X.useContext)(it),[n,r]=(0,X.useState)(0),[i,a]=(0,X.useState)([]),o=(0,X.useCallback)(e=>{a(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])},[]),s=(0,X.useMemo)(()=>new Set(i),[i]),c=(0,X.useCallback)(()=>{a([])},[]),[{data:u,fetching:d},f]=l({query:ae,variables:{filters:{byOwners:t?.context.adminBusinessId?[t.context.adminBusinessId]:void 0,sortBy:{field:x.Date,asc:!1},byBusinesses:[e]},page:n,limit:10}}),p=u?.allCharges?.pageInfo.totalPages??1,m=(0,X.useMemo)(()=>u?.allCharges?.nodes??[],[u]);return d&&!m.length?(0,Z.jsx)(`div`,{children:`Loading charges...`}):(0,Z.jsxs)(W,{children:[(0,Z.jsxs)(G,{className:`flex w-full justify-between items-center`,children:[(0,Z.jsx)(`div`,{className:`flex items-center justify-between`,children:(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(J,{children:`Charges`}),(0,Z.jsx)(V,{children:`Recurring and one-time charges for this business`})]})}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[p>1&&(0,Z.jsx)(Qt,{className:`flex-fit w-fit mx-0`,currentPageIndex:n,onChange:r,totalPages:p}),(0,Z.jsx)(Lt,{selected:i.map(e=>({id:e,onChange:()=>{f({requestPolicy:`cache-and-network`})}})),resetMerge:c})]})]}),(0,Z.jsx)(B,{children:(0,Z.jsx)(`div`,{className:`rounded-md border`,children:(0,Z.jsx)(Me,{data:m,isAllOpened:!1,toggleMergeCharge:o,mergeSelectedCharges:s})})})]})}function pi(){return pi=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},pi.apply(null,arguments)}var mi=e=>{var{cx:n,cy:r,r:i,className:a}=e,o=t(`recharts-dot`,a);return gn(n)&&gn(r)&&gn(i)?X.createElement(`circle`,pi({},Fn(e),tr(e),{className:o,cx:n,cy:r,r:i})):null},hi=[`points`];function gi(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function _i(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?gi(Object(n),!0).forEach(function(t){vi(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):gi(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function vi(e,t,n){return(t=yi(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function yi(e){var t=bi(e,`string`);return typeof t==`symbol`?t:t+``}function bi(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function xi(){return xi=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},xi.apply(null,arguments)}function Si(e,t){if(e==null)return{};var n,r,i=Ci(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function Ci(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function wi(e){var{option:n,dotProps:r,className:i}=e;if((0,X.isValidElement)(n))return(0,X.cloneElement)(n,r);if(typeof n==`function`)return n(r);var a=t(i,typeof n==`boolean`?``:n.className),o=r??{},{points:s}=o,c=Si(o,hi);return X.createElement(mi,xi({},c,{className:a}))}function Ti(e,t){return e==null?!1:t?!0:e.length===1}function Ei(e){var{points:t,dot:n,className:r,dotClassName:i,dataKey:a,baseProps:o,needClip:s,clipPathId:c,zIndex:l=On.scatter}=e;if(!Ti(t,n))return null;var u=Tn(n),d=un(n),f=t.map((e,r)=>{var s=_i(_i(_i({r:3},o),d),{},{index:r,cx:e.x??void 0,cy:e.y??void 0,dataKey:a,value:e.value,payload:e.payload,points:t});return X.createElement(wi,{key:`dot-${r}`,option:n,dotProps:s,className:i})}),p={};return s&&c!=null&&(p.clipPath=`url(#clipPath-${u?``:`dots-`}${c})`),X.createElement(wn,{zIndex:l},X.createElement(kn,xi({className:r},p),f))}function Di(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Oi(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?Di(Object(n),!0).forEach(function(t){ki(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Di(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function ki(e,t,n){return(t=Ai(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Ai(e){var t=ji(e,`string`);return typeof t==`symbol`?t:t+``}function ji(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}var Mi=e=>{var{point:t,childIndex:n,mainColor:r,activeDot:i,dataKey:a,clipPath:o}=e;if(i===!1||t.x==null||t.y==null)return null;var s=Oi(Oi(Oi({},{index:n,dataKey:a,cx:t.x,cy:t.y,r:4,fill:r??`none`,strokeWidth:2,stroke:`#fff`,payload:t.payload,value:t.value}),vn(i)),tr(i)),c=(0,X.isValidElement)(i)?(0,X.cloneElement)(i,s):typeof i==`function`?i(s):X.createElement(mi,s);return X.createElement(kn,{className:`recharts-active-dot`,clipPath:o},c)};function Ni(e){var{points:t,mainColor:n,activeDot:r,itemDataKey:i,clipPath:a,zIndex:o=On.activeDot}=e,s=fn(hn),c=Yn();if(t==null||c==null)return null;var l=t.find(e=>c.includes(e.payload));return Dn(l)?null:X.createElement(wn,{zIndex:o},X.createElement(Mi,{point:l,childIndex:Number(s),mainColor:n,dataKey:i,activeDot:r,clipPath:a}))}var Pi=(e,t,n,r)=>ln(e,`xAxis`,t,r),Fi=(e,t,n,r)=>In(e,`xAxis`,t,r),Ii=(e,t,n,r)=>ln(e,`yAxis`,n,r),Li=(e,t,n,r)=>In(e,`yAxis`,n,r),Ri=Nn([Wn,Pi,Ii,Fi,Li],(e,t,n,r,i)=>jn(e,`xAxis`)?Zn(t,r,!1):Zn(n,i,!1)),zi=(e,t,n,r,i)=>i;function Bi(e){return e.type===`line`}var Vi=Nn([Wn,Pi,Ii,Fi,Li,Nn([_n,zi],(e,t)=>e.filter(Bi).find(e=>e.id===t)),Ri,Qn],(e,t,n,r,i,a,o,s)=>{var{chartData:c,dataStartIndex:l,dataEndIndex:u}=s;if(!(a==null||t==null||n==null||r==null||i==null||r.length===0||i.length===0||o==null||e!==`horizontal`&&e!==`vertical`)){var{dataKey:d,data:f}=a,p=f!=null&&f.length>0?f:c?.slice(l,u+1);if(p!=null)return ma({layout:e,xAxis:t,yAxis:n,xAxisTicks:r,yAxisTicks:i,dataKey:d,bandSize:o,displayedData:p})}});function Hi(e){var t=vn(e),n=3,r=2;if(t!=null){var{r:i,strokeWidth:a}=t,o=Number(i),s=Number(a);return(Number.isNaN(o)||o<0)&&(o=n),(Number.isNaN(s)||s<0)&&(s=r),{r:o,strokeWidth:s}}return{r:n,strokeWidth:r}}var Ui=[`id`],Wi=[`type`,`layout`,`connectNulls`,`needClip`,`shape`],Gi=[`activeDot`,`animateNewValues`,`animationBegin`,`animationDuration`,`animationEasing`,`connectNulls`,`dot`,`hide`,`isAnimationActive`,`label`,`legendType`,`xAxisId`,`yAxisId`,`id`];function Ki(){return Ki=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Ki.apply(null,arguments)}function qi(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function $(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?qi(Object(n),!0).forEach(function(t){Ji(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):qi(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Ji(e,t,n){return(t=Yi(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Yi(e){var t=Xi(e,`string`);return typeof t==`symbol`?t:t+``}function Xi(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function Zi(e,t){if(e==null)return{};var n,r,i=Qi(e,t);if(Object.getOwnPropertySymbols){var a=Ob