@accounter/client 0.0.9-alpha-20260104192330-5023f4398b22d4c0c52b68b62c7a290e03de417e → 0.0.9-alpha-20260104194509-1bbd863eb3e889196f321663613c729992d236b4
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/CHANGELOG.md +1 -1
- package/dist/assets/{Checkbox-D1EYx-2R.js → Checkbox-Bqh8Rs3Y.js} +1 -1
- package/dist/assets/{MultiSelect-BYC23mXC.js → MultiSelect-BLtBUfDG.js} +1 -1
- package/dist/assets/{Progress-Bgh_hdHE.js → Progress-zdcZiq7-.js} +1 -1
- package/dist/assets/{Table-BPmZ5ljQ.js → Table-LzLjpZeA.js} +1 -1
- package/dist/assets/{Typography-IFt-aKsY.js → Typography-DemEN63p.js} +1 -1
- package/dist/assets/{YearPickerInput-DXpznBXd.js → YearPickerInput-wefUMrNX.js} +1 -1
- package/dist/assets/{accordion-DjXOBlUF.js → accordion-DY8sNVhh.js} +1 -1
- package/dist/assets/{accountant-approvals-Ddg6bDMn.js → accountant-approvals-DtBIRZC5.js} +1 -1
- package/dist/assets/{accounter-table-Cg2u2Bcd.js → accounter-table-pB9Clv36.js} +1 -1
- package/dist/assets/{addDays-CIRVLi_y.js → addDays-z7yxKvSG.js} +1 -1
- package/dist/assets/{all-charges-B53ChbBw.js → all-charges-BqRr5A4S.js} +1 -1
- package/dist/assets/{arrow-up-down-BMWCHusr.js → arrow-up-down-DB7wmydC.js} +1 -1
- package/dist/assets/{building-2-DvOC_0Kc.js → building-2-BUBxSuvf.js} +1 -1
- package/dist/assets/{business-C6EHWbDo.js → business-B33OdXng.js} +1 -1
- package/dist/assets/{business-extended-info-zo9fuTOe.js → business-extended-info-C3BaFkvQ.js} +1 -1
- package/dist/assets/{business-header-KFCqFju_.js → business-header-DH34C-UW.js} +1 -1
- package/dist/assets/{business-ledger-filters-CmCpp7PJ.js → business-ledger-filters-C_W4Kia6.js} +1 -1
- package/dist/assets/{business-ledger-single-DZyFn40E.js → business-ledger-single-CLw2fXXF.js} +1 -1
- package/dist/assets/{business-trip-Beo5bB1g.js → business-trip-BDIbjeVM.js} +1 -1
- package/dist/assets/{charge-Cvrsuvam.js → charge-BZqb4exj.js} +1 -1
- package/dist/assets/{charges-filters-BcdlXxSE.js → charges-filters-f-jBUxw-.js} +1 -1
- package/dist/assets/{charges-ledger-validation-K5bGVbfd.js → charges-ledger-validation-vQXFL31X.js} +1 -1
- package/dist/assets/{charges-table-BE8zAChh.js → charges-table-CYqBhSR-.js} +3 -3
- package/dist/assets/{chart-DyrsWjc9.js → chart-D-802gvL.js} +1 -1
- package/dist/assets/{contracts-CjRjQCRY.js → contracts-40v4c5wb.js} +1 -1
- package/dist/assets/{data-table-column-header-BN5-dHgb.js → data-table-column-header-RVA6DnfK.js} +1 -1
- package/dist/assets/{data-table-pagination-Dncu-pMI.js → data-table-pagination-UNpJ4XY4.js} +1 -1
- package/dist/assets/{deposits-transactions-table-D3Sw0OgH.js → deposits-transactions-table-CcCuygQV.js} +1 -1
- package/dist/assets/{download-csv-button-BzrwomIw.js → download-csv-button-C_FDbZVI.js} +1 -1
- package/dist/assets/{editable-business-trip-TNouMmtc.js → editable-business-trip-D7udcq6I.js} +1 -1
- package/dist/assets/{eye-off-Ct63cJU6.js → eye-off-A1glr3Lh.js} +1 -1
- package/dist/assets/{funnel-BpdROO69.js → funnel-BFG62oJX.js} +1 -1
- package/dist/assets/{index-B3P9rJGf.js → index-BANZ4FYC.js} +1 -1
- package/dist/assets/{index-CNNawG6D.js → index-BWAOW53d.js} +4 -4
- package/dist/assets/{index-CAoIWd0f.js → index-BXi4oDGN.js} +1 -1
- package/dist/assets/{index-fvfqfHgx.js → index-BhoUb_ON.js} +1 -1
- package/dist/assets/{index-VOgo1b_w.js → index-Bk6qb18g.js} +1 -1
- package/dist/assets/{index-DfyBVta3.js → index-BlXqh5bw.js} +1 -1
- package/dist/assets/{index-D0OFipbT.js → index-Bps1VY5w.js} +1 -1
- package/dist/assets/{index-BvqzqML_.js → index-CR08bGyj.js} +1 -1
- package/dist/assets/{index-i7Yf0n3Q.js → index-CV3eOseE.js} +1 -1
- package/dist/assets/{index-B4XWvHSY.js → index-C_D1SRFk.js} +1 -1
- package/dist/assets/{index-DDqBw1FZ.js → index-CcCOZohd.js} +1 -1
- package/dist/assets/{index-BgpzfaeJ.js → index-Clz8I9dK.js} +1 -1
- package/dist/assets/{index-CJ5SOHQ0.js → index-Cwq6ofsb.js} +1 -1
- package/dist/assets/{index-sl9J9RIm.js → index-DJDErZF_.js} +1 -1
- package/dist/assets/{index-1q5Bty_H.js → index-DLnIlpCq.js} +1 -1
- package/dist/assets/{index-DCrzzRDf.js → index-DhMdXJus.js} +1 -1
- package/dist/assets/{index-DWeUM89g.js → index-Djgjvx0H.js} +1 -1
- package/dist/assets/{index-C6PQh6Al.js → index-DqYn-i8w.js} +1 -1
- package/dist/assets/{index-lbcY8WB_.js → index-HOYMUDFE.js} +1 -1
- package/dist/assets/{index-LWqbIc1T.js → index-_JHX2B8O.js} +1 -1
- package/dist/assets/{index-CIRmhdDG.js → index-_kREhIPr.js} +1 -1
- package/dist/assets/{index-ComDmMDN.js → index-b-MiIoC6.js} +1 -1
- package/dist/assets/{index-Bpv_EQpT.js → index-hOl2Gwvk.js} +1 -1
- package/dist/assets/{index-CIoirABN.js → index-iu4sjTwc.js} +1 -1
- package/dist/assets/{index-Cs_wIQni.js → index-nugs82ok.js} +1 -1
- package/dist/assets/{index-D4AHtEfm.js → index-qqIdqRd-.js} +1 -1
- package/dist/assets/{index.es-BB65ERNg.js → index.es-DTX7vrgg.js} +1 -1
- package/dist/assets/{insert-business-trip-modal-CLVLw7m4.js → insert-business-trip-modal-C4MiJk_g.js} +1 -1
- package/dist/assets/issue-document-DlLf2ULj.js +1 -0
- package/dist/assets/{list-plus-wSEH8ky8.js → list-plus-C0XPnNVe.js} +1 -1
- package/dist/assets/{login-page-CQJsxqwG.js → login-page-Ck5nqn-L.js} +1 -1
- package/dist/assets/{match-document-modal-BVyNTaxu.js → match-document-modal-B8E3M5F6.js} +1 -1
- package/dist/assets/{missing-info-charges-DJbVpU3F.js → missing-info-charges-DGgTFt-D.js} +1 -1
- package/dist/assets/{modal-BghEq_eS.js → modal-DGBtDZun.js} +1 -1
- package/dist/assets/{modify-contract-dialog-DP5g5ngT.js → modify-contract-dialog-BoLoZhIr.js} +1 -1
- package/dist/assets/{page-layout-Dne17xLZ.js → page-layout-Ck_xKyt0.js} +1 -1
- package/dist/assets/{page-not-found-BoSNUBMS.js → page-not-found-BTbs3XmD.js} +1 -1
- package/dist/assets/{panel-top-open-muCAuRMw.js → panel-top-open-EMjzc-ww.js} +1 -1
- package/dist/assets/{report-commentary-row-Ch8YqjGk.js → report-commentary-row-C0J-6IpH.js} +1 -1
- package/dist/assets/{save-CY8EeuE7.js → save-BMNpevK9.js} +1 -1
- package/dist/assets/{similar-transactions-modal-vucNNAQ7.js → similar-transactions-modal--yMHokZr.js} +1 -1
- package/dist/assets/{sub-CjP3ABDx.js → sub-B9GwcGJi.js} +1 -1
- package/dist/assets/subMonths-KzuARV4a.js +1 -0
- package/dist/assets/{summary-CoPnqTel.js → summary-BU7IrLve.js} +1 -1
- package/dist/assets/{toggle-expansion-button-wmsjVpKZ.js → toggle-expansion-button-wXVsrHLI.js} +1 -1
- package/dist/assets/{use-issue-monthly-documents-CP0FLnjj.js → use-issue-monthly-documents-DEVr0ix_.js} +1 -1
- package/dist/assets/{use-url-query-D4K72DMD.js → use-url-query-DG-wQ19o.js} +1 -1
- package/dist/index.html +1 -1
- package/package.json +1 -1
- package/src/components/charges/charge-extended-info.tsx +11 -14
- package/src/components/documents-table/cells/creditor.tsx +1 -1
- package/src/components/documents-table/cells/debtor.tsx +1 -1
- package/src/components/documents-table/cells/description.tsx +1 -1
- package/src/components/documents-table/cells/remarks.tsx +1 -1
- package/src/components/documents-table/cells/type.tsx +1 -1
- package/dist/assets/issue-document-8tNe2T1W.js +0 -1
- package/dist/assets/subMonths-I2NCK3sY.js +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import{v as _e,j as n,ey as La,af as Ba,aM as Va,bc as Ua,bx as Ge,ci as $,ch as Ie,ez as Ka,r as p,by as qe,aF as k,bz as We,eA as us,eB as Ha,eC as Ga,eD as qa,eE as Wa,eF as cn,bu as Be,eG as fs,eH as Ya,d as Dt,cq as ps,G as B,eI as Qa,g as Ee,eJ as Ja,t as F,i as Oe,eK as Xa,T as Ke,bW as en,B as q,m as gs,eL as Za,eM as eo,z as An,V as to,eN as no,eO as ro,eP as at,eQ as ot,eR as Zn,eS as er,dN as so,eT as ms,eU as ao,l as xt,eV as oo,eW as io,aT as tr,eX as co,u as ke,eY as lo,c as hs,D as St,aL as xs,bT as uo,bU as fo,bV as po,x as wt,al as Pn,am as Nn,ah as ys,eZ as go,e_ as mo,bX as Tn,c4 as kn,c5 as $n,J as vs,bN as tn,bO as nn,bP as Ne,bQ as Ae,c1 as rt,bR as rn,bS as xe,p as jn,w as He,e$ as ho,y as xo,f0 as yo,e9 as vo,f1 as jo,bB as Le,f2 as bo,ai as yt,R as st,f3 as js,f4 as bs,f5 as Ue,f6 as Co,f7 as Cs,f8 as Do,f9 as So,fa as Ds,fb as zt,fc as Ss,fd as wo,fe as Io,ay as sn,ff as _o,a3 as ws,fg as Is,n as mt,bD as Fe,bE as _s,bF as Es,cp as Os,bG as Lt,fh as Eo,fi as Oo,cv as Fn,e as Ao,fj as Po,a9 as No,fk as To,L as Mn,fl as ko,e6 as $o,ds as Fo,fm as bn,fn as As,fo as Ps,fp as Mo,fq as ln,fr as nr,fs as Ns,dt as Ro,ft as zo,dG as we,b_ as Ce,ag as Ts,fu as rr,en as Lo,c3 as Bo,P as Vo,ea as ks,fv as $s,fw as Fs,fx as Uo,fy as Ko,fz as Ho,ao as sr,ap as ar,aq as or,ar as ir,as as cr,a2 as Go,au as qo,fA as Wo,fB as Ms,c2 as Yo,bY as Qo,bZ as Jo,b$ as Xo,c0 as Zo,fC as ei,fD as ti,dn as nt,fE as Rs,fF as ni,fG as zs,W as ri,O as si,fH as Ls,fI as ai,fJ as Bs,fK as Vs,fL as Pe,fM as De,fN as lr,fO as Us,fP as oi,fQ as Je,fR as ii,fS as ci,fT as li}from"./index-CNNawG6D.js";import{T as Ks}from"./toggle-expansion-button-wmsjVpKZ.js";import{M as di,P as Y,I as ui,T as Hs,a as fi,D as pi,A as gi,b as mi,c as hi,S as xi,C as yi,d as vi}from"./index-1q5Bty_H.js";import{T as Gs}from"./Table-BPmZ5ljQ.js";import{R as ji,S as bi,M as ie,B as Ci,L as dr,A as z,G as dn,C as ur,a as Di}from"./summary-CoPnqTel.js";import{L as un}from"./list-plus-wSEH8ky8.js";import{u as Si,D as wi}from"./deposits-transactions-table-D3Sw0OgH.js";import{C as Ii,M as _i}from"./Checkbox-D1EYx-2R.js";import{A as Ei,a as fr,b as pr,c as Ot}from"./accordion-DjXOBlUF.js";import{D as ze}from"./data-table-column-header-BN5-dHgb.js";const Oi=[["path",{d:"m3 16 4 4 4-4",key:"1co6wj"}],["path",{d:"M7 20V4",key:"1yoxec"}],["path",{d:"M11 4h10",key:"1w87gc"}],["path",{d:"M11 8h7",key:"djye34"}],["path",{d:"M11 12h4",key:"q8tih4"}]],Ai=_e("arrow-down-wide-narrow",Oi);const Pi=[["path",{d:"m16 3 4 4-4 4",key:"1x1c3m"}],["path",{d:"M20 7H4",key:"zbl0bi"}],["path",{d:"m8 21-4-4 4-4",key:"h9nckh"}],["path",{d:"M4 17h16",key:"g4d7ey"}]],Ni=_e("arrow-right-left",Pi);const Ti=[["circle",{cx:"8",cy:"8",r:"6",key:"3yglwk"}],["path",{d:"M18.09 10.37A6 6 0 1 1 10.34 18",key:"t5s6rm"}],["path",{d:"M7 6h1v4",key:"1obek4"}],["path",{d:"m16.71 13.88.7.71-2.82 2.82",key:"1rbuyh"}]],qs=_e("coins",Ti);const ki=[["path",{d:"M14 3a1 1 0 0 1 1 1v5a1 1 0 0 1-1 1",key:"1l7d7l"}],["path",{d:"M19 3a1 1 0 0 1 1 1v5a1 1 0 0 1-1 1",key:"9955pe"}],["path",{d:"m7 15 3 3",key:"4hkfgk"}],["path",{d:"m7 21 3-3H5a2 2 0 0 1-2-2v-2",key:"1xljwe"}],["rect",{x:"14",y:"14",width:"7",height:"7",rx:"1",key:"1cdgtw"}],["rect",{x:"3",y:"3",width:"7",height:"7",rx:"1",key:"zi3rio"}]],$i=_e("combine",ki);const Fi=[["path",{d:"M11.35 22H6a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v5.35",key:"17jvcc"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M14 19h6",key:"bvotb8"}],["path",{d:"M17 16v6",key:"18yu1i"}]],gr=_e("file-plus-corner",Fi);const Mi=[["rect",{x:"3",y:"8",width:"18",height:"4",rx:"1",key:"bkv52"}],["path",{d:"M12 8v13",key:"1c76mn"}],["path",{d:"M19 12v7a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2v-7",key:"6wjy6b"}],["path",{d:"M7.5 8a2.5 2.5 0 0 1 0-5A4.8 8 0 0 1 12 8a4.8 8 0 0 1 4.5-5 2.5 2.5 0 0 1 0 5",key:"1ihvrl"}]],Ri=_e("gift",Mi);const zi=[["path",{d:"M11 17h3v2a1 1 0 0 0 1 1h2a1 1 0 0 0 1-1v-3a3.16 3.16 0 0 0 2-2h1a1 1 0 0 0 1-1v-2a1 1 0 0 0-1-1h-1a5 5 0 0 0-2-4V3a4 4 0 0 0-3.2 1.6l-.3.4H11a6 6 0 0 0-6 6v1a5 5 0 0 0 2 4v3a1 1 0 0 0 1 1h2a1 1 0 0 0 1-1z",key:"1piglc"}],["path",{d:"M16 10h.01",key:"1m94wz"}],["path",{d:"M2 8v1a2 2 0 0 0 2 2h1",key:"1env43"}]],Li=_e("piggy-bank",zi);const Bi=[["path",{d:"M17.8 19.2 16 11l3.5-3.5C21 6 21.5 4 21 3c-1-.5-3 0-4.5 1.5L13 8 4.8 6.2c-.5-.1-.9.1-1.1.5l-.3.5c-.2.5-.1 1 .3 1.3L9 12l-2 3H4l-1 1 3 2 2 3 1-1v-3l3-2 3.5 5.3c.3.4.8.5 1.3.3l.5-.2c.4-.3.6-.7.5-1.2z",key:"1v9wt8"}]],Vi=_e("plane",Bi);const Ui=[["path",{d:"M21 12a9 9 0 0 0-9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"14sxne"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M3 12a9 9 0 0 0 9 9 9.75 9.75 0 0 0 6.74-2.74L21 16",key:"1hlbsb"}],["path",{d:"M16 16h5v5",key:"ccwih5"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}]],Ki=_e("refresh-ccw-dot",Ui);const Hi=[["path",{d:"M21 10.656V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h12.344",key:"2acyp4"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],At=_e("square-check-big",Hi);const Gi=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]],Pt=_e("square-x",Gi);const qi=[["path",{d:"M14.828 14.828 21 21",key:"ar5fw7"}],["path",{d:"M21 16v5h-5",key:"1ck2sf"}],["path",{d:"m21 3-9 9-4-4-6 6",key:"1h02xo"}],["path",{d:"M21 8V3h-5",key:"1qoq8a"}]],Wi=_e("trending-up-down",qi);const Yi=[["path",{d:"M19 7V4a1 1 0 0 0-1-1H5a2 2 0 0 0 0 4h15a1 1 0 0 1 1 1v4h-3a2 2 0 0 0 0 4h3a1 1 0 0 0 1-1v-2a1 1 0 0 0-1-1",key:"18etb6"}],["path",{d:"M3 5v14a2 2 0 0 0 2 2h15a1 1 0 0 0 1-1v-4",key:"xoc0q4"}]],Qi=_e("wallet",Yi),Ji={CommonCharge:"Common",BusinessTripCharge:"Business Trip",DividendCharge:"Dividend",ConversionCharge:"Conversion",SalaryCharge:"Salary",InternalTransferCharge:"Internal Transfer",MonthlyVatCharge:"Monthly VAT",BankDepositCharge:"Bank Deposit",ForeignSecuritiesCharge:"Foreign Securities",CreditcardBankCharge:"Credit Card Bank Charge",FinancialCharge:"Financial Charge"},Rn=e=>Ji[e]??"Unknown",Xi={CommonCharge:n.jsx(qs,{}),BusinessTripCharge:n.jsx(Vi,{}),DividendCharge:n.jsx(Ri,{}),ConversionCharge:n.jsx(Ua,{}),SalaryCharge:n.jsx(Qi,{}),InternalTransferCharge:n.jsx(Ni,{}),MonthlyVatCharge:n.jsx(Va,{}),BankDepositCharge:n.jsx(Li,{}),ForeignSecuritiesCharge:n.jsx(Wi,{}),CreditcardBankCharge:n.jsx(Ba,{}),FinancialCharge:n.jsx(La,{})},Ws=e=>Xi[e]??n.jsx(qs,{});function mr(e){return typeof e!="string"?"":e.charAt(0).toUpperCase()+e.slice(1)}var Zi=Object.defineProperty,ec=Object.defineProperties,tc=Object.getOwnPropertyDescriptors,hr=Object.getOwnPropertySymbols,nc=Object.prototype.hasOwnProperty,rc=Object.prototype.propertyIsEnumerable,xr=(e,t,r)=>t in e?Zi(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,fn=(e,t)=>{for(var r in t||(t={}))nc.call(t,r)&&xr(e,r,t[r]);if(hr)for(var r of hr(t))rc.call(t,r)&&xr(e,r,t[r]);return e},sc=(e,t)=>ec(e,tc(t));const ac=["light","filled","outline","dot","gradient"],pn={xs:{fontSize:$(9),height:$(16)},sm:{fontSize:$(10),height:$(18)},md:{fontSize:$(11),height:$(20)},lg:{fontSize:$(13),height:$(26)},xl:{fontSize:$(16),height:$(32)}},oc={xs:$(4),sm:$(4),md:$(6),lg:$(8),xl:$(10)};function ic({theme:e,variant:t,color:r,size:s,gradient:a}){if(!ac.includes(t))return null;if(t==="dot"){const i=Ie({size:s,sizes:oc});return{backgroundColor:"transparent",color:e.colorScheme==="dark"?e.colors.dark[0]:e.colors.gray[7],border:`${$(1)} solid ${e.colorScheme==="dark"?e.colors.dark[3]:e.colors.gray[3]}`,paddingLeft:`calc(${Ie({size:s,sizes:e.spacing})} / 1.5 - ${i} / 2)`,"&::before":{content:'""',display:"block",width:i,height:i,borderRadius:i,backgroundColor:e.fn.themeColor(r,e.colorScheme==="dark"?4:e.fn.primaryShade("light"),!0),marginRight:i}}}const o=e.fn.variant({color:r,variant:t,gradient:a});return{background:o.background,color:o.color,border:`${$(t==="gradient"?0:1)} solid ${o.border}`}}var cc=Ge((e,{color:t,radius:r,gradient:s,fullWidth:a},{variant:o,size:i})=>{const{fontSize:c,height:l}=i in pn?pn[i]:pn.md;return{leftSection:{marginRight:`calc(${e.spacing.xs} / 2)`},rightSection:{marginLeft:`calc(${e.spacing.xs} / 2)`},inner:{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},root:fn(sc(fn(fn({},e.fn.focusStyles()),e.fn.fontStyles()),{fontSize:c,height:l,WebkitTapHighlightColor:"transparent",lineHeight:`calc(${l} - ${$(2)})`,textDecoration:"none",padding:`0 calc(${Ie({size:i,sizes:e.spacing})} / 1.5)`,boxSizing:"border-box",display:a?"flex":"inline-flex",alignItems:"center",justifyContent:"center",width:a?"100%":"auto",textTransform:"uppercase",borderRadius:e.fn.radius(r),fontWeight:700,letterSpacing:$(.25),cursor:"inherit",textOverflow:"ellipsis",overflow:"hidden"}),ic({theme:e,variant:o,color:t,size:i,gradient:s}))}}),lc=Object.defineProperty,Bt=Object.getOwnPropertySymbols,Ys=Object.prototype.hasOwnProperty,Qs=Object.prototype.propertyIsEnumerable,yr=(e,t,r)=>t in e?lc(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,dc=(e,t)=>{for(var r in t||(t={}))Ys.call(t,r)&&yr(e,r,t[r]);if(Bt)for(var r of Bt(t))Qs.call(t,r)&&yr(e,r,t[r]);return e},uc=(e,t)=>{var r={};for(var s in e)Ys.call(e,s)&&t.indexOf(s)<0&&(r[s]=e[s]);if(e!=null&&Bt)for(var s of Bt(e))t.indexOf(s)<0&&Qs.call(e,s)&&(r[s]=e[s]);return r};const fc={variant:"light",size:"md",radius:"xl"},Js=p.forwardRef((e,t)=>{const r=qe("Badge",fc,e),{className:s,color:a,variant:o,fullWidth:i,children:c,size:l,leftSection:d,rightSection:y,radius:g,gradient:m,classNames:x,styles:f,unstyled:u}=r,j=uc(r,["className","color","variant","fullWidth","children","size","leftSection","rightSection","radius","gradient","classNames","styles","unstyled"]),{classes:v,cx:b}=cc({fullWidth:i,color:a,radius:g,gradient:m},{classNames:x,styles:f,name:"Badge",unstyled:u,variant:o,size:l});return k.createElement(We,dc({className:b(v.root,s),ref:t},j),d&&k.createElement("span",{className:v.leftSection},d),k.createElement("span",{className:v.inner},c),y&&k.createElement("span",{className:v.rightSection},y))});Js.displayName="@mantine/core/Badge";const Cn=Ka(Js);var pc=Object.defineProperty,Vt=Object.getOwnPropertySymbols,Xs=Object.prototype.hasOwnProperty,Zs=Object.prototype.propertyIsEnumerable,vr=(e,t,r)=>t in e?pc(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,jr=(e,t)=>{for(var r in t||(t={}))Xs.call(t,r)&&vr(e,r,t[r]);if(Vt)for(var r of Vt(t))Zs.call(t,r)&&vr(e,r,t[r]);return e},gc=(e,t)=>{var r={};for(var s in e)Xs.call(e,s)&&t.indexOf(s)<0&&(r[s]=e[s]);if(e!=null&&Vt)for(var s of Vt(e))t.indexOf(s)<0&&Zs.call(e,s)&&(r[s]=e[s]);return r};const mc={multiple:!1},ea=p.forwardRef((e,t)=>{const r=qe("FileButton",mc,e),{onChange:s,children:a,multiple:o,accept:i,name:c,form:l,resetRef:d,disabled:y,capture:g,inputProps:m}=r,x=gc(r,["onChange","children","multiple","accept","name","form","resetRef","disabled","capture","inputProps"]),f=p.useRef(),u=()=>{!y&&f.current.click()},j=b=>{s(o?Array.from(b.currentTarget.files):b.currentTarget.files[0]||null)};return us(d,()=>{f.current.value=""}),k.createElement(k.Fragment,null,a(jr({onClick:u},x)),k.createElement("input",jr({style:{display:"none"},type:"file",accept:i,multiple:o,onChange:j,ref:Ha(t,f),name:c,form:l,capture:g},m)))});ea.displayName="@mantine/core/FileButton";var hc=Ge(()=>({placeholder:{},input:{cursor:"pointer"}})),xc=Object.defineProperty,yc=Object.defineProperties,vc=Object.getOwnPropertyDescriptors,Ut=Object.getOwnPropertySymbols,ta=Object.prototype.hasOwnProperty,na=Object.prototype.propertyIsEnumerable,br=(e,t,r)=>t in e?xc(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,tt=(e,t)=>{for(var r in t||(t={}))ta.call(t,r)&&br(e,r,t[r]);if(Ut)for(var r of Ut(t))na.call(t,r)&&br(e,r,t[r]);return e},Nt=(e,t)=>yc(e,vc(t)),jc=(e,t)=>{var r={};for(var s in e)ta.call(e,s)&&t.indexOf(s)<0&&(r[s]=e[s]);if(e!=null&&Ut)for(var s of Ut(e))t.indexOf(s)<0&&na.call(e,s)&&(r[s]=e[s]);return r};const bc=({value:e})=>k.createElement(Be,{sx:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}},Array.isArray(e)?e.map(t=>t.name).join(", "):e?.name),Cc={size:"sm",valueComponent:bc},ra=p.forwardRef((e,t)=>{const r=Ga("FileInput",Cc,e),{inputProps:s,wrapperProps:a,placeholder:o,value:i,defaultValue:c,onChange:l,multiple:d,accept:y,name:g,form:m,classNames:x,styles:f,unstyled:u,valueComponent:j,rightSection:v,clearable:b,clearButtonProps:C,readOnly:S,capture:O,fileInputProps:_}=r,D=jc(r,["inputProps","wrapperProps","placeholder","value","defaultValue","onChange","multiple","accept","name","form","classNames","styles","unstyled","valueComponent","rightSection","clearable","clearButtonProps","readOnly","capture","fileInputProps"]),E=p.useRef(),{classes:A,cx:M}=hc(null,{name:"FileInput",classNames:x,styles:f,unstyled:u}),[h,T]=qa({value:i,defaultValue:c,onChange:l,finalValue:d?[]:null}),Q=Array.isArray(h)?h.length!==0:h!==null,R=v||(b&&Q&&!S?k.createElement(Wa,Nt(tt({},C),{variant:"transparent",onClick:()=>T(d?[]:null),size:s.size,unstyled:u})):null);return p.useEffect(()=>{(Array.isArray(h)&&h.length===0||h===null)&&E.current()},[h]),k.createElement(cn.Wrapper,Nt(tt({},a),{__staticSelector:"FileInput"}),k.createElement(ea,{onChange:T,multiple:d,accept:y,name:g,form:m,resetRef:E,disabled:S,capture:O,inputProps:_},V=>k.createElement(cn,Nt(tt(tt(tt({multiline:!0},V),s),D),{component:"button",type:"button",ref:t,__staticSelector:"FileInput",rightSection:R,classNames:Nt(tt({},x),{input:M(A.input,x?.input)})}),Q?k.createElement(j,{value:h}):k.createElement(cn.Placeholder,{className:A.placeholder},o))))});ra.displayName="@mantine/core/FileInput";const Dc=ra;var Sc=Object.defineProperty,wc=Object.defineProperties,Ic=Object.getOwnPropertyDescriptors,Cr=Object.getOwnPropertySymbols,_c=Object.prototype.hasOwnProperty,Ec=Object.prototype.propertyIsEnumerable,Dr=(e,t,r)=>t in e?Sc(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Oc=(e,t)=>{for(var r in t||(t={}))_c.call(t,r)&&Dr(e,r,t[r]);if(Cr)for(var r of Cr(t))Ec.call(t,r)&&Dr(e,r,t[r]);return e},Ac=(e,t)=>wc(e,Ic(t)),Pc=Ge(e=>({root:Ac(Oc({},e.fn.cover()),{display:"flex",alignItems:"center",justifyContent:"center",overflow:"hidden"})})),Nc=Object.defineProperty,Tc=Object.defineProperties,kc=Object.getOwnPropertyDescriptors,Kt=Object.getOwnPropertySymbols,sa=Object.prototype.hasOwnProperty,aa=Object.prototype.propertyIsEnumerable,Sr=(e,t,r)=>t in e?Nc(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Tt=(e,t)=>{for(var r in t||(t={}))sa.call(t,r)&&Sr(e,r,t[r]);if(Kt)for(var r of Kt(t))aa.call(t,r)&&Sr(e,r,t[r]);return e},$c=(e,t)=>Tc(e,kc(t)),Fc=(e,t)=>{var r={};for(var s in e)sa.call(e,s)&&t.indexOf(s)<0&&(r[s]=e[s]);if(e!=null&&Kt)for(var s of Kt(e))t.indexOf(s)<0&&aa.call(e,s)&&(r[s]=e[s]);return r};const Mc={overlayOpacity:.75,transitionDuration:0,radius:0,zIndex:fs("overlay")},oa=p.forwardRef((e,t)=>{const r=qe("LoadingOverlay",Mc,e),{className:s,visible:a,loaderProps:o,overlayOpacity:i,overlayColor:c,transitionDuration:l,exitTransitionDuration:d,zIndex:y,style:g,loader:m,radius:x,overlayBlur:f,unstyled:u,variant:j,keepMounted:v}=r,b=Fc(r,["className","visible","loaderProps","overlayOpacity","overlayColor","transitionDuration","exitTransitionDuration","zIndex","style","loader","radius","overlayBlur","unstyled","variant","keepMounted"]),{classes:C,cx:S,theme:O}=Pc(null,{name:"LoadingOverlay",unstyled:u,variant:j}),_=`calc(${y} + 1)`;return k.createElement(Ya,{keepMounted:v,duration:l,exitDuration:d,mounted:a,transition:"fade"},D=>k.createElement(We,Tt({className:S(C.root,s),style:$c(Tt(Tt({},D),g),{zIndex:y}),ref:t},b),m?k.createElement("div",{style:{zIndex:_}},m):k.createElement(Dt,Tt({style:{zIndex:_}},o)),k.createElement(ps,{opacity:i,zIndex:y,radius:x,blur:f,unstyled:u,color:c||(O.colorScheme==="dark"?O.colors.dark[5]:O.white)})))});oa.displayName="@mantine/core/LoadingOverlay";var Rc=Object.defineProperty,zc=Object.defineProperties,Lc=Object.getOwnPropertyDescriptors,wr=Object.getOwnPropertySymbols,Bc=Object.prototype.hasOwnProperty,Vc=Object.prototype.propertyIsEnumerable,Ir=(e,t,r)=>t in e?Rc(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,_r=(e,t)=>{for(var r in t||(t={}))Bc.call(t,r)&&Ir(e,r,t[r]);if(wr)for(var r of wr(t))Vc.call(t,r)&&Ir(e,r,t[r]);return e},Uc=(e,t)=>zc(e,Lc(t));const Kc={xs:$(16),sm:$(20),md:$(26),lg:$(32),xl:$(40)},Hc=["filled","light","gradient","outline","default"];function Gc({theme:e,variant:t,color:r,gradient:s}){if(!Hc.includes(t))return null;const a=e.fn.variant({variant:t,color:r||e.primaryColor,gradient:s,primaryFallback:!1});return{backgroundColor:a.background,color:a.color,backgroundImage:t==="gradient"?a.background:void 0,border:`${$(t==="gradient"?0:1)} solid ${a.border}`}}var qc=Ge((e,{color:t,radius:r,gradient:s},{variant:a,size:o})=>{const i=Ie({size:o,sizes:Kc});return{root:_r(Uc(_r({},e.fn.fontStyles()),{display:"inline-flex",alignItems:"center",justifyContent:"center",boxSizing:"border-box",width:i,height:i,minWidth:i,minHeight:i,borderRadius:e.fn.radius(r)}),Gc({theme:e,variant:a,gradient:s,color:t}))}}),Wc=Object.defineProperty,Ht=Object.getOwnPropertySymbols,ia=Object.prototype.hasOwnProperty,ca=Object.prototype.propertyIsEnumerable,Er=(e,t,r)=>t in e?Wc(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Yc=(e,t)=>{for(var r in t||(t={}))ia.call(t,r)&&Er(e,r,t[r]);if(Ht)for(var r of Ht(t))ca.call(t,r)&&Er(e,r,t[r]);return e},Qc=(e,t)=>{var r={};for(var s in e)ia.call(e,s)&&t.indexOf(s)<0&&(r[s]=e[s]);if(e!=null&&Ht)for(var s of Ht(e))t.indexOf(s)<0&&ca.call(e,s)&&(r[s]=e[s]);return r};const Jc={size:"md",variant:"filled"},zn=p.forwardRef((e,t)=>{const r=qe("ThemeIcon",Jc,e),{className:s,size:a,radius:o,variant:i,color:c,children:l,gradient:d,unstyled:y}=r,g=Qc(r,["className","size","radius","variant","color","children","gradient","unstyled"]),{classes:m,cx:x}=qc({variant:i,radius:o,color:c,gradient:d},{name:"ThemeIcon",unstyled:y,variant:i,size:a});return k.createElement(We,Yc({className:x(m.root,s),ref:t},g),l)});zn.displayName="@mantine/core/ThemeIcon";const Xc=({data:e})=>{const t=B(Qa,e);return n.jsxs(n.Fragment,{children:[n.jsx(ji,{data:t,onChange:()=>{}}),n.jsx(bi,{data:t})]})},Zc="deleteCharge",el=()=>{const[{fetching:e},t]=Ee(Ja),r=p.useCallback(async s=>{const a=`Error deleting charge ID [${s.chargeId}]`,o=`${Zc}-${s.chargeId}`;F.loading("Deleting charge",{id:o});try{const i=await t(s),c=Oe(i,a,o);if(c){if(c.deleteCharge===!1)throw new Error("Unsuccessful deletion");return F.success("Success",{id:o,description:"Charge was deleted"}),c.deleteCharge}}catch(i){console.error(`${a}: ${i}`),F.error("Error",{id:o,description:a,duration:1e5,closeButton:!0})}return!1},[t]);return{fetching:e,deleteCharge:r}},tl="regenerateLedgerRecords",nl=()=>{const[{fetching:e},t]=Ee(Xa),r=p.useCallback(async s=>{const a="Error regenerating ledger",o=`${tl}-${s.chargeId}`;F.loading("Regenerating Ledger",{id:o});try{const i=await t(s),c=Oe(i,a,o,"regenerateLedgerRecords");if(c)return F.success("Success",{id:o,description:"Ledger records were regenerated"}),c.regenerateLedgerRecords}catch(i){console.error(`${a}: ${i}`),F.error("Error",{id:o,description:a,duration:1e5,closeButton:!0})}},[t]);return{fetching:e,regenerateLedgerRecords:r}};function rl({chargeId:e,onChange:t,...r}){const{regenerateLedgerRecords:s}=nl();function a(){s({chargeId:e}).then(t)}return n.jsx(Ke,{content:"Regenerate Ledger",children:n.jsx(en,{onConfirm:a,title:"Are you sure you want to regenerate ledger records?",children:n.jsx(q,{variant:"outline",size:"icon",...r,className:gs("size-7.5",r.className),children:n.jsx(Ki,{className:"size-5"})})})})}function sl(e){const{mergeSelected:t,toggleMergeSelected:r}=e,[s,a]=p.useState(t?"default":"ghost");return p.useEffect(()=>{a(t?"default":"ghost")},[t]),n.jsx(Ke,{content:"Select for merge",children:n.jsx(q,{onClick:o=>{o.stopPropagation(),r()},variant:s,className:gs("size-7.5",t?"bg-blue-500 hover:bg-blue-500/90":""),children:n.jsx($i,{className:"size-5"})})})}const al="updateCharge",la=()=>{const[{fetching:e},t]=Ee(Za),r=p.useCallback(async s=>{const a=`Error updating charge ID [${s.chargeId}]`,o=`${al}-${s.chargeId}`;F.loading("Updating charge",{id:o});try{const i=await t(s),c=Oe(i,a,o,"updateCharge");if(c)return F.success("Success",{id:o,description:"Charge updated"}),c.updateCharge.charge}catch(i){console.error(`${a}: ${i}`),F.error("Error",{id:o,description:a,duration:1e5,closeButton:!0})}},[t]);return{fetching:e,updateCharge:r}},ol="updateMiscExpense",il=()=>{const[{fetching:e},t]=Ee(eo),r=p.useCallback(async s=>{const a=`Error updating misc expense ID [${s.id}]`,o=`${ol}-${s.id}`;F.loading("Update Misc Expense",{id:o});try{const i=await t(s),c=Oe(i,a,o,"updateMiscExpense");if(c)return F.success("Success",{id:o,description:"Misc expense was updated"}),c.updateMiscExpense}catch(i){console.error(`${a}: ${i}`),F.error("Error",{id:o,description:a,duration:1e5,closeButton:!0})}},[t]);return{fetching:e,updateMiscExpense:r}},cl=({onDone:e,data:t})=>{const[r,s]=p.useState(!1),a=B(no,t),o=An({defaultValues:{amount:a.amount.raw,currency:a.amount.currency,description:a.description,valueDate:new Date(a.valueDate),invoiceDate:a.invoiceDate,creditorId:a.creditor.id,debtorId:a.debtor.id}}),{handleSubmit:i,formState:{dirtyFields:c}}=o,{updateMiscExpense:l,fetching:d}=il(),y=p.useCallback(async m=>{s(!0),await l({id:a.id,fields:m}),e(),s(!1)},[l,e,a.id]),g=m=>{m&&Object.keys(m).length>0&&y({...m})};return r?n.jsx(Dt,{className:"flex self-center my-5",color:"dark",size:"xl",variant:"dots"}):n.jsx(to,{...o,children:n.jsx("form",{onSubmit:i(g),noValidate:!0,children:n.jsxs("div",{className:"px-5 flex flex-col gap-5",children:[n.jsx(di,{formManager:o,isInsert:!1}),n.jsx("div",{className:"flex justify-right gap-5 mt-5",children:n.jsx("button",{type:"submit",className:"text-white bg-indigo-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-indigo-600 rounded-sm text-lg",disabled:d||Object.keys(c).length===0,children:"Accept"})})]})})})},ll="insertSalaryRecordsFromFile",dl=()=>{const[{fetching:e},t]=Ee(ro),r=p.useCallback(async s=>{const a=`Error uploading payroll file to charge ID [${s.chargeId}]`,o=`${ll}-${s.chargeId}`;F.loading("Uploading payroll file",{id:o});try{const i=await t(s),c=Oe(i,a,o,"insertSalaryRecordsFromFile");if(c)return F.success("Success",{id:o,description:"Payroll file added"}),c.insertSalaryRecordsFromFile}catch(i){console.error(`${a}: ${i}`),F.error("Error",{id:o,description:a,duration:1e5,closeButton:!0})}return!1},[t]);return{fetching:e,uploadPayrollFile:r}},ul=({chargeId:e,onDone:t})=>{const{fetching:r,uploadPayrollFile:s}=dl(),[a,o]=p.useState(null),i=p.useCallback(async()=>{a&&s({file:a,chargeId:e}).then(t)},[s,t,a,e]);return n.jsxs("div",{className:"px-5 w-max h-max justify-items-center",children:[n.jsx(Dc,{icon:r&&n.jsx(Dt,{}),value:a,onChange:o,clearable:!0,label:"File Upload"}),n.jsx("div",{className:"flex justify-center gap-5 mt-5",children:n.jsx("button",{type:"submit",className:" text-white bg-indigo-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-indigo-600 rounded-sm text-lg",disabled:r||!a,onClick:i,children:"Accept"})})]})};var fl=new Map([["aac","audio/aac"],["abw","application/x-abiword"],["arc","application/x-freearc"],["avif","image/avif"],["avi","video/x-msvideo"],["azw","application/vnd.amazon.ebook"],["bin","application/octet-stream"],["bmp","image/bmp"],["bz","application/x-bzip"],["bz2","application/x-bzip2"],["cda","application/x-cdf"],["csh","application/x-csh"],["css","text/css"],["csv","text/csv"],["doc","application/msword"],["docx","application/vnd.openxmlformats-officedocument.wordprocessingml.document"],["eot","application/vnd.ms-fontobject"],["epub","application/epub+zip"],["gz","application/gzip"],["gif","image/gif"],["heic","image/heic"],["heif","image/heif"],["htm","text/html"],["html","text/html"],["ico","image/vnd.microsoft.icon"],["ics","text/calendar"],["jar","application/java-archive"],["jpeg","image/jpeg"],["jpg","image/jpeg"],["js","text/javascript"],["json","application/json"],["jsonld","application/ld+json"],["mid","audio/midi"],["midi","audio/midi"],["mjs","text/javascript"],["mp3","audio/mpeg"],["mp4","video/mp4"],["mpeg","video/mpeg"],["mpkg","application/vnd.apple.installer+xml"],["odp","application/vnd.oasis.opendocument.presentation"],["ods","application/vnd.oasis.opendocument.spreadsheet"],["odt","application/vnd.oasis.opendocument.text"],["oga","audio/ogg"],["ogv","video/ogg"],["ogx","application/ogg"],["opus","audio/opus"],["otf","font/otf"],["png","image/png"],["pdf","application/pdf"],["php","application/x-httpd-php"],["ppt","application/vnd.ms-powerpoint"],["pptx","application/vnd.openxmlformats-officedocument.presentationml.presentation"],["rar","application/vnd.rar"],["rtf","application/rtf"],["sh","application/x-sh"],["svg","image/svg+xml"],["swf","application/x-shockwave-flash"],["tar","application/x-tar"],["tif","image/tiff"],["tiff","image/tiff"],["ts","video/mp2t"],["ttf","font/ttf"],["txt","text/plain"],["vsd","application/vnd.visio"],["wav","audio/wav"],["weba","audio/webm"],["webm","video/webm"],["webp","image/webp"],["woff","font/woff"],["woff2","font/woff2"],["xhtml","application/xhtml+xml"],["xls","application/vnd.ms-excel"],["xlsx","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"],["xml","application/xml"],["xul","application/vnd.mozilla.xul+xml"],["zip","application/zip"],["7z","application/x-7z-compressed"],["mkv","video/x-matroska"],["mov","video/quicktime"],["msg","application/vnd.ms-outlook"]]);function It(e,t){var r=pl(e);if(typeof r.path!="string"){var s=e.webkitRelativePath;Object.defineProperty(r,"path",{value:typeof t=="string"?t:typeof s=="string"&&s.length>0?s:e.name,writable:!1,configurable:!1,enumerable:!0})}return r}function pl(e){var t=e.name,r=t&&t.lastIndexOf(".")!==-1;if(r&&!e.type){var s=t.split(".").pop().toLowerCase(),a=fl.get(s);a&&Object.defineProperty(e,"type",{value:a,writable:!1,configurable:!1,enumerable:!0})}return e}var gl=[".DS_Store","Thumbs.db"];function ml(e){return at(this,void 0,void 0,function(){return ot(this,function(t){return Gt(e)&&hl(e.dataTransfer)?[2,jl(e.dataTransfer,e.type)]:xl(e)?[2,yl(e)]:Array.isArray(e)&&e.every(function(r){return"getFile"in r&&typeof r.getFile=="function"})?[2,vl(e)]:[2,[]]})})}function hl(e){return Gt(e)}function xl(e){return Gt(e)&&Gt(e.target)}function Gt(e){return typeof e=="object"&&e!==null}function yl(e){return Dn(e.target.files).map(function(t){return It(t)})}function vl(e){return at(this,void 0,void 0,function(){var t;return ot(this,function(r){switch(r.label){case 0:return[4,Promise.all(e.map(function(s){return s.getFile()}))];case 1:return t=r.sent(),[2,t.map(function(s){return It(s)})]}})})}function jl(e,t){return at(this,void 0,void 0,function(){var r,s;return ot(this,function(a){switch(a.label){case 0:return e.items?(r=Dn(e.items).filter(function(o){return o.kind==="file"}),t!=="drop"?[2,r]:[4,Promise.all(r.map(bl))]):[3,2];case 1:return s=a.sent(),[2,Or(da(s))];case 2:return[2,Or(Dn(e.files).map(function(o){return It(o)}))]}})})}function Or(e){return e.filter(function(t){return gl.indexOf(t.name)===-1})}function Dn(e){if(e===null)return[];for(var t=[],r=0;r<e.length;r++){var s=e[r];t.push(s)}return t}function bl(e){if(typeof e.webkitGetAsEntry!="function")return Ar(e);var t=e.webkitGetAsEntry();return t&&t.isDirectory?ua(t):Ar(e)}function da(e){return e.reduce(function(t,r){return Zn(Zn([],er(t),!1),er(Array.isArray(r)?da(r):[r]),!1)},[])}function Ar(e){var t=e.getAsFile();if(!t)return Promise.reject("".concat(e," is not a File"));var r=It(t);return Promise.resolve(r)}function Cl(e){return at(this,void 0,void 0,function(){return ot(this,function(t){return[2,e.isDirectory?ua(e):Dl(e)]})})}function ua(e){var t=e.createReader();return new Promise(function(r,s){var a=[];function o(){var i=this;t.readEntries(function(c){return at(i,void 0,void 0,function(){var l,d,y;return ot(this,function(g){switch(g.label){case 0:if(c.length)return[3,5];g.label=1;case 1:return g.trys.push([1,3,,4]),[4,Promise.all(a)];case 2:return l=g.sent(),r(l),[3,4];case 3:return d=g.sent(),s(d),[3,4];case 4:return[3,6];case 5:y=Promise.all(c.map(Cl)),a.push(y),o(),g.label=6;case 6:return[2]}})})},function(c){s(c)})}o()})}function Dl(e){return at(this,void 0,void 0,function(){return ot(this,function(t){return[2,new Promise(function(r,s){e.file(function(a){var o=It(a,e.fullPath);r(o)},function(a){s(a)})})]})})}var kt={},Pr;function Sl(){return Pr||(Pr=1,kt.__esModule=!0,kt.default=function(e,t){if(e&&t){var r=Array.isArray(t)?t:t.split(",");if(r.length===0)return!0;var s=e.name||"",a=(e.type||"").toLowerCase(),o=a.replace(/\/.*$/,"");return r.some(function(i){var c=i.trim().toLowerCase();return c.charAt(0)==="."?s.toLowerCase().endsWith(c):c.endsWith("/*")?o===c.replace(/\/.*$/,""):a===c})}return!0}),kt}var wl=Sl();const Il=so(wl);function Nr(e){return Ol(e)||El(e)||pa(e)||_l()}function _l(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
|
|
1
|
+
import{v as _e,j as n,ey as La,af as Ba,aM as Va,bc as Ua,bx as Ge,ci as $,ch as Ie,ez as Ka,r as p,by as qe,aF as k,bz as We,eA as us,eB as Ha,eC as Ga,eD as qa,eE as Wa,eF as cn,bu as Be,eG as fs,eH as Ya,d as Dt,cq as ps,G as L,eI as Qa,g as Ee,eJ as Ja,t as F,i as Oe,eK as Xa,T as Ke,bW as en,B as q,m as gs,eL as Za,eM as eo,z as An,V as to,eN as no,eO as ro,eP as at,eQ as ot,eR as Zn,eS as er,dN as so,eT as ms,eU as ao,l as xt,eV as oo,eW as io,aT as tr,eX as co,u as ke,eY as lo,c as hs,D as St,aL as xs,bT as uo,bU as fo,bV as po,x as wt,al as Pn,am as Nn,ah as ys,eZ as go,e_ as mo,bX as Tn,c4 as kn,c5 as $n,J as vs,bN as tn,bO as nn,bP as Ne,bQ as Ae,c1 as rt,bR as rn,bS as xe,p as jn,w as He,e$ as ho,y as xo,f0 as yo,e9 as vo,f1 as jo,bB as Le,f2 as bo,ai as yt,R as st,f3 as js,f4 as bs,f5 as Ue,f6 as Co,f7 as Cs,f8 as Do,f9 as So,fa as Ds,fb as zt,fc as Ss,fd as wo,fe as Io,ay as sn,ff as _o,a3 as ws,fg as Is,n as mt,bD as Fe,bE as _s,bF as Es,cp as Os,bG as Lt,fh as Eo,fi as Oo,cv as Fn,e as Ao,fj as Po,a9 as No,fk as To,L as Mn,fl as ko,e6 as $o,ds as Fo,fm as bn,fn as As,fo as Ps,fp as Mo,fq as ln,fr as nr,fs as Ns,dt as Ro,ft as zo,dG as we,b_ as Ce,ag as Ts,fu as rr,en as Lo,c3 as Bo,P as Vo,ea as ks,fv as $s,fw as Fs,fx as Uo,fy as Ko,fz as Ho,ao as sr,ap as ar,aq as or,ar as ir,as as cr,a2 as Go,au as qo,fA as Wo,fB as Ms,c2 as Yo,bY as Qo,bZ as Jo,b$ as Xo,c0 as Zo,fC as ei,fD as ti,dn as nt,fE as Rs,fF as ni,fG as zs,W as ri,O as si,fH as Ls,fI as ai,fJ as Bs,fK as Vs,fL as Pe,fM as De,fN as lr,fO as Us,fP as oi,fQ as Je,fR as ii,fS as ci,fT as li}from"./index-BWAOW53d.js";import{T as Ks}from"./toggle-expansion-button-wXVsrHLI.js";import{M as di,P as Y,I as ui,T as Hs,a as fi,D as pi,A as gi,b as mi,c as hi,S as xi,C as yi,d as vi}from"./index-DLnIlpCq.js";import{T as Gs}from"./Table-LzLjpZeA.js";import{R as ji,S as bi,M as ie,B as Ci,L as dr,A as z,G as dn,C as ur,a as Di}from"./summary-BU7IrLve.js";import{L as un}from"./list-plus-C0XPnNVe.js";import{u as Si,D as wi}from"./deposits-transactions-table-CcCuygQV.js";import{C as Ii,M as _i}from"./Checkbox-Bqh8Rs3Y.js";import{A as Ei,a as fr,b as pr,c as Ot}from"./accordion-DY8sNVhh.js";import{D as ze}from"./data-table-column-header-RVA6DnfK.js";const Oi=[["path",{d:"m3 16 4 4 4-4",key:"1co6wj"}],["path",{d:"M7 20V4",key:"1yoxec"}],["path",{d:"M11 4h10",key:"1w87gc"}],["path",{d:"M11 8h7",key:"djye34"}],["path",{d:"M11 12h4",key:"q8tih4"}]],Ai=_e("arrow-down-wide-narrow",Oi);const Pi=[["path",{d:"m16 3 4 4-4 4",key:"1x1c3m"}],["path",{d:"M20 7H4",key:"zbl0bi"}],["path",{d:"m8 21-4-4 4-4",key:"h9nckh"}],["path",{d:"M4 17h16",key:"g4d7ey"}]],Ni=_e("arrow-right-left",Pi);const Ti=[["circle",{cx:"8",cy:"8",r:"6",key:"3yglwk"}],["path",{d:"M18.09 10.37A6 6 0 1 1 10.34 18",key:"t5s6rm"}],["path",{d:"M7 6h1v4",key:"1obek4"}],["path",{d:"m16.71 13.88.7.71-2.82 2.82",key:"1rbuyh"}]],qs=_e("coins",Ti);const ki=[["path",{d:"M14 3a1 1 0 0 1 1 1v5a1 1 0 0 1-1 1",key:"1l7d7l"}],["path",{d:"M19 3a1 1 0 0 1 1 1v5a1 1 0 0 1-1 1",key:"9955pe"}],["path",{d:"m7 15 3 3",key:"4hkfgk"}],["path",{d:"m7 21 3-3H5a2 2 0 0 1-2-2v-2",key:"1xljwe"}],["rect",{x:"14",y:"14",width:"7",height:"7",rx:"1",key:"1cdgtw"}],["rect",{x:"3",y:"3",width:"7",height:"7",rx:"1",key:"zi3rio"}]],$i=_e("combine",ki);const Fi=[["path",{d:"M11.35 22H6a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v5.35",key:"17jvcc"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M14 19h6",key:"bvotb8"}],["path",{d:"M17 16v6",key:"18yu1i"}]],gr=_e("file-plus-corner",Fi);const Mi=[["rect",{x:"3",y:"8",width:"18",height:"4",rx:"1",key:"bkv52"}],["path",{d:"M12 8v13",key:"1c76mn"}],["path",{d:"M19 12v7a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2v-7",key:"6wjy6b"}],["path",{d:"M7.5 8a2.5 2.5 0 0 1 0-5A4.8 8 0 0 1 12 8a4.8 8 0 0 1 4.5-5 2.5 2.5 0 0 1 0 5",key:"1ihvrl"}]],Ri=_e("gift",Mi);const zi=[["path",{d:"M11 17h3v2a1 1 0 0 0 1 1h2a1 1 0 0 0 1-1v-3a3.16 3.16 0 0 0 2-2h1a1 1 0 0 0 1-1v-2a1 1 0 0 0-1-1h-1a5 5 0 0 0-2-4V3a4 4 0 0 0-3.2 1.6l-.3.4H11a6 6 0 0 0-6 6v1a5 5 0 0 0 2 4v3a1 1 0 0 0 1 1h2a1 1 0 0 0 1-1z",key:"1piglc"}],["path",{d:"M16 10h.01",key:"1m94wz"}],["path",{d:"M2 8v1a2 2 0 0 0 2 2h1",key:"1env43"}]],Li=_e("piggy-bank",zi);const Bi=[["path",{d:"M17.8 19.2 16 11l3.5-3.5C21 6 21.5 4 21 3c-1-.5-3 0-4.5 1.5L13 8 4.8 6.2c-.5-.1-.9.1-1.1.5l-.3.5c-.2.5-.1 1 .3 1.3L9 12l-2 3H4l-1 1 3 2 2 3 1-1v-3l3-2 3.5 5.3c.3.4.8.5 1.3.3l.5-.2c.4-.3.6-.7.5-1.2z",key:"1v9wt8"}]],Vi=_e("plane",Bi);const Ui=[["path",{d:"M21 12a9 9 0 0 0-9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"14sxne"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M3 12a9 9 0 0 0 9 9 9.75 9.75 0 0 0 6.74-2.74L21 16",key:"1hlbsb"}],["path",{d:"M16 16h5v5",key:"ccwih5"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}]],Ki=_e("refresh-ccw-dot",Ui);const Hi=[["path",{d:"M21 10.656V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h12.344",key:"2acyp4"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],At=_e("square-check-big",Hi);const Gi=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]],Pt=_e("square-x",Gi);const qi=[["path",{d:"M14.828 14.828 21 21",key:"ar5fw7"}],["path",{d:"M21 16v5h-5",key:"1ck2sf"}],["path",{d:"m21 3-9 9-4-4-6 6",key:"1h02xo"}],["path",{d:"M21 8V3h-5",key:"1qoq8a"}]],Wi=_e("trending-up-down",qi);const Yi=[["path",{d:"M19 7V4a1 1 0 0 0-1-1H5a2 2 0 0 0 0 4h15a1 1 0 0 1 1 1v4h-3a2 2 0 0 0 0 4h3a1 1 0 0 0 1-1v-2a1 1 0 0 0-1-1",key:"18etb6"}],["path",{d:"M3 5v14a2 2 0 0 0 2 2h15a1 1 0 0 0 1-1v-4",key:"xoc0q4"}]],Qi=_e("wallet",Yi),Ji={CommonCharge:"Common",BusinessTripCharge:"Business Trip",DividendCharge:"Dividend",ConversionCharge:"Conversion",SalaryCharge:"Salary",InternalTransferCharge:"Internal Transfer",MonthlyVatCharge:"Monthly VAT",BankDepositCharge:"Bank Deposit",ForeignSecuritiesCharge:"Foreign Securities",CreditcardBankCharge:"Credit Card Bank Charge",FinancialCharge:"Financial Charge"},Rn=e=>Ji[e]??"Unknown",Xi={CommonCharge:n.jsx(qs,{}),BusinessTripCharge:n.jsx(Vi,{}),DividendCharge:n.jsx(Ri,{}),ConversionCharge:n.jsx(Ua,{}),SalaryCharge:n.jsx(Qi,{}),InternalTransferCharge:n.jsx(Ni,{}),MonthlyVatCharge:n.jsx(Va,{}),BankDepositCharge:n.jsx(Li,{}),ForeignSecuritiesCharge:n.jsx(Wi,{}),CreditcardBankCharge:n.jsx(Ba,{}),FinancialCharge:n.jsx(La,{})},Ws=e=>Xi[e]??n.jsx(qs,{});function mr(e){return typeof e!="string"?"":e.charAt(0).toUpperCase()+e.slice(1)}var Zi=Object.defineProperty,ec=Object.defineProperties,tc=Object.getOwnPropertyDescriptors,hr=Object.getOwnPropertySymbols,nc=Object.prototype.hasOwnProperty,rc=Object.prototype.propertyIsEnumerable,xr=(e,t,r)=>t in e?Zi(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,fn=(e,t)=>{for(var r in t||(t={}))nc.call(t,r)&&xr(e,r,t[r]);if(hr)for(var r of hr(t))rc.call(t,r)&&xr(e,r,t[r]);return e},sc=(e,t)=>ec(e,tc(t));const ac=["light","filled","outline","dot","gradient"],pn={xs:{fontSize:$(9),height:$(16)},sm:{fontSize:$(10),height:$(18)},md:{fontSize:$(11),height:$(20)},lg:{fontSize:$(13),height:$(26)},xl:{fontSize:$(16),height:$(32)}},oc={xs:$(4),sm:$(4),md:$(6),lg:$(8),xl:$(10)};function ic({theme:e,variant:t,color:r,size:s,gradient:a}){if(!ac.includes(t))return null;if(t==="dot"){const i=Ie({size:s,sizes:oc});return{backgroundColor:"transparent",color:e.colorScheme==="dark"?e.colors.dark[0]:e.colors.gray[7],border:`${$(1)} solid ${e.colorScheme==="dark"?e.colors.dark[3]:e.colors.gray[3]}`,paddingLeft:`calc(${Ie({size:s,sizes:e.spacing})} / 1.5 - ${i} / 2)`,"&::before":{content:'""',display:"block",width:i,height:i,borderRadius:i,backgroundColor:e.fn.themeColor(r,e.colorScheme==="dark"?4:e.fn.primaryShade("light"),!0),marginRight:i}}}const o=e.fn.variant({color:r,variant:t,gradient:a});return{background:o.background,color:o.color,border:`${$(t==="gradient"?0:1)} solid ${o.border}`}}var cc=Ge((e,{color:t,radius:r,gradient:s,fullWidth:a},{variant:o,size:i})=>{const{fontSize:c,height:l}=i in pn?pn[i]:pn.md;return{leftSection:{marginRight:`calc(${e.spacing.xs} / 2)`},rightSection:{marginLeft:`calc(${e.spacing.xs} / 2)`},inner:{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},root:fn(sc(fn(fn({},e.fn.focusStyles()),e.fn.fontStyles()),{fontSize:c,height:l,WebkitTapHighlightColor:"transparent",lineHeight:`calc(${l} - ${$(2)})`,textDecoration:"none",padding:`0 calc(${Ie({size:i,sizes:e.spacing})} / 1.5)`,boxSizing:"border-box",display:a?"flex":"inline-flex",alignItems:"center",justifyContent:"center",width:a?"100%":"auto",textTransform:"uppercase",borderRadius:e.fn.radius(r),fontWeight:700,letterSpacing:$(.25),cursor:"inherit",textOverflow:"ellipsis",overflow:"hidden"}),ic({theme:e,variant:o,color:t,size:i,gradient:s}))}}),lc=Object.defineProperty,Bt=Object.getOwnPropertySymbols,Ys=Object.prototype.hasOwnProperty,Qs=Object.prototype.propertyIsEnumerable,yr=(e,t,r)=>t in e?lc(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,dc=(e,t)=>{for(var r in t||(t={}))Ys.call(t,r)&&yr(e,r,t[r]);if(Bt)for(var r of Bt(t))Qs.call(t,r)&&yr(e,r,t[r]);return e},uc=(e,t)=>{var r={};for(var s in e)Ys.call(e,s)&&t.indexOf(s)<0&&(r[s]=e[s]);if(e!=null&&Bt)for(var s of Bt(e))t.indexOf(s)<0&&Qs.call(e,s)&&(r[s]=e[s]);return r};const fc={variant:"light",size:"md",radius:"xl"},Js=p.forwardRef((e,t)=>{const r=qe("Badge",fc,e),{className:s,color:a,variant:o,fullWidth:i,children:c,size:l,leftSection:d,rightSection:y,radius:g,gradient:m,classNames:x,styles:f,unstyled:u}=r,j=uc(r,["className","color","variant","fullWidth","children","size","leftSection","rightSection","radius","gradient","classNames","styles","unstyled"]),{classes:v,cx:b}=cc({fullWidth:i,color:a,radius:g,gradient:m},{classNames:x,styles:f,name:"Badge",unstyled:u,variant:o,size:l});return k.createElement(We,dc({className:b(v.root,s),ref:t},j),d&&k.createElement("span",{className:v.leftSection},d),k.createElement("span",{className:v.inner},c),y&&k.createElement("span",{className:v.rightSection},y))});Js.displayName="@mantine/core/Badge";const Cn=Ka(Js);var pc=Object.defineProperty,Vt=Object.getOwnPropertySymbols,Xs=Object.prototype.hasOwnProperty,Zs=Object.prototype.propertyIsEnumerable,vr=(e,t,r)=>t in e?pc(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,jr=(e,t)=>{for(var r in t||(t={}))Xs.call(t,r)&&vr(e,r,t[r]);if(Vt)for(var r of Vt(t))Zs.call(t,r)&&vr(e,r,t[r]);return e},gc=(e,t)=>{var r={};for(var s in e)Xs.call(e,s)&&t.indexOf(s)<0&&(r[s]=e[s]);if(e!=null&&Vt)for(var s of Vt(e))t.indexOf(s)<0&&Zs.call(e,s)&&(r[s]=e[s]);return r};const mc={multiple:!1},ea=p.forwardRef((e,t)=>{const r=qe("FileButton",mc,e),{onChange:s,children:a,multiple:o,accept:i,name:c,form:l,resetRef:d,disabled:y,capture:g,inputProps:m}=r,x=gc(r,["onChange","children","multiple","accept","name","form","resetRef","disabled","capture","inputProps"]),f=p.useRef(),u=()=>{!y&&f.current.click()},j=b=>{s(o?Array.from(b.currentTarget.files):b.currentTarget.files[0]||null)};return us(d,()=>{f.current.value=""}),k.createElement(k.Fragment,null,a(jr({onClick:u},x)),k.createElement("input",jr({style:{display:"none"},type:"file",accept:i,multiple:o,onChange:j,ref:Ha(t,f),name:c,form:l,capture:g},m)))});ea.displayName="@mantine/core/FileButton";var hc=Ge(()=>({placeholder:{},input:{cursor:"pointer"}})),xc=Object.defineProperty,yc=Object.defineProperties,vc=Object.getOwnPropertyDescriptors,Ut=Object.getOwnPropertySymbols,ta=Object.prototype.hasOwnProperty,na=Object.prototype.propertyIsEnumerable,br=(e,t,r)=>t in e?xc(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,tt=(e,t)=>{for(var r in t||(t={}))ta.call(t,r)&&br(e,r,t[r]);if(Ut)for(var r of Ut(t))na.call(t,r)&&br(e,r,t[r]);return e},Nt=(e,t)=>yc(e,vc(t)),jc=(e,t)=>{var r={};for(var s in e)ta.call(e,s)&&t.indexOf(s)<0&&(r[s]=e[s]);if(e!=null&&Ut)for(var s of Ut(e))t.indexOf(s)<0&&na.call(e,s)&&(r[s]=e[s]);return r};const bc=({value:e})=>k.createElement(Be,{sx:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}},Array.isArray(e)?e.map(t=>t.name).join(", "):e?.name),Cc={size:"sm",valueComponent:bc},ra=p.forwardRef((e,t)=>{const r=Ga("FileInput",Cc,e),{inputProps:s,wrapperProps:a,placeholder:o,value:i,defaultValue:c,onChange:l,multiple:d,accept:y,name:g,form:m,classNames:x,styles:f,unstyled:u,valueComponent:j,rightSection:v,clearable:b,clearButtonProps:C,readOnly:S,capture:O,fileInputProps:_}=r,D=jc(r,["inputProps","wrapperProps","placeholder","value","defaultValue","onChange","multiple","accept","name","form","classNames","styles","unstyled","valueComponent","rightSection","clearable","clearButtonProps","readOnly","capture","fileInputProps"]),E=p.useRef(),{classes:A,cx:M}=hc(null,{name:"FileInput",classNames:x,styles:f,unstyled:u}),[h,T]=qa({value:i,defaultValue:c,onChange:l,finalValue:d?[]:null}),Q=Array.isArray(h)?h.length!==0:h!==null,R=v||(b&&Q&&!S?k.createElement(Wa,Nt(tt({},C),{variant:"transparent",onClick:()=>T(d?[]:null),size:s.size,unstyled:u})):null);return p.useEffect(()=>{(Array.isArray(h)&&h.length===0||h===null)&&E.current()},[h]),k.createElement(cn.Wrapper,Nt(tt({},a),{__staticSelector:"FileInput"}),k.createElement(ea,{onChange:T,multiple:d,accept:y,name:g,form:m,resetRef:E,disabled:S,capture:O,inputProps:_},V=>k.createElement(cn,Nt(tt(tt(tt({multiline:!0},V),s),D),{component:"button",type:"button",ref:t,__staticSelector:"FileInput",rightSection:R,classNames:Nt(tt({},x),{input:M(A.input,x?.input)})}),Q?k.createElement(j,{value:h}):k.createElement(cn.Placeholder,{className:A.placeholder},o))))});ra.displayName="@mantine/core/FileInput";const Dc=ra;var Sc=Object.defineProperty,wc=Object.defineProperties,Ic=Object.getOwnPropertyDescriptors,Cr=Object.getOwnPropertySymbols,_c=Object.prototype.hasOwnProperty,Ec=Object.prototype.propertyIsEnumerable,Dr=(e,t,r)=>t in e?Sc(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Oc=(e,t)=>{for(var r in t||(t={}))_c.call(t,r)&&Dr(e,r,t[r]);if(Cr)for(var r of Cr(t))Ec.call(t,r)&&Dr(e,r,t[r]);return e},Ac=(e,t)=>wc(e,Ic(t)),Pc=Ge(e=>({root:Ac(Oc({},e.fn.cover()),{display:"flex",alignItems:"center",justifyContent:"center",overflow:"hidden"})})),Nc=Object.defineProperty,Tc=Object.defineProperties,kc=Object.getOwnPropertyDescriptors,Kt=Object.getOwnPropertySymbols,sa=Object.prototype.hasOwnProperty,aa=Object.prototype.propertyIsEnumerable,Sr=(e,t,r)=>t in e?Nc(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Tt=(e,t)=>{for(var r in t||(t={}))sa.call(t,r)&&Sr(e,r,t[r]);if(Kt)for(var r of Kt(t))aa.call(t,r)&&Sr(e,r,t[r]);return e},$c=(e,t)=>Tc(e,kc(t)),Fc=(e,t)=>{var r={};for(var s in e)sa.call(e,s)&&t.indexOf(s)<0&&(r[s]=e[s]);if(e!=null&&Kt)for(var s of Kt(e))t.indexOf(s)<0&&aa.call(e,s)&&(r[s]=e[s]);return r};const Mc={overlayOpacity:.75,transitionDuration:0,radius:0,zIndex:fs("overlay")},oa=p.forwardRef((e,t)=>{const r=qe("LoadingOverlay",Mc,e),{className:s,visible:a,loaderProps:o,overlayOpacity:i,overlayColor:c,transitionDuration:l,exitTransitionDuration:d,zIndex:y,style:g,loader:m,radius:x,overlayBlur:f,unstyled:u,variant:j,keepMounted:v}=r,b=Fc(r,["className","visible","loaderProps","overlayOpacity","overlayColor","transitionDuration","exitTransitionDuration","zIndex","style","loader","radius","overlayBlur","unstyled","variant","keepMounted"]),{classes:C,cx:S,theme:O}=Pc(null,{name:"LoadingOverlay",unstyled:u,variant:j}),_=`calc(${y} + 1)`;return k.createElement(Ya,{keepMounted:v,duration:l,exitDuration:d,mounted:a,transition:"fade"},D=>k.createElement(We,Tt({className:S(C.root,s),style:$c(Tt(Tt({},D),g),{zIndex:y}),ref:t},b),m?k.createElement("div",{style:{zIndex:_}},m):k.createElement(Dt,Tt({style:{zIndex:_}},o)),k.createElement(ps,{opacity:i,zIndex:y,radius:x,blur:f,unstyled:u,color:c||(O.colorScheme==="dark"?O.colors.dark[5]:O.white)})))});oa.displayName="@mantine/core/LoadingOverlay";var Rc=Object.defineProperty,zc=Object.defineProperties,Lc=Object.getOwnPropertyDescriptors,wr=Object.getOwnPropertySymbols,Bc=Object.prototype.hasOwnProperty,Vc=Object.prototype.propertyIsEnumerable,Ir=(e,t,r)=>t in e?Rc(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,_r=(e,t)=>{for(var r in t||(t={}))Bc.call(t,r)&&Ir(e,r,t[r]);if(wr)for(var r of wr(t))Vc.call(t,r)&&Ir(e,r,t[r]);return e},Uc=(e,t)=>zc(e,Lc(t));const Kc={xs:$(16),sm:$(20),md:$(26),lg:$(32),xl:$(40)},Hc=["filled","light","gradient","outline","default"];function Gc({theme:e,variant:t,color:r,gradient:s}){if(!Hc.includes(t))return null;const a=e.fn.variant({variant:t,color:r||e.primaryColor,gradient:s,primaryFallback:!1});return{backgroundColor:a.background,color:a.color,backgroundImage:t==="gradient"?a.background:void 0,border:`${$(t==="gradient"?0:1)} solid ${a.border}`}}var qc=Ge((e,{color:t,radius:r,gradient:s},{variant:a,size:o})=>{const i=Ie({size:o,sizes:Kc});return{root:_r(Uc(_r({},e.fn.fontStyles()),{display:"inline-flex",alignItems:"center",justifyContent:"center",boxSizing:"border-box",width:i,height:i,minWidth:i,minHeight:i,borderRadius:e.fn.radius(r)}),Gc({theme:e,variant:a,gradient:s,color:t}))}}),Wc=Object.defineProperty,Ht=Object.getOwnPropertySymbols,ia=Object.prototype.hasOwnProperty,ca=Object.prototype.propertyIsEnumerable,Er=(e,t,r)=>t in e?Wc(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Yc=(e,t)=>{for(var r in t||(t={}))ia.call(t,r)&&Er(e,r,t[r]);if(Ht)for(var r of Ht(t))ca.call(t,r)&&Er(e,r,t[r]);return e},Qc=(e,t)=>{var r={};for(var s in e)ia.call(e,s)&&t.indexOf(s)<0&&(r[s]=e[s]);if(e!=null&&Ht)for(var s of Ht(e))t.indexOf(s)<0&&ca.call(e,s)&&(r[s]=e[s]);return r};const Jc={size:"md",variant:"filled"},zn=p.forwardRef((e,t)=>{const r=qe("ThemeIcon",Jc,e),{className:s,size:a,radius:o,variant:i,color:c,children:l,gradient:d,unstyled:y}=r,g=Qc(r,["className","size","radius","variant","color","children","gradient","unstyled"]),{classes:m,cx:x}=qc({variant:i,radius:o,color:c,gradient:d},{name:"ThemeIcon",unstyled:y,variant:i,size:a});return k.createElement(We,Yc({className:x(m.root,s),ref:t},g),l)});zn.displayName="@mantine/core/ThemeIcon";const Xc=({data:e})=>{const t=L(Qa,e);return n.jsxs(n.Fragment,{children:[n.jsx(ji,{data:t,onChange:()=>{}}),n.jsx(bi,{data:t})]})},Zc="deleteCharge",el=()=>{const[{fetching:e},t]=Ee(Ja),r=p.useCallback(async s=>{const a=`Error deleting charge ID [${s.chargeId}]`,o=`${Zc}-${s.chargeId}`;F.loading("Deleting charge",{id:o});try{const i=await t(s),c=Oe(i,a,o);if(c){if(c.deleteCharge===!1)throw new Error("Unsuccessful deletion");return F.success("Success",{id:o,description:"Charge was deleted"}),c.deleteCharge}}catch(i){console.error(`${a}: ${i}`),F.error("Error",{id:o,description:a,duration:1e5,closeButton:!0})}return!1},[t]);return{fetching:e,deleteCharge:r}},tl="regenerateLedgerRecords",nl=()=>{const[{fetching:e},t]=Ee(Xa),r=p.useCallback(async s=>{const a="Error regenerating ledger",o=`${tl}-${s.chargeId}`;F.loading("Regenerating Ledger",{id:o});try{const i=await t(s),c=Oe(i,a,o,"regenerateLedgerRecords");if(c)return F.success("Success",{id:o,description:"Ledger records were regenerated"}),c.regenerateLedgerRecords}catch(i){console.error(`${a}: ${i}`),F.error("Error",{id:o,description:a,duration:1e5,closeButton:!0})}},[t]);return{fetching:e,regenerateLedgerRecords:r}};function rl({chargeId:e,onChange:t,...r}){const{regenerateLedgerRecords:s}=nl();function a(){s({chargeId:e}).then(t)}return n.jsx(Ke,{content:"Regenerate Ledger",children:n.jsx(en,{onConfirm:a,title:"Are you sure you want to regenerate ledger records?",children:n.jsx(q,{variant:"outline",size:"icon",...r,className:gs("size-7.5",r.className),children:n.jsx(Ki,{className:"size-5"})})})})}function sl(e){const{mergeSelected:t,toggleMergeSelected:r}=e,[s,a]=p.useState(t?"default":"ghost");return p.useEffect(()=>{a(t?"default":"ghost")},[t]),n.jsx(Ke,{content:"Select for merge",children:n.jsx(q,{onClick:o=>{o.stopPropagation(),r()},variant:s,className:gs("size-7.5",t?"bg-blue-500 hover:bg-blue-500/90":""),children:n.jsx($i,{className:"size-5"})})})}const al="updateCharge",la=()=>{const[{fetching:e},t]=Ee(Za),r=p.useCallback(async s=>{const a=`Error updating charge ID [${s.chargeId}]`,o=`${al}-${s.chargeId}`;F.loading("Updating charge",{id:o});try{const i=await t(s),c=Oe(i,a,o,"updateCharge");if(c)return F.success("Success",{id:o,description:"Charge updated"}),c.updateCharge.charge}catch(i){console.error(`${a}: ${i}`),F.error("Error",{id:o,description:a,duration:1e5,closeButton:!0})}},[t]);return{fetching:e,updateCharge:r}},ol="updateMiscExpense",il=()=>{const[{fetching:e},t]=Ee(eo),r=p.useCallback(async s=>{const a=`Error updating misc expense ID [${s.id}]`,o=`${ol}-${s.id}`;F.loading("Update Misc Expense",{id:o});try{const i=await t(s),c=Oe(i,a,o,"updateMiscExpense");if(c)return F.success("Success",{id:o,description:"Misc expense was updated"}),c.updateMiscExpense}catch(i){console.error(`${a}: ${i}`),F.error("Error",{id:o,description:a,duration:1e5,closeButton:!0})}},[t]);return{fetching:e,updateMiscExpense:r}},cl=({onDone:e,data:t})=>{const[r,s]=p.useState(!1),a=L(no,t),o=An({defaultValues:{amount:a.amount.raw,currency:a.amount.currency,description:a.description,valueDate:new Date(a.valueDate),invoiceDate:a.invoiceDate,creditorId:a.creditor.id,debtorId:a.debtor.id}}),{handleSubmit:i,formState:{dirtyFields:c}}=o,{updateMiscExpense:l,fetching:d}=il(),y=p.useCallback(async m=>{s(!0),await l({id:a.id,fields:m}),e(),s(!1)},[l,e,a.id]),g=m=>{m&&Object.keys(m).length>0&&y({...m})};return r?n.jsx(Dt,{className:"flex self-center my-5",color:"dark",size:"xl",variant:"dots"}):n.jsx(to,{...o,children:n.jsx("form",{onSubmit:i(g),noValidate:!0,children:n.jsxs("div",{className:"px-5 flex flex-col gap-5",children:[n.jsx(di,{formManager:o,isInsert:!1}),n.jsx("div",{className:"flex justify-right gap-5 mt-5",children:n.jsx("button",{type:"submit",className:"text-white bg-indigo-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-indigo-600 rounded-sm text-lg",disabled:d||Object.keys(c).length===0,children:"Accept"})})]})})})},ll="insertSalaryRecordsFromFile",dl=()=>{const[{fetching:e},t]=Ee(ro),r=p.useCallback(async s=>{const a=`Error uploading payroll file to charge ID [${s.chargeId}]`,o=`${ll}-${s.chargeId}`;F.loading("Uploading payroll file",{id:o});try{const i=await t(s),c=Oe(i,a,o,"insertSalaryRecordsFromFile");if(c)return F.success("Success",{id:o,description:"Payroll file added"}),c.insertSalaryRecordsFromFile}catch(i){console.error(`${a}: ${i}`),F.error("Error",{id:o,description:a,duration:1e5,closeButton:!0})}return!1},[t]);return{fetching:e,uploadPayrollFile:r}},ul=({chargeId:e,onDone:t})=>{const{fetching:r,uploadPayrollFile:s}=dl(),[a,o]=p.useState(null),i=p.useCallback(async()=>{a&&s({file:a,chargeId:e}).then(t)},[s,t,a,e]);return n.jsxs("div",{className:"px-5 w-max h-max justify-items-center",children:[n.jsx(Dc,{icon:r&&n.jsx(Dt,{}),value:a,onChange:o,clearable:!0,label:"File Upload"}),n.jsx("div",{className:"flex justify-center gap-5 mt-5",children:n.jsx("button",{type:"submit",className:" text-white bg-indigo-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-indigo-600 rounded-sm text-lg",disabled:r||!a,onClick:i,children:"Accept"})})]})};var fl=new Map([["aac","audio/aac"],["abw","application/x-abiword"],["arc","application/x-freearc"],["avif","image/avif"],["avi","video/x-msvideo"],["azw","application/vnd.amazon.ebook"],["bin","application/octet-stream"],["bmp","image/bmp"],["bz","application/x-bzip"],["bz2","application/x-bzip2"],["cda","application/x-cdf"],["csh","application/x-csh"],["css","text/css"],["csv","text/csv"],["doc","application/msword"],["docx","application/vnd.openxmlformats-officedocument.wordprocessingml.document"],["eot","application/vnd.ms-fontobject"],["epub","application/epub+zip"],["gz","application/gzip"],["gif","image/gif"],["heic","image/heic"],["heif","image/heif"],["htm","text/html"],["html","text/html"],["ico","image/vnd.microsoft.icon"],["ics","text/calendar"],["jar","application/java-archive"],["jpeg","image/jpeg"],["jpg","image/jpeg"],["js","text/javascript"],["json","application/json"],["jsonld","application/ld+json"],["mid","audio/midi"],["midi","audio/midi"],["mjs","text/javascript"],["mp3","audio/mpeg"],["mp4","video/mp4"],["mpeg","video/mpeg"],["mpkg","application/vnd.apple.installer+xml"],["odp","application/vnd.oasis.opendocument.presentation"],["ods","application/vnd.oasis.opendocument.spreadsheet"],["odt","application/vnd.oasis.opendocument.text"],["oga","audio/ogg"],["ogv","video/ogg"],["ogx","application/ogg"],["opus","audio/opus"],["otf","font/otf"],["png","image/png"],["pdf","application/pdf"],["php","application/x-httpd-php"],["ppt","application/vnd.ms-powerpoint"],["pptx","application/vnd.openxmlformats-officedocument.presentationml.presentation"],["rar","application/vnd.rar"],["rtf","application/rtf"],["sh","application/x-sh"],["svg","image/svg+xml"],["swf","application/x-shockwave-flash"],["tar","application/x-tar"],["tif","image/tiff"],["tiff","image/tiff"],["ts","video/mp2t"],["ttf","font/ttf"],["txt","text/plain"],["vsd","application/vnd.visio"],["wav","audio/wav"],["weba","audio/webm"],["webm","video/webm"],["webp","image/webp"],["woff","font/woff"],["woff2","font/woff2"],["xhtml","application/xhtml+xml"],["xls","application/vnd.ms-excel"],["xlsx","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"],["xml","application/xml"],["xul","application/vnd.mozilla.xul+xml"],["zip","application/zip"],["7z","application/x-7z-compressed"],["mkv","video/x-matroska"],["mov","video/quicktime"],["msg","application/vnd.ms-outlook"]]);function It(e,t){var r=pl(e);if(typeof r.path!="string"){var s=e.webkitRelativePath;Object.defineProperty(r,"path",{value:typeof t=="string"?t:typeof s=="string"&&s.length>0?s:e.name,writable:!1,configurable:!1,enumerable:!0})}return r}function pl(e){var t=e.name,r=t&&t.lastIndexOf(".")!==-1;if(r&&!e.type){var s=t.split(".").pop().toLowerCase(),a=fl.get(s);a&&Object.defineProperty(e,"type",{value:a,writable:!1,configurable:!1,enumerable:!0})}return e}var gl=[".DS_Store","Thumbs.db"];function ml(e){return at(this,void 0,void 0,function(){return ot(this,function(t){return Gt(e)&&hl(e.dataTransfer)?[2,jl(e.dataTransfer,e.type)]:xl(e)?[2,yl(e)]:Array.isArray(e)&&e.every(function(r){return"getFile"in r&&typeof r.getFile=="function"})?[2,vl(e)]:[2,[]]})})}function hl(e){return Gt(e)}function xl(e){return Gt(e)&&Gt(e.target)}function Gt(e){return typeof e=="object"&&e!==null}function yl(e){return Dn(e.target.files).map(function(t){return It(t)})}function vl(e){return at(this,void 0,void 0,function(){var t;return ot(this,function(r){switch(r.label){case 0:return[4,Promise.all(e.map(function(s){return s.getFile()}))];case 1:return t=r.sent(),[2,t.map(function(s){return It(s)})]}})})}function jl(e,t){return at(this,void 0,void 0,function(){var r,s;return ot(this,function(a){switch(a.label){case 0:return e.items?(r=Dn(e.items).filter(function(o){return o.kind==="file"}),t!=="drop"?[2,r]:[4,Promise.all(r.map(bl))]):[3,2];case 1:return s=a.sent(),[2,Or(da(s))];case 2:return[2,Or(Dn(e.files).map(function(o){return It(o)}))]}})})}function Or(e){return e.filter(function(t){return gl.indexOf(t.name)===-1})}function Dn(e){if(e===null)return[];for(var t=[],r=0;r<e.length;r++){var s=e[r];t.push(s)}return t}function bl(e){if(typeof e.webkitGetAsEntry!="function")return Ar(e);var t=e.webkitGetAsEntry();return t&&t.isDirectory?ua(t):Ar(e)}function da(e){return e.reduce(function(t,r){return Zn(Zn([],er(t),!1),er(Array.isArray(r)?da(r):[r]),!1)},[])}function Ar(e){var t=e.getAsFile();if(!t)return Promise.reject("".concat(e," is not a File"));var r=It(t);return Promise.resolve(r)}function Cl(e){return at(this,void 0,void 0,function(){return ot(this,function(t){return[2,e.isDirectory?ua(e):Dl(e)]})})}function ua(e){var t=e.createReader();return new Promise(function(r,s){var a=[];function o(){var i=this;t.readEntries(function(c){return at(i,void 0,void 0,function(){var l,d,y;return ot(this,function(g){switch(g.label){case 0:if(c.length)return[3,5];g.label=1;case 1:return g.trys.push([1,3,,4]),[4,Promise.all(a)];case 2:return l=g.sent(),r(l),[3,4];case 3:return d=g.sent(),s(d),[3,4];case 4:return[3,6];case 5:y=Promise.all(c.map(Cl)),a.push(y),o(),g.label=6;case 6:return[2]}})})},function(c){s(c)})}o()})}function Dl(e){return at(this,void 0,void 0,function(){return ot(this,function(t){return[2,new Promise(function(r,s){e.file(function(a){var o=It(a,e.fullPath);r(o)},function(a){s(a)})})]})})}var kt={},Pr;function Sl(){return Pr||(Pr=1,kt.__esModule=!0,kt.default=function(e,t){if(e&&t){var r=Array.isArray(t)?t:t.split(",");if(r.length===0)return!0;var s=e.name||"",a=(e.type||"").toLowerCase(),o=a.replace(/\/.*$/,"");return r.some(function(i){var c=i.trim().toLowerCase();return c.charAt(0)==="."?s.toLowerCase().endsWith(c):c.endsWith("/*")?o===c.replace(/\/.*$/,""):a===c})}return!0}),kt}var wl=Sl();const Il=so(wl);function Nr(e){return Ol(e)||El(e)||pa(e)||_l()}function _l(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
|
|
2
2
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function El(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function Ol(e){if(Array.isArray(e))return Sn(e)}function Tr(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,s)}return r}function kr(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?Tr(Object(r),!0).forEach(function(s){fa(e,s,r[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Tr(Object(r)).forEach(function(s){Object.defineProperty(e,s,Object.getOwnPropertyDescriptor(r,s))})}return e}function fa(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function vt(e,t){return Nl(e)||Pl(e,t)||pa(e,t)||Al()}function Al(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
3
3
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function pa(e,t){if(e){if(typeof e=="string")return Sn(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if(r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set")return Array.from(e);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return Sn(e,t)}}function Sn(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,s=new Array(t);r<t;r++)s[r]=e[r];return s}function Pl(e,t){var r=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(r!=null){var s=[],a=!0,o=!1,i,c;try{for(r=r.call(e);!(a=(i=r.next()).done)&&(s.push(i.value),!(t&&s.length===t));a=!0);}catch(l){o=!0,c=l}finally{try{!a&&r.return!=null&&r.return()}finally{if(o)throw c}}return s}}function Nl(e){if(Array.isArray(e))return e}var Tl="file-invalid-type",kl="file-too-large",$l="file-too-small",Fl="too-many-files",Ml=function(t){t=Array.isArray(t)&&t.length===1?t[0]:t;var r=Array.isArray(t)?"one of ".concat(t.join(", ")):t;return{code:Tl,message:"File type must be ".concat(r)}},$r=function(t){return{code:kl,message:"File is larger than ".concat(t," ").concat(t===1?"byte":"bytes")}},Fr=function(t){return{code:$l,message:"File is smaller than ".concat(t," ").concat(t===1?"byte":"bytes")}},Rl={code:Fl,message:"Too many files"};function ga(e,t){var r=e.type==="application/x-moz-file"||Il(e,t);return[r,r?null:Ml(t)]}function ma(e,t,r){if(Xe(e.size))if(Xe(t)&&Xe(r)){if(e.size>r)return[!1,$r(r)];if(e.size<t)return[!1,Fr(t)]}else{if(Xe(t)&&e.size<t)return[!1,Fr(t)];if(Xe(r)&&e.size>r)return[!1,$r(r)]}return[!0,null]}function Xe(e){return e!=null}function zl(e){var t=e.files,r=e.accept,s=e.minSize,a=e.maxSize,o=e.multiple,i=e.maxFiles,c=e.validator;return!o&&t.length>1||o&&i>=1&&t.length>i?!1:t.every(function(l){var d=ga(l,r),y=vt(d,1),g=y[0],m=ma(l,s,a),x=vt(m,1),f=x[0],u=c?c(l):null;return g&&f&&!u})}function qt(e){return typeof e.isPropagationStopped=="function"?e.isPropagationStopped():typeof e.cancelBubble<"u"?e.cancelBubble:!1}function $t(e){return e.dataTransfer?Array.prototype.some.call(e.dataTransfer.types,function(t){return t==="Files"||t==="application/x-moz-file"}):!!e.target&&!!e.target.files}function Mr(e){e.preventDefault()}function Ll(e){return e.indexOf("MSIE")!==-1||e.indexOf("Trident/")!==-1}function Bl(e){return e.indexOf("Edge/")!==-1}function Vl(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:window.navigator.userAgent;return Ll(e)||Bl(e)}function $e(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return function(s){for(var a=arguments.length,o=new Array(a>1?a-1:0),i=1;i<a;i++)o[i-1]=arguments[i];return t.some(function(c){return!qt(s)&&c&&c.apply(void 0,[s].concat(o)),qt(s)})}}function Ul(){return"showOpenFilePicker"in window}function Kl(e){if(Xe(e)){var t=Object.entries(e).filter(function(r){var s=vt(r,2),a=s[0],o=s[1],i=!0;return ha(a)||(console.warn('Skipped "'.concat(a,'" because it is not a valid MIME type. Check https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types for a list of valid MIME types.')),i=!1),(!Array.isArray(o)||!o.every(xa))&&(console.warn('Skipped "'.concat(a,'" because an invalid file extension was provided.')),i=!1),i}).reduce(function(r,s){var a=vt(s,2),o=a[0],i=a[1];return kr(kr({},r),{},fa({},o,i))},{});return[{description:"Files",accept:t}]}return e}function Hl(e){if(Xe(e))return Object.entries(e).reduce(function(t,r){var s=vt(r,2),a=s[0],o=s[1];return[].concat(Nr(t),[a],Nr(o))},[]).filter(function(t){return ha(t)||xa(t)}).join(",")}function Gl(e){return e instanceof DOMException&&(e.name==="AbortError"||e.code===e.ABORT_ERR)}function ql(e){return e instanceof DOMException&&(e.name==="SecurityError"||e.code===e.SECURITY_ERR)}function ha(e){return e==="audio/*"||e==="video/*"||e==="image/*"||e==="text/*"||/\w+\/[-+.\w]+/g.test(e)}function xa(e){return/^.*\.[\w]+$/.test(e)}var Wl=["children"],Yl=["open"],Ql=["refKey","role","onKeyDown","onFocus","onBlur","onClick","onDragEnter","onDragOver","onDragLeave","onDrop"],Jl=["refKey","onChange","onClick"];function Xl(e){return td(e)||ed(e)||ya(e)||Zl()}function Zl(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
|
|
4
4
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function ed(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function td(e){if(Array.isArray(e))return wn(e)}function gn(e,t){return sd(e)||rd(e,t)||ya(e,t)||nd()}function nd(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
5
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function ya(e,t){if(e){if(typeof e=="string")return wn(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if(r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set")return Array.from(e);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return wn(e,t)}}function wn(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,s=new Array(t);r<t;r++)s[r]=e[r];return s}function rd(e,t){var r=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(r!=null){var s=[],a=!0,o=!1,i,c;try{for(r=r.call(e);!(a=(i=r.next()).done)&&(s.push(i.value),!(t&&s.length===t));a=!0);}catch(l){o=!0,c=l}finally{try{!a&&r.return!=null&&r.return()}finally{if(o)throw c}}return s}}function sd(e){if(Array.isArray(e))return e}function Rr(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,s)}return r}function J(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?Rr(Object(r),!0).forEach(function(s){In(e,s,r[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Rr(Object(r)).forEach(function(s){Object.defineProperty(e,s,Object.getOwnPropertyDescriptor(r,s))})}return e}function In(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function Wt(e,t){if(e==null)return{};var r=ad(e,t),s,a;if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(a=0;a<o.length;a++)s=o[a],!(t.indexOf(s)>=0)&&Object.prototype.propertyIsEnumerable.call(e,s)&&(r[s]=e[s])}return r}function ad(e,t){if(e==null)return{};var r={},s=Object.keys(e),a,o;for(o=0;o<s.length;o++)a=s[o],!(t.indexOf(a)>=0)&&(r[a]=e[a]);return r}var Ln=p.forwardRef(function(e,t){var r=e.children,s=Wt(e,Wl),a=ja(s),o=a.open,i=Wt(a,Yl);return p.useImperativeHandle(t,function(){return{open:o}},[o]),k.createElement(p.Fragment,null,r(J(J({},i),{},{open:o})))});Ln.displayName="Dropzone";var va={disabled:!1,getFilesFromEvent:ml,maxSize:1/0,minSize:0,multiple:!0,maxFiles:0,preventDropOnDocument:!0,noClick:!1,noKeyboard:!1,noDrag:!1,noDragEventsBubbling:!1,validator:null,useFsAccessApi:!0,autoFocus:!1};Ln.defaultProps=va;Ln.propTypes={children:Y.func,accept:Y.objectOf(Y.arrayOf(Y.string)),multiple:Y.bool,preventDropOnDocument:Y.bool,noClick:Y.bool,noKeyboard:Y.bool,noDrag:Y.bool,noDragEventsBubbling:Y.bool,minSize:Y.number,maxSize:Y.number,maxFiles:Y.number,disabled:Y.bool,getFilesFromEvent:Y.func,onFileDialogCancel:Y.func,onFileDialogOpen:Y.func,useFsAccessApi:Y.bool,autoFocus:Y.bool,onDragEnter:Y.func,onDragLeave:Y.func,onDragOver:Y.func,onDrop:Y.func,onDropAccepted:Y.func,onDropRejected:Y.func,onError:Y.func,validator:Y.func};var _n={isFocused:!1,isFileDialogActive:!1,isDragActive:!1,isDragAccept:!1,isDragReject:!1,acceptedFiles:[],fileRejections:[]};function ja(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t=J(J({},va),e),r=t.accept,s=t.disabled,a=t.getFilesFromEvent,o=t.maxSize,i=t.minSize,c=t.multiple,l=t.maxFiles,d=t.onDragEnter,y=t.onDragLeave,g=t.onDragOver,m=t.onDrop,x=t.onDropAccepted,f=t.onDropRejected,u=t.onFileDialogCancel,j=t.onFileDialogOpen,v=t.useFsAccessApi,b=t.autoFocus,C=t.preventDropOnDocument,S=t.noClick,O=t.noKeyboard,_=t.noDrag,D=t.noDragEventsBubbling,E=t.onError,A=t.validator,M=p.useMemo(function(){return Hl(r)},[r]),h=p.useMemo(function(){return Kl(r)},[r]),T=p.useMemo(function(){return typeof j=="function"?j:zr},[j]),Q=p.useMemo(function(){return typeof u=="function"?u:zr},[u]),R=p.useRef(null),V=p.useRef(null),ue=p.useReducer(od,_n),le=gn(ue,2),ee=le[0],H=le[1],ye=ee.isFocused,L=ee.isFileDialogActive,se=p.useRef(typeof window<"u"&&window.isSecureContext&&v&&Ul()),me=function(){!se.current&&L&&setTimeout(function(){if(V.current){var P=V.current.files;P.length||(H({type:"closeDialog"}),Q())}},300)};p.useEffect(function(){return window.addEventListener("focus",me,!1),function(){window.removeEventListener("focus",me,!1)}},[V,L,Q,se]);var G=p.useRef([]),ve=function(P){R.current&&R.current.contains(P.target)||(P.preventDefault(),G.current=[])};p.useEffect(function(){return C&&(document.addEventListener("dragover",Mr,!1),document.addEventListener("drop",ve,!1)),function(){C&&(document.removeEventListener("dragover",Mr),document.removeEventListener("drop",ve))}},[R,C]),p.useEffect(function(){return!s&&b&&R.current&&R.current.focus(),function(){}},[R,b,s]);var ce=p.useCallback(function(w){E?E(w):console.error(w)},[E]),te=p.useCallback(function(w){w.preventDefault(),w.persist(),be(w),G.current=[].concat(Xl(G.current),[w.target]),$t(w)&&Promise.resolve(a(w)).then(function(P){if(!(qt(w)&&!D)){var Z=P.length,oe=Z>0&&zl({files:P,accept:M,minSize:i,maxSize:o,multiple:c,maxFiles:l,validator:A}),he=Z>0&&!oe;H({isDragAccept:oe,isDragReject:he,isDragActive:!0,type:"setDraggedFiles"}),d&&d(w)}}).catch(function(P){return ce(P)})},[a,d,ce,D,M,i,o,c,l,A]),N=p.useCallback(function(w){w.preventDefault(),w.persist(),be(w);var P=$t(w);if(P&&w.dataTransfer)try{w.dataTransfer.dropEffect="copy"}catch{}return P&&g&&g(w),!1},[g,D]),fe=p.useCallback(function(w){w.preventDefault(),w.persist(),be(w);var P=G.current.filter(function(oe){return R.current&&R.current.contains(oe)}),Z=P.indexOf(w.target);Z!==-1&&P.splice(Z,1),G.current=P,!(P.length>0)&&(H({type:"setDraggedFiles",isDragActive:!1,isDragAccept:!1,isDragReject:!1}),$t(w)&&y&&y(w))},[R,y,D]),ne=p.useCallback(function(w,P){var Z=[],oe=[];w.forEach(function(he){var Re=ga(he,M),Se=gn(Re,2),Ye=Se[0],Qe=Se[1],Ve=ma(he,i,o),et=gn(Ve,2),lt=et[0],dt=et[1],ut=A?A(he):null;if(Ye&<&&!ut)Z.push(he);else{var ft=[Qe,dt];ut&&(ft=ft.concat(ut)),oe.push({file:he,errors:ft.filter(function(Et){return Et})})}}),(!c&&Z.length>1||c&&l>=1&&Z.length>l)&&(Z.forEach(function(he){oe.push({file:he,errors:[Rl]})}),Z.splice(0)),H({acceptedFiles:Z,fileRejections:oe,type:"setFiles"}),m&&m(Z,oe,P),oe.length>0&&f&&f(oe,P),Z.length>0&&x&&x(Z,P)},[H,c,M,i,o,l,m,x,f,A]),K=p.useCallback(function(w){w.preventDefault(),w.persist(),be(w),G.current=[],$t(w)&&Promise.resolve(a(w)).then(function(P){qt(w)&&!D||ne(P,w)}).catch(function(P){return ce(P)}),H({type:"reset"})},[a,ne,ce,D]),I=p.useCallback(function(){if(se.current){H({type:"openDialog"}),T();var w={multiple:c,types:h};window.showOpenFilePicker(w).then(function(P){return a(P)}).then(function(P){ne(P,null),H({type:"closeDialog"})}).catch(function(P){Gl(P)?(Q(P),H({type:"closeDialog"})):ql(P)?(se.current=!1,V.current?(V.current.value=null,V.current.click()):ce(new Error("Cannot open the file picker because the https://developer.mozilla.org/en-US/docs/Web/API/File_System_Access_API is not supported and no <input> was provided."))):ce(P)});return}V.current&&(H({type:"openDialog"}),T(),V.current.value=null,V.current.click())},[H,T,Q,v,ne,ce,h,c]),U=p.useCallback(function(w){!R.current||!R.current.isEqualNode(w.target)||(w.key===" "||w.key==="Enter"||w.keyCode===32||w.keyCode===13)&&(w.preventDefault(),I())},[R,I]),W=p.useCallback(function(){H({type:"focus"})},[]),re=p.useCallback(function(){H({type:"blur"})},[]),pe=p.useCallback(function(){S||(Vl()?setTimeout(I,0):I())},[S,I]),de=function(P){return s?null:P},je=function(P){return O?null:de(P)},ge=function(P){return _?null:de(P)},be=function(P){D&&P.stopPropagation()},ae=p.useMemo(function(){return function(){var w=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},P=w.refKey,Z=P===void 0?"ref":P,oe=w.role,he=w.onKeyDown,Re=w.onFocus,Se=w.onBlur,Ye=w.onClick,Qe=w.onDragEnter,Ve=w.onDragOver,et=w.onDragLeave,lt=w.onDrop,dt=Wt(w,Ql);return J(J(In({onKeyDown:je($e(he,U)),onFocus:je($e(Re,W)),onBlur:je($e(Se,re)),onClick:de($e(Ye,pe)),onDragEnter:ge($e(Qe,te)),onDragOver:ge($e(Ve,N)),onDragLeave:ge($e(et,fe)),onDrop:ge($e(lt,K)),role:typeof oe=="string"&&oe!==""?oe:"presentation"},Z,R),!s&&!O?{tabIndex:0}:{}),dt)}},[R,U,W,re,pe,te,N,fe,K,O,_,s]),Me=p.useCallback(function(w){w.stopPropagation()},[]),ct=p.useMemo(function(){return function(){var w=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},P=w.refKey,Z=P===void 0?"ref":P,oe=w.onChange,he=w.onClick,Re=Wt(w,Jl),Se=In({accept:M,multiple:c,type:"file",style:{display:"none"},onChange:de($e(oe,K)),onClick:de($e(he,Me)),tabIndex:-1},Z,V);return J(J({},Se),Re)}},[V,r,c,K,s]);return J(J({},ee),{},{isFocused:ye&&!s,getRootProps:ae,getInputProps:ct,rootRef:R,inputRef:V,open:de(I)})}function od(e,t){switch(t.type){case"focus":return J(J({},e),{},{isFocused:!0});case"blur":return J(J({},e),{},{isFocused:!1});case"openDialog":return J(J({},_n),{},{isFileDialogActive:!0});case"closeDialog":return J(J({},e),{},{isFileDialogActive:!1});case"setDraggedFiles":return J(J({},e),{},{isDragActive:t.isDragActive,isDragAccept:t.isDragAccept,isDragReject:t.isDragReject});case"setFiles":return J(J({},e),{},{acceptedFiles:t.acceptedFiles,fileRejections:t.fileRejections});case"reset":return J({},_n);default:return e}}function zr(){}const[id,cd]=ms("Dropzone component was not found in tree");var Lr=Object.getOwnPropertySymbols,ld=Object.prototype.hasOwnProperty,dd=Object.prototype.propertyIsEnumerable,ud=(e,t)=>{var r={};for(var s in e)ld.call(e,s)&&t.indexOf(s)<0&&(r[s]=e[s]);if(e!=null&&Lr)for(var s of Lr(e))t.indexOf(s)<0&&dd.call(e,s)&&(r[s]=e[s]);return r};function Bn(e){const t=r=>{const s=qe(`Dropzone${mr(e)}`,{},r),{children:a}=s,o=ud(s,["children"]),i=cd(),c=ao(a)?a:k.createElement("span",null,a);return i[e]?p.cloneElement(c,o):null};return t.displayName=`@mantine/dropzone/${mr(e)}`,t}const fd=Bn("accept"),pd=Bn("reject"),gd=Bn("idle");var md=Object.defineProperty,hd=Object.defineProperties,xd=Object.getOwnPropertyDescriptors,Br=Object.getOwnPropertySymbols,yd=Object.prototype.hasOwnProperty,vd=Object.prototype.propertyIsEnumerable,Vr=(e,t,r)=>t in e?md(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Ur=(e,t)=>{for(var r in t||(t={}))yd.call(t,r)&&Vr(e,r,t[r]);if(Br)for(var r of Br(t))vd.call(t,r)&&Vr(e,r,t[r]);return e},jd=(e,t)=>hd(e,xd(t)),bd=Ge((e,{padding:t,radius:r})=>{const s=e.fn.variant({color:"red",variant:"light"}),a=e.fn.variant({color:e.primaryColor,variant:"light"});return{root:jd(Ur(Ur({},e.fn.fontStyles()),e.fn.focusStyles()),{boxSizing:"border-box",backgroundColor:e.colorScheme==="dark"?e.colors.dark[6]:e.white,border:`${$(2)} dashed ${e.colorScheme==="dark"?e.colors.dark[4]:e.colors.gray[4]}`,padding:Ie({size:t,sizes:e.spacing}),borderRadius:e.fn.radius(r),cursor:"pointer",userSelect:"none",transition:"background-color 150ms ease",position:"relative","&:hover":{backgroundColor:e.colorScheme==="dark"?e.colors.dark[5]:e.colors.gray[0]},"&[data-loading]":{cursor:"default","&:hover":{backgroundColor:e.colorScheme==="dark"?e.colors.dark[6]:e.white}},"&[data-accept]":{backgroundColor:e.colorScheme==="dark"?a.background:e.colors[e.primaryColor][0],borderColor:e.colorScheme==="dark"?a.border:e.colors[e.primaryColor][4],"&:hover":{backgroundColor:e.colorScheme==="dark"?a.background:e.colors[e.primaryColor][0]}},"&[data-reject]":{backgroundColor:e.colorScheme==="dark"?s.background:e.colors.red[0],borderColor:e.colorScheme==="dark"?s.border:e.colors.red[4],"&:hover":{backgroundColor:e.colorScheme==="dark"?s.background:e.colors.red[0]}}}),inner:{pointerEvents:"none",userSelect:"none"}}}),Cd=Object.defineProperty,Dd=Object.defineProperties,Sd=Object.getOwnPropertyDescriptors,Yt=Object.getOwnPropertySymbols,ba=Object.prototype.hasOwnProperty,Ca=Object.prototype.propertyIsEnumerable,Kr=(e,t,r)=>t in e?Cd(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,pt=(e,t)=>{for(var r in t||(t={}))ba.call(t,r)&&Kr(e,r,t[r]);if(Yt)for(var r of Yt(t))Ca.call(t,r)&&Kr(e,r,t[r]);return e},mn=(e,t)=>Dd(e,Sd(t)),wd=(e,t)=>{var r={};for(var s in e)ba.call(e,s)&&t.indexOf(s)<0&&(r[s]=e[s]);if(e!=null&&Yt)for(var s of Yt(e))t.indexOf(s)<0&&Ca.call(e,s)&&(r[s]=e[s]);return r};const Id={padding:"md",loading:!1,multiple:!0,maxSize:1/0,autoFocus:!1,activateOnClick:!0,activateOnDrag:!0,dragEventsBubbling:!0,activateOnKeyboard:!0,useFsAccessApi:!0};function it(e){const t=qe("Dropzone",Id,e),{className:r,padding:s,radius:a,disabled:o,classNames:i,styles:c,loading:l,multiple:d,maxSize:y,accept:g,children:m,onDropAny:x,onDrop:f,onReject:u,openRef:j,name:v,unstyled:b,maxFiles:C,autoFocus:S,activateOnClick:O,activateOnDrag:_,dragEventsBubbling:D,activateOnKeyboard:E,onDragEnter:A,onDragLeave:M,onDragOver:h,onFileDialogCancel:T,onFileDialogOpen:Q,preventDropOnDocument:R,useFsAccessApi:V,getFilesFromEvent:ue,validator:le,variant:ee}=t,H=wd(t,["className","padding","radius","disabled","classNames","styles","loading","multiple","maxSize","accept","children","onDropAny","onDrop","onReject","openRef","name","unstyled","maxFiles","autoFocus","activateOnClick","activateOnDrag","dragEventsBubbling","activateOnKeyboard","onDragEnter","onDragLeave","onDragOver","onFileDialogCancel","onFileDialogOpen","preventDropOnDocument","useFsAccessApi","getFilesFromEvent","validator","variant"]),{classes:ye,cx:L}=bd({radius:a,padding:s},{name:"Dropzone",classNames:i,styles:c,unstyled:b,variant:ee}),{getRootProps:se,getInputProps:me,isDragAccept:G,isDragReject:ve,open:ce}=ja(pt({onDrop:x,onDropAccepted:f,onDropRejected:u,disabled:o||l,accept:Array.isArray(g)?g.reduce((N,fe)=>mn(pt({},N),{[fe]:[]}),{}):g,multiple:d,maxSize:y,maxFiles:C,autoFocus:S,noClick:!O,noDrag:!_,noDragEventsBubbling:!D,noKeyboard:!E,onDragEnter:A,onDragLeave:M,onDragOver:h,onFileDialogCancel:T,onFileDialogOpen:Q,preventDropOnDocument:R,useFsAccessApi:V,validator:le},ue?{getFilesFromEvent:ue}:null));us(j,ce);const te=!G&&!ve;return k.createElement(id,{value:{accept:G,reject:ve,idle:te}},k.createElement(We,mn(pt(pt({},H),se()),{"data-accept":G||void 0,"data-reject":ve||void 0,"data-idle":te||void 0,"data-loading":l||void 0,className:L(ye.root,r)}),k.createElement(oa,{visible:l,radius:a,unstyled:b}),k.createElement("input",mn(pt({},me()),{name:v})),k.createElement("div",{className:ye.inner},m)))}it.displayName="@mantine/dropzone/Dropzone";it.Accept=fd;it.Reject=pd;it.Idle=gd;const Da=it;var _d=Object.defineProperty,Ed=Object.defineProperties,Od=Object.getOwnPropertyDescriptors,Hr=Object.getOwnPropertySymbols,Ad=Object.prototype.hasOwnProperty,Pd=Object.prototype.propertyIsEnumerable,Gr=(e,t,r)=>t in e?_d(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Nd=(e,t)=>{for(var r in t||(t={}))Ad.call(t,r)&&Gr(e,r,t[r]);if(Hr)for(var r of Hr(t))Pd.call(t,r)&&Gr(e,r,t[r]);return e},Td=(e,t)=>Ed(e,Od(t)),kd=Ge(e=>({wrapper:Td(Nd({},e.fn.cover(0)),{position:"fixed",backgroundColor:e.colorScheme==="dark"?e.colors.dark[7]:e.white,display:"flex",padding:e.spacing.xs,transition:"opacity 100ms ease"}),dropzone:{flex:1}})),$d=Object.defineProperty,Fd=Object.defineProperties,Md=Object.getOwnPropertyDescriptors,Qt=Object.getOwnPropertySymbols,Sa=Object.prototype.hasOwnProperty,wa=Object.prototype.propertyIsEnumerable,qr=(e,t,r)=>t in e?$d(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,hn=(e,t)=>{for(var r in t||(t={}))Sa.call(t,r)&&qr(e,r,t[r]);if(Qt)for(var r of Qt(t))wa.call(t,r)&&qr(e,r,t[r]);return e},xn=(e,t)=>Fd(e,Md(t)),Rd=(e,t)=>{var r={};for(var s in e)Sa.call(e,s)&&t.indexOf(s)<0&&(r[s]=e[s]);if(e!=null&&Qt)for(var s of Qt(e))t.indexOf(s)<0&&wa.call(e,s)&&(r[s]=e[s]);return r};const zd={padding:"md",loading:!1,multiple:!0,maxSize:1/0,autoFocus:!1,activateOnClick:!0,activateOnDrag:!0,dragEventsBubbling:!0,activateOnKeyboard:!0,active:!0,zIndex:fs("max"),withinPortal:!0};function Ia(e){const t=qe("DropzoneFullScreen",zd,e),{classNames:r,styles:s,sx:a,className:o,style:i,unstyled:c,active:l,onDrop:d,onReject:y,zIndex:g,withinPortal:m,portalProps:x}=t,f=Rd(t,["classNames","styles","sx","className","style","unstyled","active","onDrop","onReject","zIndex","withinPortal","portalProps"]),[u,j]=k.useState(0),[v,{open:b,close:C}]=xt(!1),{classes:S,cx:O}=kd(null,{name:"DropzoneFullScreen",classNames:r,styles:s,unstyled:c}),_=E=>{E.dataTransfer.types.includes("Files")&&(j(A=>A+1),b())},D=()=>{j(E=>E-1)};return p.useEffect(()=>{u===0&&C()},[u]),p.useEffect(()=>{if(l)return document.addEventListener("dragenter",_,!1),document.addEventListener("dragleave",D,!1),()=>{document.removeEventListener("dragenter",_,!1),document.removeEventListener("dragleave",D,!1)}},[l]),k.createElement(oo,xn(hn({},x),{withinPortal:m}),k.createElement(We,{className:O(S.wrapper,o),sx:a,style:xn(hn({},i),{opacity:v?1:0,pointerEvents:v?"all":"none",zIndex:g})},k.createElement(it,xn(hn({},f),{classNames:r,styles:s,unstyled:c,className:S.dropzone,onDrop:E=>{d?.(E),C()},onReject:E=>{y?.(E),C()}}))))}Ia.displayName="@mantine/dropzone/DropzoneFullScreen";Da.FullScreen=Ia;const Ld=Da,Bd=({children:e,chargeId:t})=>{const{uploading:r,uploadMultipleDocuments:s}=io();function a(o){F.error("Error",{description:o,duration:5e3})}return n.jsx(Ld,{onDrop:o=>s({documents:o,chargeId:t,isSensitive:!1}),onReject:o=>a(`Rejected Files:
|
|
5
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function ya(e,t){if(e){if(typeof e=="string")return wn(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if(r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set")return Array.from(e);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return wn(e,t)}}function wn(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,s=new Array(t);r<t;r++)s[r]=e[r];return s}function rd(e,t){var r=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(r!=null){var s=[],a=!0,o=!1,i,c;try{for(r=r.call(e);!(a=(i=r.next()).done)&&(s.push(i.value),!(t&&s.length===t));a=!0);}catch(l){o=!0,c=l}finally{try{!a&&r.return!=null&&r.return()}finally{if(o)throw c}}return s}}function sd(e){if(Array.isArray(e))return e}function Rr(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,s)}return r}function J(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?Rr(Object(r),!0).forEach(function(s){In(e,s,r[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Rr(Object(r)).forEach(function(s){Object.defineProperty(e,s,Object.getOwnPropertyDescriptor(r,s))})}return e}function In(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function Wt(e,t){if(e==null)return{};var r=ad(e,t),s,a;if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(a=0;a<o.length;a++)s=o[a],!(t.indexOf(s)>=0)&&Object.prototype.propertyIsEnumerable.call(e,s)&&(r[s]=e[s])}return r}function ad(e,t){if(e==null)return{};var r={},s=Object.keys(e),a,o;for(o=0;o<s.length;o++)a=s[o],!(t.indexOf(a)>=0)&&(r[a]=e[a]);return r}var Ln=p.forwardRef(function(e,t){var r=e.children,s=Wt(e,Wl),a=ja(s),o=a.open,i=Wt(a,Yl);return p.useImperativeHandle(t,function(){return{open:o}},[o]),k.createElement(p.Fragment,null,r(J(J({},i),{},{open:o})))});Ln.displayName="Dropzone";var va={disabled:!1,getFilesFromEvent:ml,maxSize:1/0,minSize:0,multiple:!0,maxFiles:0,preventDropOnDocument:!0,noClick:!1,noKeyboard:!1,noDrag:!1,noDragEventsBubbling:!1,validator:null,useFsAccessApi:!0,autoFocus:!1};Ln.defaultProps=va;Ln.propTypes={children:Y.func,accept:Y.objectOf(Y.arrayOf(Y.string)),multiple:Y.bool,preventDropOnDocument:Y.bool,noClick:Y.bool,noKeyboard:Y.bool,noDrag:Y.bool,noDragEventsBubbling:Y.bool,minSize:Y.number,maxSize:Y.number,maxFiles:Y.number,disabled:Y.bool,getFilesFromEvent:Y.func,onFileDialogCancel:Y.func,onFileDialogOpen:Y.func,useFsAccessApi:Y.bool,autoFocus:Y.bool,onDragEnter:Y.func,onDragLeave:Y.func,onDragOver:Y.func,onDrop:Y.func,onDropAccepted:Y.func,onDropRejected:Y.func,onError:Y.func,validator:Y.func};var _n={isFocused:!1,isFileDialogActive:!1,isDragActive:!1,isDragAccept:!1,isDragReject:!1,acceptedFiles:[],fileRejections:[]};function ja(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t=J(J({},va),e),r=t.accept,s=t.disabled,a=t.getFilesFromEvent,o=t.maxSize,i=t.minSize,c=t.multiple,l=t.maxFiles,d=t.onDragEnter,y=t.onDragLeave,g=t.onDragOver,m=t.onDrop,x=t.onDropAccepted,f=t.onDropRejected,u=t.onFileDialogCancel,j=t.onFileDialogOpen,v=t.useFsAccessApi,b=t.autoFocus,C=t.preventDropOnDocument,S=t.noClick,O=t.noKeyboard,_=t.noDrag,D=t.noDragEventsBubbling,E=t.onError,A=t.validator,M=p.useMemo(function(){return Hl(r)},[r]),h=p.useMemo(function(){return Kl(r)},[r]),T=p.useMemo(function(){return typeof j=="function"?j:zr},[j]),Q=p.useMemo(function(){return typeof u=="function"?u:zr},[u]),R=p.useRef(null),V=p.useRef(null),ue=p.useReducer(od,_n),le=gn(ue,2),ee=le[0],H=le[1],ye=ee.isFocused,B=ee.isFileDialogActive,se=p.useRef(typeof window<"u"&&window.isSecureContext&&v&&Ul()),me=function(){!se.current&&B&&setTimeout(function(){if(V.current){var P=V.current.files;P.length||(H({type:"closeDialog"}),Q())}},300)};p.useEffect(function(){return window.addEventListener("focus",me,!1),function(){window.removeEventListener("focus",me,!1)}},[V,B,Q,se]);var G=p.useRef([]),ve=function(P){R.current&&R.current.contains(P.target)||(P.preventDefault(),G.current=[])};p.useEffect(function(){return C&&(document.addEventListener("dragover",Mr,!1),document.addEventListener("drop",ve,!1)),function(){C&&(document.removeEventListener("dragover",Mr),document.removeEventListener("drop",ve))}},[R,C]),p.useEffect(function(){return!s&&b&&R.current&&R.current.focus(),function(){}},[R,b,s]);var ce=p.useCallback(function(w){E?E(w):console.error(w)},[E]),te=p.useCallback(function(w){w.preventDefault(),w.persist(),be(w),G.current=[].concat(Xl(G.current),[w.target]),$t(w)&&Promise.resolve(a(w)).then(function(P){if(!(qt(w)&&!D)){var Z=P.length,oe=Z>0&&zl({files:P,accept:M,minSize:i,maxSize:o,multiple:c,maxFiles:l,validator:A}),he=Z>0&&!oe;H({isDragAccept:oe,isDragReject:he,isDragActive:!0,type:"setDraggedFiles"}),d&&d(w)}}).catch(function(P){return ce(P)})},[a,d,ce,D,M,i,o,c,l,A]),N=p.useCallback(function(w){w.preventDefault(),w.persist(),be(w);var P=$t(w);if(P&&w.dataTransfer)try{w.dataTransfer.dropEffect="copy"}catch{}return P&&g&&g(w),!1},[g,D]),fe=p.useCallback(function(w){w.preventDefault(),w.persist(),be(w);var P=G.current.filter(function(oe){return R.current&&R.current.contains(oe)}),Z=P.indexOf(w.target);Z!==-1&&P.splice(Z,1),G.current=P,!(P.length>0)&&(H({type:"setDraggedFiles",isDragActive:!1,isDragAccept:!1,isDragReject:!1}),$t(w)&&y&&y(w))},[R,y,D]),ne=p.useCallback(function(w,P){var Z=[],oe=[];w.forEach(function(he){var Re=ga(he,M),Se=gn(Re,2),Ye=Se[0],Qe=Se[1],Ve=ma(he,i,o),et=gn(Ve,2),lt=et[0],dt=et[1],ut=A?A(he):null;if(Ye&<&&!ut)Z.push(he);else{var ft=[Qe,dt];ut&&(ft=ft.concat(ut)),oe.push({file:he,errors:ft.filter(function(Et){return Et})})}}),(!c&&Z.length>1||c&&l>=1&&Z.length>l)&&(Z.forEach(function(he){oe.push({file:he,errors:[Rl]})}),Z.splice(0)),H({acceptedFiles:Z,fileRejections:oe,type:"setFiles"}),m&&m(Z,oe,P),oe.length>0&&f&&f(oe,P),Z.length>0&&x&&x(Z,P)},[H,c,M,i,o,l,m,x,f,A]),K=p.useCallback(function(w){w.preventDefault(),w.persist(),be(w),G.current=[],$t(w)&&Promise.resolve(a(w)).then(function(P){qt(w)&&!D||ne(P,w)}).catch(function(P){return ce(P)}),H({type:"reset"})},[a,ne,ce,D]),I=p.useCallback(function(){if(se.current){H({type:"openDialog"}),T();var w={multiple:c,types:h};window.showOpenFilePicker(w).then(function(P){return a(P)}).then(function(P){ne(P,null),H({type:"closeDialog"})}).catch(function(P){Gl(P)?(Q(P),H({type:"closeDialog"})):ql(P)?(se.current=!1,V.current?(V.current.value=null,V.current.click()):ce(new Error("Cannot open the file picker because the https://developer.mozilla.org/en-US/docs/Web/API/File_System_Access_API is not supported and no <input> was provided."))):ce(P)});return}V.current&&(H({type:"openDialog"}),T(),V.current.value=null,V.current.click())},[H,T,Q,v,ne,ce,h,c]),U=p.useCallback(function(w){!R.current||!R.current.isEqualNode(w.target)||(w.key===" "||w.key==="Enter"||w.keyCode===32||w.keyCode===13)&&(w.preventDefault(),I())},[R,I]),W=p.useCallback(function(){H({type:"focus"})},[]),re=p.useCallback(function(){H({type:"blur"})},[]),pe=p.useCallback(function(){S||(Vl()?setTimeout(I,0):I())},[S,I]),de=function(P){return s?null:P},je=function(P){return O?null:de(P)},ge=function(P){return _?null:de(P)},be=function(P){D&&P.stopPropagation()},ae=p.useMemo(function(){return function(){var w=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},P=w.refKey,Z=P===void 0?"ref":P,oe=w.role,he=w.onKeyDown,Re=w.onFocus,Se=w.onBlur,Ye=w.onClick,Qe=w.onDragEnter,Ve=w.onDragOver,et=w.onDragLeave,lt=w.onDrop,dt=Wt(w,Ql);return J(J(In({onKeyDown:je($e(he,U)),onFocus:je($e(Re,W)),onBlur:je($e(Se,re)),onClick:de($e(Ye,pe)),onDragEnter:ge($e(Qe,te)),onDragOver:ge($e(Ve,N)),onDragLeave:ge($e(et,fe)),onDrop:ge($e(lt,K)),role:typeof oe=="string"&&oe!==""?oe:"presentation"},Z,R),!s&&!O?{tabIndex:0}:{}),dt)}},[R,U,W,re,pe,te,N,fe,K,O,_,s]),Me=p.useCallback(function(w){w.stopPropagation()},[]),ct=p.useMemo(function(){return function(){var w=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},P=w.refKey,Z=P===void 0?"ref":P,oe=w.onChange,he=w.onClick,Re=Wt(w,Jl),Se=In({accept:M,multiple:c,type:"file",style:{display:"none"},onChange:de($e(oe,K)),onClick:de($e(he,Me)),tabIndex:-1},Z,V);return J(J({},Se),Re)}},[V,r,c,K,s]);return J(J({},ee),{},{isFocused:ye&&!s,getRootProps:ae,getInputProps:ct,rootRef:R,inputRef:V,open:de(I)})}function od(e,t){switch(t.type){case"focus":return J(J({},e),{},{isFocused:!0});case"blur":return J(J({},e),{},{isFocused:!1});case"openDialog":return J(J({},_n),{},{isFileDialogActive:!0});case"closeDialog":return J(J({},e),{},{isFileDialogActive:!1});case"setDraggedFiles":return J(J({},e),{},{isDragActive:t.isDragActive,isDragAccept:t.isDragAccept,isDragReject:t.isDragReject});case"setFiles":return J(J({},e),{},{acceptedFiles:t.acceptedFiles,fileRejections:t.fileRejections});case"reset":return J({},_n);default:return e}}function zr(){}const[id,cd]=ms("Dropzone component was not found in tree");var Lr=Object.getOwnPropertySymbols,ld=Object.prototype.hasOwnProperty,dd=Object.prototype.propertyIsEnumerable,ud=(e,t)=>{var r={};for(var s in e)ld.call(e,s)&&t.indexOf(s)<0&&(r[s]=e[s]);if(e!=null&&Lr)for(var s of Lr(e))t.indexOf(s)<0&&dd.call(e,s)&&(r[s]=e[s]);return r};function Bn(e){const t=r=>{const s=qe(`Dropzone${mr(e)}`,{},r),{children:a}=s,o=ud(s,["children"]),i=cd(),c=ao(a)?a:k.createElement("span",null,a);return i[e]?p.cloneElement(c,o):null};return t.displayName=`@mantine/dropzone/${mr(e)}`,t}const fd=Bn("accept"),pd=Bn("reject"),gd=Bn("idle");var md=Object.defineProperty,hd=Object.defineProperties,xd=Object.getOwnPropertyDescriptors,Br=Object.getOwnPropertySymbols,yd=Object.prototype.hasOwnProperty,vd=Object.prototype.propertyIsEnumerable,Vr=(e,t,r)=>t in e?md(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Ur=(e,t)=>{for(var r in t||(t={}))yd.call(t,r)&&Vr(e,r,t[r]);if(Br)for(var r of Br(t))vd.call(t,r)&&Vr(e,r,t[r]);return e},jd=(e,t)=>hd(e,xd(t)),bd=Ge((e,{padding:t,radius:r})=>{const s=e.fn.variant({color:"red",variant:"light"}),a=e.fn.variant({color:e.primaryColor,variant:"light"});return{root:jd(Ur(Ur({},e.fn.fontStyles()),e.fn.focusStyles()),{boxSizing:"border-box",backgroundColor:e.colorScheme==="dark"?e.colors.dark[6]:e.white,border:`${$(2)} dashed ${e.colorScheme==="dark"?e.colors.dark[4]:e.colors.gray[4]}`,padding:Ie({size:t,sizes:e.spacing}),borderRadius:e.fn.radius(r),cursor:"pointer",userSelect:"none",transition:"background-color 150ms ease",position:"relative","&:hover":{backgroundColor:e.colorScheme==="dark"?e.colors.dark[5]:e.colors.gray[0]},"&[data-loading]":{cursor:"default","&:hover":{backgroundColor:e.colorScheme==="dark"?e.colors.dark[6]:e.white}},"&[data-accept]":{backgroundColor:e.colorScheme==="dark"?a.background:e.colors[e.primaryColor][0],borderColor:e.colorScheme==="dark"?a.border:e.colors[e.primaryColor][4],"&:hover":{backgroundColor:e.colorScheme==="dark"?a.background:e.colors[e.primaryColor][0]}},"&[data-reject]":{backgroundColor:e.colorScheme==="dark"?s.background:e.colors.red[0],borderColor:e.colorScheme==="dark"?s.border:e.colors.red[4],"&:hover":{backgroundColor:e.colorScheme==="dark"?s.background:e.colors.red[0]}}}),inner:{pointerEvents:"none",userSelect:"none"}}}),Cd=Object.defineProperty,Dd=Object.defineProperties,Sd=Object.getOwnPropertyDescriptors,Yt=Object.getOwnPropertySymbols,ba=Object.prototype.hasOwnProperty,Ca=Object.prototype.propertyIsEnumerable,Kr=(e,t,r)=>t in e?Cd(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,pt=(e,t)=>{for(var r in t||(t={}))ba.call(t,r)&&Kr(e,r,t[r]);if(Yt)for(var r of Yt(t))Ca.call(t,r)&&Kr(e,r,t[r]);return e},mn=(e,t)=>Dd(e,Sd(t)),wd=(e,t)=>{var r={};for(var s in e)ba.call(e,s)&&t.indexOf(s)<0&&(r[s]=e[s]);if(e!=null&&Yt)for(var s of Yt(e))t.indexOf(s)<0&&Ca.call(e,s)&&(r[s]=e[s]);return r};const Id={padding:"md",loading:!1,multiple:!0,maxSize:1/0,autoFocus:!1,activateOnClick:!0,activateOnDrag:!0,dragEventsBubbling:!0,activateOnKeyboard:!0,useFsAccessApi:!0};function it(e){const t=qe("Dropzone",Id,e),{className:r,padding:s,radius:a,disabled:o,classNames:i,styles:c,loading:l,multiple:d,maxSize:y,accept:g,children:m,onDropAny:x,onDrop:f,onReject:u,openRef:j,name:v,unstyled:b,maxFiles:C,autoFocus:S,activateOnClick:O,activateOnDrag:_,dragEventsBubbling:D,activateOnKeyboard:E,onDragEnter:A,onDragLeave:M,onDragOver:h,onFileDialogCancel:T,onFileDialogOpen:Q,preventDropOnDocument:R,useFsAccessApi:V,getFilesFromEvent:ue,validator:le,variant:ee}=t,H=wd(t,["className","padding","radius","disabled","classNames","styles","loading","multiple","maxSize","accept","children","onDropAny","onDrop","onReject","openRef","name","unstyled","maxFiles","autoFocus","activateOnClick","activateOnDrag","dragEventsBubbling","activateOnKeyboard","onDragEnter","onDragLeave","onDragOver","onFileDialogCancel","onFileDialogOpen","preventDropOnDocument","useFsAccessApi","getFilesFromEvent","validator","variant"]),{classes:ye,cx:B}=bd({radius:a,padding:s},{name:"Dropzone",classNames:i,styles:c,unstyled:b,variant:ee}),{getRootProps:se,getInputProps:me,isDragAccept:G,isDragReject:ve,open:ce}=ja(pt({onDrop:x,onDropAccepted:f,onDropRejected:u,disabled:o||l,accept:Array.isArray(g)?g.reduce((N,fe)=>mn(pt({},N),{[fe]:[]}),{}):g,multiple:d,maxSize:y,maxFiles:C,autoFocus:S,noClick:!O,noDrag:!_,noDragEventsBubbling:!D,noKeyboard:!E,onDragEnter:A,onDragLeave:M,onDragOver:h,onFileDialogCancel:T,onFileDialogOpen:Q,preventDropOnDocument:R,useFsAccessApi:V,validator:le},ue?{getFilesFromEvent:ue}:null));us(j,ce);const te=!G&&!ve;return k.createElement(id,{value:{accept:G,reject:ve,idle:te}},k.createElement(We,mn(pt(pt({},H),se()),{"data-accept":G||void 0,"data-reject":ve||void 0,"data-idle":te||void 0,"data-loading":l||void 0,className:B(ye.root,r)}),k.createElement(oa,{visible:l,radius:a,unstyled:b}),k.createElement("input",mn(pt({},me()),{name:v})),k.createElement("div",{className:ye.inner},m)))}it.displayName="@mantine/dropzone/Dropzone";it.Accept=fd;it.Reject=pd;it.Idle=gd;const Da=it;var _d=Object.defineProperty,Ed=Object.defineProperties,Od=Object.getOwnPropertyDescriptors,Hr=Object.getOwnPropertySymbols,Ad=Object.prototype.hasOwnProperty,Pd=Object.prototype.propertyIsEnumerable,Gr=(e,t,r)=>t in e?_d(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Nd=(e,t)=>{for(var r in t||(t={}))Ad.call(t,r)&&Gr(e,r,t[r]);if(Hr)for(var r of Hr(t))Pd.call(t,r)&&Gr(e,r,t[r]);return e},Td=(e,t)=>Ed(e,Od(t)),kd=Ge(e=>({wrapper:Td(Nd({},e.fn.cover(0)),{position:"fixed",backgroundColor:e.colorScheme==="dark"?e.colors.dark[7]:e.white,display:"flex",padding:e.spacing.xs,transition:"opacity 100ms ease"}),dropzone:{flex:1}})),$d=Object.defineProperty,Fd=Object.defineProperties,Md=Object.getOwnPropertyDescriptors,Qt=Object.getOwnPropertySymbols,Sa=Object.prototype.hasOwnProperty,wa=Object.prototype.propertyIsEnumerable,qr=(e,t,r)=>t in e?$d(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,hn=(e,t)=>{for(var r in t||(t={}))Sa.call(t,r)&&qr(e,r,t[r]);if(Qt)for(var r of Qt(t))wa.call(t,r)&&qr(e,r,t[r]);return e},xn=(e,t)=>Fd(e,Md(t)),Rd=(e,t)=>{var r={};for(var s in e)Sa.call(e,s)&&t.indexOf(s)<0&&(r[s]=e[s]);if(e!=null&&Qt)for(var s of Qt(e))t.indexOf(s)<0&&wa.call(e,s)&&(r[s]=e[s]);return r};const zd={padding:"md",loading:!1,multiple:!0,maxSize:1/0,autoFocus:!1,activateOnClick:!0,activateOnDrag:!0,dragEventsBubbling:!0,activateOnKeyboard:!0,active:!0,zIndex:fs("max"),withinPortal:!0};function Ia(e){const t=qe("DropzoneFullScreen",zd,e),{classNames:r,styles:s,sx:a,className:o,style:i,unstyled:c,active:l,onDrop:d,onReject:y,zIndex:g,withinPortal:m,portalProps:x}=t,f=Rd(t,["classNames","styles","sx","className","style","unstyled","active","onDrop","onReject","zIndex","withinPortal","portalProps"]),[u,j]=k.useState(0),[v,{open:b,close:C}]=xt(!1),{classes:S,cx:O}=kd(null,{name:"DropzoneFullScreen",classNames:r,styles:s,unstyled:c}),_=E=>{E.dataTransfer.types.includes("Files")&&(j(A=>A+1),b())},D=()=>{j(E=>E-1)};return p.useEffect(()=>{u===0&&C()},[u]),p.useEffect(()=>{if(l)return document.addEventListener("dragenter",_,!1),document.addEventListener("dragleave",D,!1),()=>{document.removeEventListener("dragenter",_,!1),document.removeEventListener("dragleave",D,!1)}},[l]),k.createElement(oo,xn(hn({},x),{withinPortal:m}),k.createElement(We,{className:O(S.wrapper,o),sx:a,style:xn(hn({},i),{opacity:v?1:0,pointerEvents:v?"all":"none",zIndex:g})},k.createElement(it,xn(hn({},f),{classNames:r,styles:s,unstyled:c,className:S.dropzone,onDrop:E=>{d?.(E),C()},onReject:E=>{y?.(E),C()}}))))}Ia.displayName="@mantine/dropzone/DropzoneFullScreen";Da.FullScreen=Ia;const Ld=Da,Bd=({children:e,chargeId:t})=>{const{uploading:r,uploadMultipleDocuments:s}=io();function a(o){F.error("Error",{description:o,duration:5e3})}return n.jsx(Ld,{onDrop:o=>s({documents:o,chargeId:t,isSensitive:!1}),onReject:o=>a(`Rejected Files:
|
|
6
6
|
${o.map(i=>`"${i.file.name}": ${i.errors}`).join(`
|
|
7
|
-
`)}`),activateOnClick:!1,activateOnKeyboard:!1,radius:0,padding:0,maxFiles:1/0,loading:r,sx:()=>({border:0,cursor:"default",width:"100%",height:"100%",zIndex:1}),children:e})},an=({items:e,extraClassName:t=""})=>{const r=["text-sm font-medium text-gray-900 bg-white border border-gray-200 rounded-lg",t].join(" ");return n.jsx("ul",{className:r,children:e.map((s,a)=>{const o=["w-full px-4 py-2",a===e.length-1?"rounded-b-lg":"border-b",a===0?"rounded-t-lg":"","border-gray-200",s&&typeof s=="object"&&"extraClassName"in s?s.extraClassName??"":""].join(" ");return n.jsx("li",{className:o,children:s&&typeof s=="object"&&"content"in s?s.content:s},a)})})};function Wr({columns:e=5,rows:t=5,headerHeight:r="h-10",rowHeight:s="h-8",showHeader:a=!0,columnWidths:o,...i}){const c=o||Array(e).fill("flex-1");return n.jsxs("div",{className:"space-y-2",...i,children:[a&&n.jsx("div",{className:"flex gap-2 border-b pb-2",children:c.map((l,d)=>n.jsx(tr,{className:`${r} ${l}`},d))}),[...Array(t)].map((l,d)=>n.jsx("div",{className:"flex gap-2 border-b py-2",children:c.map((y,g)=>n.jsx(tr,{className:`${s} ${y}`},g))},d))]})}const Vd="mergeCharges",Ud=()=>{const[{fetching:e},t]=Ee(co),r=p.useCallback(async s=>{const a=`Error merging into charge ID [${s.baseChargeID}]`,o=`${Vd}-${s.baseChargeID}`;F.loading("Merging Charges",{id:o});try{const i=await t(s),c=Oe(i,a,o,"mergeCharges");if(c)return F.success("Success",{id:o,description:"Charges were merged"}),c.mergeCharges.charge}catch(i){console.error(`${a}: ${i}`),F.error("Error",{id:o,description:a,duration:1e5,closeButton:!0})}},[t]);return{fetching:e,mergeCharges:r}};function Kd({chargeIds:e,onDone:t,resetMerge:r}){const{mergeCharges:s,fetching:a}=Ud(),o=Array.from(new Set(e)),[{data:i,fetching:c}]=ke({query:lo,variables:{chargeIds:o}}),[l,d]=p.useState(i?.chargesByIDs[0]),[y,g]=p.useState(void 0),[m,x]=p.useState(void 0),[f,u]=p.useState(void 0),[j,v]=p.useState(void 0),[b,C]=p.useState(void 0),[S,O]=p.useState(void 0),[_,D]=p.useState(void 0),E=i?.chargesByIDs.length!==o.length&&"Some charges were not Found"||void 0,A=i?.chargesByIDs||[],M=p.useCallback(async()=>{if(!l){F.error("Error",{description:"No main charge selected"});return}if(o.length<2){F.error("Error",{description:"At least 2 charges are required to execute a merge"});return}let h;return y&&y.value!==l.userDescription&&(h??={},h={...h,userDescription:y.value}),m&&m.value!==l.owner.id&&(h??={},h={...h,ownerId:m.value}),b&&b.value!==l.conversion&&(h??={},h={...h,isConversion:b.value}),f&&f.value!==l.optionalVAT&&(h??={},h={...h,optionalVAT:f.value}),j&&j.value!==l.optionalDocuments&&(h??={},h={...h,optionalDocuments:j.value}),_&&_.value!==l.tags.map(T=>T.name).join(",")&&(h??={},h={...h,tags:_.value.split(",").filter(T=>T!=="").map(T=>({id:T}))}),S&&S.value!==l.isInvoicePaymentDifferentCurrency&&(h??={},h={...h,isInvoicePaymentDifferentCurrency:S.value}),await s({baseChargeID:l.id,chargeIdsToMerge:o.filter(T=>T!==l.id),fields:h}),r(),t()},[l,o,s,y,m,b,f,S,_,t,r]);return n.jsxs(n.Fragment,{children:[c&&n.jsx("div",{className:"flex flex-col text-center w-full mb-1",children:n.jsx(hs,{})}),!c&&E&&n.jsx("div",{className:"flex flex-col text-center w-full mb-1",children:n.jsx("h3",{className:"sm:text-2xl text-xl font-medium title-font mb-6 text-gray-900",children:E})}),!c&&!E&&n.jsxs(n.Fragment,{children:[n.jsxs("table",{children:[n.jsxs("tr",{children:[n.jsx("th",{children:"Main"}),A.map(h=>n.jsx("td",{children:n.jsx("div",{className:"flex items-center justify-center mx-2 px-2 py-2 border-2 border-b-0 rounded-t-xl",children:n.jsx(Ii,{checked:h.id===l?.id,size:"xl",onClick:()=>{d(h),g({id:h.id,value:h.userDescription??""}),x({id:h.id,value:h.owner.id}),u({id:h.id,value:h.optionalVAT??!1}),v({id:h.id,value:h.optionalDocuments??!1}),O({id:h.id,value:h.isInvoicePaymentDifferentCurrency??!1}),C({id:h.id,value:h.conversion??!1}),D({id:h.id,value:(h.tags.map(T=>T.name)??[]).join(",")})}})})},h.id))]}),n.jsxs("tr",{children:[n.jsx("th",{children:"Description"}),A.map(h=>n.jsx("td",{children:n.jsx("button",{className:"w-full px-2",disabled:!h.userDescription||y?.value===h.userDescription,onClick:()=>g({id:h.id,value:h.userDescription??""}),children:n.jsx("div",{className:"flex items-center justify-center px-2 py-2 border-x-2",style:y?.id===h.id?{background:"#228be633"}:{},children:h.userDescription})})},h.id))]}),n.jsxs("tr",{children:[n.jsx("th",{children:"Owner"}),A.map(h=>n.jsx("td",{children:n.jsx("button",{className:"w-full px-2",disabled:m?.value===h.owner.id,onClick:()=>x({id:h.id,value:h.owner.id}),children:n.jsx("div",{className:"flex items-center justify-center px-2 py-2 border-x-2",style:m?.id===h.id?{background:"#228be633"}:{},children:h.owner.name})})},h.id))]}),n.jsxs("tr",{children:[n.jsx("th",{children:"Is Conversion"}),A.map(h=>n.jsx("td",{children:n.jsx("button",{className:"w-full px-2",disabled:h.conversion==null||h.conversion===b?.value,onClick:()=>{C({id:h.id,value:h.conversion??!1})},children:n.jsx("div",{className:"flex items-center justify-center px-2 py-2 border-x-2",style:b?.id===h.id?{background:"#228be633"}:{},children:h.conversion?n.jsx(At,{size:20,color:"green"}):n.jsx(Pt,{size:20,color:"red"})})})},h.id))]}),n.jsxs("tr",{children:[n.jsx("th",{children:"Optional VAT"}),A.map(h=>n.jsx("td",{children:n.jsx("button",{className:"w-full px-2",disabled:h.optionalVAT==null||h.optionalVAT===f?.value,onClick:()=>{u({id:h.id,value:h.optionalVAT??!1})},children:n.jsx("div",{className:"flex items-center justify-center px-2 py-2 border-x-2",style:f?.id===h.id?{background:"#228be633"}:{},children:h.optionalVAT?n.jsx(At,{size:20,color:"green"}):n.jsx(Pt,{size:20,color:"red"})})})},h.id))]}),n.jsxs("tr",{children:[n.jsx("th",{children:"Optional Documents"}),A.map(h=>n.jsx("td",{children:n.jsx("button",{className:"w-full px-2",disabled:h.optionalDocuments==null||h.optionalDocuments===j?.value,onClick:()=>{v({id:h.id,value:h.optionalDocuments??!1})},children:n.jsx("div",{className:"flex items-center justify-center px-2 py-2 border-x-2",style:j?.id===h.id?{background:"#228be633"}:{},children:h.optionalDocuments?n.jsx(At,{size:20,color:"green"}):n.jsx(Pt,{size:20,color:"red"})})})},h.id))]}),n.jsxs("tr",{children:[n.jsx("th",{children:"Invoice-Payment Currency Difference"}),A.map(h=>n.jsx("td",{children:n.jsx("button",{className:"w-full px-2",disabled:h.isInvoicePaymentDifferentCurrency==null||h.isInvoicePaymentDifferentCurrency===S?.value,onClick:()=>{O({id:h.id,value:h.isInvoicePaymentDifferentCurrency??!1})},children:n.jsx("div",{className:"flex items-center justify-center px-2 py-2 border-x-2",style:S?.id===h.id?{background:"#228be633"}:{},children:h.isInvoicePaymentDifferentCurrency?n.jsx(At,{size:20,color:"green"}):n.jsx(Pt,{size:20,color:"red"})})})},h.id))]}),n.jsxs("tr",{children:[n.jsx("th",{children:"Tags"}),A.map(h=>n.jsx("td",{children:n.jsx("button",{className:"w-full px-2",disabled:h.tags==null||h.tags.map(T=>T.name).join(",")===_?.value,onClick:()=>{D({id:h.id,value:(h.tags.map(T=>T.name)??[]).join(",")})},children:n.jsx("div",{className:"flex items-center justify-center px-2 py-2 border-x-2",style:_?.id===h.id?{background:"#228be633"}:{},children:n.jsx(an,{items:h.tags.map(T=>n.jsxs("div",{className:"flex flex-col items-center",children:[n.jsx("div",{children:T.name}),T.namePath&&n.jsx("div",{children:T.namePath.join(" > ")})]},T.id))})})})},h.id))]}),n.jsxs("tr",{children:[n.jsx("th",{children:"Transactions"}),A.map(h=>n.jsx("td",{children:n.jsx("div",{className:"flex items-center justify-center mx-2 px-2 py-2 border-x-2",children:h.metadata?.transactionsCount??0})},h.id))]}),n.jsxs("tr",{children:[n.jsx("th",{children:"Invoices"}),A.map(h=>n.jsx("td",{children:n.jsx("div",{className:"flex items-center justify-center mx-2 px-2 py-2 border-2 border-t-0 rounded-b-xl",children:h.metadata?.invoicesCount??0})},h.id))]})]}),n.jsxs("div",{className:"flex justify-center gap-5 mt-5",children:[n.jsx("button",{type:"button",className:" text-white bg-blue-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-blue-600 rounded-sm text-lg",disabled:c||a,onClick:M,children:"Accept"}),n.jsx("button",{type:"button",className:" text-white bg-red-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-red-600 rounded-sm text-lg",onClick:t,children:"Cancel"}),n.jsx("button",{type:"button",className:" text-white bg-red-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-red-600 rounded-sm text-lg",onClick:()=>{r(),t()},children:"Reset Merge"})]})]})]})}function Hd(e){const[t,r]=p.useState(!1),{selected:s,resetMerge:a}=e,o=new Set(s.map(({id:g})=>g)),i=o.size>1,[c,l]=p.useState(i?"default":"outline");p.useEffect(()=>{l(i?"default":"outline")},[i]);const d=p.useCallback(()=>{r(!1),s.map(({onChange:g})=>g())},[s]),y=p.useMemo(()=>i?`Merge ${o.size} selected charges`:"Select at least two different charges to merge",[i,o.size]);return n.jsxs(St,{open:t,onOpenChange:r,children:[n.jsx(xs,{disabled:!i,children:n.jsxs(uo,{children:[n.jsx(fo,{children:n.jsx(q,{disabled:!i,variant:c,className:"size-7.5",children:n.jsx(_i,{className:"size-5"})})}),n.jsx(po,{children:n.jsx("p",{children:y})})]})}),n.jsxs(wt,{className:"w-[90vw] sm:max-w-[95%] max-h-[90vh] overflow-y-auto",children:[n.jsx(Pn,{children:n.jsx(Nn,{children:"Issue New Document"})}),n.jsx(Kd,{chargeIds:Array.from(o),onDone:d,resetMerge:a})]})]})}const Gd=({onDone:e,data:t})=>{const[r,s]=p.useState(!1);function a(){s(!1),e?.()}return n.jsxs(St,{open:r,onOpenChange:s,children:[n.jsx(Ke,{content:"Edit Misc Expense",children:n.jsx(xs,{asChild:!0,children:n.jsx(q,{variant:"ghost",size:"icon",className:"size-7.5",children:n.jsx(ys,{className:"size-5"})})})}),n.jsx(wt,{className:"sm:max-w-[425px]",children:n.jsx(cl,{onDone:a,data:t})})]})},qd="batchUpdateCharges",Wd=()=>{const[{fetching:e},t]=Ee(go),r=p.useCallback(async s=>{const a=Array.isArray(s.chargeIds)?s.chargeIds:[s.chargeIds],o=`Error updating charge IDs [${a.join(", ")}]`,i=`${qd}-${a[0]}`;F.loading("Updating charge",{id:i});try{const c=await t(s),l=Oe(c,o,i,"batchUpdateCharges");if(l)return F.success("Success",{id:i,description:`${a.length} charge${a.length>1?"s":""} updated`}),l.batchUpdateCharges.charges}catch(c){console.error(`${o}: ${c}`),F.error("Error",{id:i,description:o,duration:1e5,closeButton:!0})}},[t]);return{fetching:e,batchUpdateCharges:r}},Yd=[{id:"select",header:({table:e})=>n.jsx(jn,{checked:e.getIsAllPageRowsSelected()||e.getIsSomePageRowsSelected()&&"indeterminate",onCheckedChange:t=>e.toggleAllPageRowsSelected(!!t),"aria-label":"Select all"}),cell:({row:e})=>n.jsx(jn,{checked:e.getIsSelected(),onCheckedChange:t=>e.toggleSelected(!!t),"aria-label":"Select row"}),enableSorting:!1,enableHiding:!1},{accessorKey:"chargeType",header:"Type",cell:({row:e})=>n.jsx("div",{children:e.getValue("chargeType")})},{accessorKey:"counterpartyName",header:"Counterparty",cell:({row:e})=>n.jsx("div",{children:e.getValue("counterpartyName")})},{accessorKey:"date",header:"Date",cell:({row:e})=>{const t=e.getValue("date");return n.jsx("div",{children:t?He(new Date(t),"yyyy-MM-dd"):"Missing"})}},{accessorKey:"amountRaw",header:"Amount",cell:({row:e})=>n.jsx("div",{children:e.original.amountFormatted})},{accessorKey:"vatAmountRaw",header:"VAT Amount",cell:({row:e})=>n.jsx("div",{children:e.original.vatAmountFormatted})},{accessorKey:"description",header:"Description",cell:({row:e})=>n.jsx("div",{children:e.getValue("description")})},{accessorKey:"taxCategoryName",header:"Tax Category",cell:({row:e})=>n.jsx("div",{children:e.getValue("taxCategoryName")})},{accessorKey:"tags",header:"Tags",cell:({row:e})=>{const t=e.getValue("tags");return!t||!Array.isArray(t)||t.length===0?n.jsx("div",{children:"No tags"}):n.jsx("div",{children:t.join(" | ")})}},{accessorKey:"businessTripName",header:"Business Trip",cell:({row:e})=>n.jsx("div",{children:e.getValue("businessTripName")})},{accessorKey:"moreInfo",header:"More Info",cell:({row:e})=>{const t=e.original.transactions||0,r=e.original.documents||0,s=e.original.miscExpenses||0,a=e.original.ledgerRecords||0;return n.jsxs("div",{className:"flex flex-col justify-center text-sm",children:[t>0&&n.jsxs("div",{children:["Transactions: ",t]}),r>0&&n.jsxs("div",{children:["Documents: ",r]}),s>0&&n.jsxs("div",{children:["Misc Expenses: ",s]}),a>0&&n.jsxs("div",{children:["Ledger Records: ",a]})]})},enableSorting:!1}];function Qd({data:e,tagIds:t,description:r,onOpenChange:s,title:a="Similar Charges"}){const[o,i]=k.useState([]),[c,l]=k.useState({}),d=p.useMemo(()=>e.map(f=>B(mo,f)),[e]),y=p.useMemo(()=>d.map(u=>({id:u.id,chargeType:Rn(u.__typename),counterpartyName:u.counterparty?.name,date:u.minEventDate||u.minDebitDate||u.minDocumentsDate||void 0,amountRaw:u.totalAmount?.raw,amountFormatted:u.totalAmount?.formatted,vatAmountRaw:u.vat?.raw,vatAmountFormatted:u.vat?.formatted,description:u.userDescription||void 0,tags:u.tags.map(j=>j.name),taxCategoryName:u.taxCategory?.name,businessTripName:u.__typename==="BusinessTripCharge"?u.businessTrip?.name:void 0,ledgerRecords:u.metadata?.ledgerCount??0,documents:u.metadata?.documentsCount??0,transactions:u.metadata?.transactionsCount??0,miscExpenses:u.metadata?.miscExpensesCount??0}))??[],[d]);p.useEffect(()=>{e&&y.length===0&&s(!1)},[e,y.length,s]);const g=Tn({data:y,columns:Yd,onSortingChange:i,getCoreRowModel:$n(),getSortedRowModel:kn(),onRowSelectionChange:l,state:{sorting:o,rowSelection:c}}),{batchUpdateCharges:m}=Wd(),x=p.useCallback(async()=>{const f=g.getSelectedRowModel().rows.map(u=>u.original.id);await m({chargeIds:f,fields:{...t?{tags:t}:{},...r?{userDescription:r}:{}}}),s(!1)},[m,s,g,t,r]);return p.useEffect(()=>{e.length===0&&s(!1)},[e.length,s]),e.length?n.jsxs(n.Fragment,{children:[n.jsxs(Pn,{className:"flex flex-row items-center justify-between",children:[n.jsx(Nn,{children:a}),n.jsx(q,{onClick:x,children:"Approve selected"})]}),n.jsx(vs,{children:n.jsxs(tn,{children:[n.jsx(nn,{children:g.getHeaderGroups().map(f=>n.jsx(Ne,{children:f.headers.map(u=>n.jsx(Ae,{children:u.isPlaceholder?null:rt(u.column.columnDef.header,u.getContext())},u.id))},f.id))}),n.jsx(rn,{children:g.getRowModel().rows.map(f=>n.jsx(Ne,{"data-state":f.getIsSelected()&&"selected",children:f.getVisibleCells().map(u=>n.jsx(xe,{children:rt(u.column.columnDef.cell,u.getContext())},u.id))},f.id))})]})})]}):null}function _a({chargeId:e,tagIds:t,description:r,open:s,onOpenChange:a,onClose:o,showChargesWithExistingSuggestions:i=!1}){const[{data:c,fetching:l},d]=ke({pause:!0,query:ho,variables:{chargeId:e,withMissingTags:i?!1:!!t,withMissingDescription:i?!1:!!r,tagsDifferentThan:i&&t?t.map(m=>m.id):void 0,descriptionDifferentThan:i?r:void 0}});p.useEffect(()=>{s&&(t||r)&&!c&&d()},[s,t,r,d,c]);const y=p.useCallback(m=>{a(m),s&&!m&&o?.()},[a,o,s]);p.useEffect(()=>{s&&!l&&c?.similarCharges.length===0&&o?.()},[s,l,c,o]);const g=p.useMemo(()=>s&&(!!t||!!r)&&c&&c?.similarCharges.length>0,[s,t,r,c]);return n.jsx(St,{open:g,onOpenChange:y,children:n.jsx(wt,{className:"overflow-scroll max-h-screen w-full sm:max-w-[640px] md:max-w-[768px] lg:max-w-[900px]",onClick:m=>m.stopPropagation(),children:n.jsx(xo,{fallback:n.jsx("div",{children:"Error fetching similar charges"}),children:l?n.jsx(hs,{}):t||r?n.jsx(Qd,{data:c?.similarCharges??[],tagIds:t,description:r,onOpenChange:y}):null})})})}function Jd(e){switch(e){case"xs":return"size-8";case"sm":return"size-10";case"md":return"size-15";case"lg":return"size-25";case"xl":return"size-40";default:return"size-10"}}function Xd(e){switch(e){case"xs":return"text-2xs";case"sm":return"text-base";case"md":return"text-2xl";case"lg":return"text-3xl";case"xl":return"text-5xl";default:return"text-base"}}const Zd=({value:e,size:t="xl"})=>{const s=(o=>{const i=Math.max(0,Math.min(100,o)),c=Math.round(155*(1-i/100)+100),l=Math.round(155*(i/100)+0);return`rgb(${c}, ${l}, 0)`})(e),a=e/100*75;return n.jsxs("div",{className:"relative "+Jd(t),children:[n.jsxs("svg",{className:"rotate-[135deg] size-full",viewBox:"0 0 36 36",xmlns:"http://www.w3.org/2000/svg",children:[n.jsx("circle",{cx:"18",cy:"18",r:"16",fill:"none",className:"stroke-current text-gray-200 dark:text-neutral-700",strokeWidth:"1",strokeDasharray:"75 100",strokeLinecap:"round"}),n.jsx("circle",{cx:"18",cy:"18",r:"16",fill:"none",stroke:s,strokeWidth:"2",strokeDasharray:`${a} 100`,strokeLinecap:"round"})]}),n.jsx("div",{className:"absolute top-1/2 start-1/2 transform -translate-x-1/2 -translate-y-1/2 text-center",children:n.jsx("span",{className:"font-bold "+Xd(t),style:{color:s},children:e.toFixed(0)})})]})},eu="updateChargeAccountantApproval",tu=()=>{const[{fetching:e},t]=Ee(yo),r=p.useCallback(async s=>{const a=`Error toggling accountant approval to ledger record ID [${s.chargeId}]`,o=`${eu}-${s.chargeId}`;F.loading("Updating approval status",{id:o});try{const i=await t(s),c=Oe(i,a,o,"updateChargeAccountantApproval");if(c)return F.success("Success",{id:o,description:"Accountant approval was updated"}),c.updateChargeAccountantApproval}catch(i){console.error(`${a}: ${i}`),F.error("Error",{id:o,description:a,duration:1e5,closeButton:!0})}},[t]);return{fetching:e,updateChargeAccountantApproval:r}};function nu({data:e,onChange:t}){const r=B(jo,e),[s,a]=p.useState(r.accountantApproval),{updateChargeAccountantApproval:o}=tu();return p.useEffect(()=>{s==null&&r.accountantApproval!=null&&a(r.accountantApproval)},[s,r.accountantApproval]),n.jsx("td",{children:n.jsx(vo,{value:s,onChange:i=>o({chargeId:r.id,status:i}).then(t)})})}const ru=({data:e})=>{const t=B(bo,e),[r,s]=p.useState(!0),[a,o]=p.useState(!0),i="validCreditCardAmount"in t?t.validCreditCardAmount:null;return p.useEffect(()=>{t.__typename==="CreditcardBankCharge"&&(o(i==null),i!=null&&s(i))},[t.__typename,i]),n.jsx("td",{children:n.jsx("div",{children:n.jsx(Le,{inline:!0,size:12,disabled:r,processing:a,color:"red",zIndex:"auto",children:n.jsx("p",{className:(t.totalAmount?.raw??0)>0?"whitespace-nowrap text-green-700":"whitespace-nowrap text-red-500",children:t.totalAmount?.formatted})})})})},su=({data:e})=>{const t=B(js,e);return"businessTrip"in t?n.jsx("td",{children:n.jsx(yt,{to:t.businessTrip?.id?st.BUSINESS_TRIPS.DETAIL(t.businessTrip?.id):st.BUSINESS_TRIPS.ROOT,target:"_blank",rel:"noreferrer",onClick:r=>r.stopPropagation(),className:"inline-flex items-center font-semibold",children:t.businessTrip?.name})}):n.jsx("td",{})},au=({data:e})=>{const{counterparty:t,validationData:r,__typename:s}=B(bs,e),a=p.useMemo(()=>{switch(s){case"BusinessTripCharge":case"DividendCharge":case"ConversionCharge":case"SalaryCharge":case"InternalTransferCharge":return!1;default:return!0}},[s]),o=p.useMemo(()=>a&&r?.missingInfo?.includes(Ue.Counterparty),[a,r?.missingInfo]),{name:i,id:c}=t??{name:"Missing",id:void 0};return n.jsx("td",{children:n.jsx("div",{className:"flex flex-wrap",children:n.jsxs(Le,{inline:!0,size:12,disabled:!o,color:"red",zIndex:"auto",children:[!o&&c&&n.jsx(yt,{to:st.BUSINESSES.DETAIL(c),target:"_blank",rel:"noreferrer",onClick:l=>l.stopPropagation(),className:"inline-flex items-center font-semibold",children:i}),o&&i]})})})},ou=({data:e})=>{const t=B(Co,e),{minDebitDate:r,minEventDate:s,minDocumentsDate:a}=t,o=r||s||a;return n.jsx("td",{children:n.jsx("div",{children:o&&He(new Date(o),"dd/MM/yy")})})},iu=({data:e,onChange:t})=>{const[r,s]=p.useState(!1),a=B(Do,e),o=p.useMemo(()=>a?.validationData?.missingInfo?.includes(Ue.Description),[a?.validationData?.missingInfo]),i=p.useMemo(()=>o&&!!a.missingInfoSuggestions?.description?.trim().length,[o,a.missingInfoSuggestions?.description]),{userDescription:c,id:l}=a,d=p.useMemo(()=>c&&c?.trim()!==""?c:a.missingInfoSuggestions?.description?a.missingInfoSuggestions.description:"Missing",[c,a.missingInfoSuggestions?.description]),{updateCharge:y,fetching:g}=la(),m=p.useCallback(async x=>{x!==void 0&&(await y({chargeId:l,fields:{userDescription:x}}),s(!0))},[l,y]);return n.jsxs("td",{children:[n.jsxs("div",{className:"flex flex-wrap",children:[n.jsx("div",{className:"flex flex-col justify-center",children:n.jsx(Le,{inline:!0,size:12,disabled:!o,color:"red",zIndex:"auto",children:n.jsx("p",{className:i?"bg-yellow-400":void 0,children:d})})}),i&&n.jsx(Cs,{onClick:x=>{x.stopPropagation(),m(a.missingInfoSuggestions.description)},disabled:g})]}),n.jsx(_a,{chargeId:l,description:a.missingInfoSuggestions?.description??void 0,open:r,onOpenChange:s,onClose:t})]})},cu=({data:e})=>{const t=B(So,e),{metadata:r,validationData:s,id:a,__typename:o}=t,i=p.useMemo(()=>{switch(o){case"BusinessTripCharge":case"ConversionCharge":case"DividendCharge":case"InternalTransferCharge":case"SalaryCharge":case"MonthlyVatCharge":case"BankDepositCharge":case"ForeignSecuritiesCharge":case"CreditcardBankCharge":case"FinancialCharge":return!1;default:return!0}},[o]),c=p.useMemo(()=>o!=="FinancialCharge",[o]),l=p.useMemo(()=>c&&s?.missingInfo?.includes(Ue.Transactions),[c,s?.missingInfo]),d=p.useMemo(()=>i&&s?.missingInfo?.includes(Ue.Documents),[i,s?.missingInfo]),y=p.useMemo(()=>!r?.invalidLedger,[r?.invalidLedger]),g=p.useMemo(()=>r?.invalidLedger,[r?.invalidLedger]),m=p.useMemo(()=>{const x=[];return(l||r?.transactionsCount||c)&&x.push({extraClassName:r?.transactionsCount||!c?void 0:"bg-yellow-400",content:n.jsx(Le,{inline:!0,size:12,disabled:!l,color:"red",zIndex:"auto",children:n.jsxs("div",{className:"whitespace-nowrap",children:["Transactions: ",r?.transactionsCount??0]})},"transactions")}),x.push({content:n.jsx(Le,{inline:!0,size:12,processing:y,disabled:g==="VALID",color:g==="DIFF"?"orange":"red",zIndex:"auto",children:n.jsxs("div",{className:"whitespace-nowrap",children:["Ledger Records: ",r?.ledgerCount??0]})},"ledger")}),(d||r?.documentsCount)&&x.push({content:n.jsx(Le,{inline:!0,size:12,disabled:!d,color:"red",zIndex:"auto",children:n.jsxs("div",{className:"whitespace-nowrap",children:["Documents: ",r?.documentsCount??0]})},"documents"),extraClassName:!s?.missingInfo?.includes(Ue.Documents)||!i?void 0:"bg-yellow-400"}),r?.miscExpensesCount&&x.push({content:n.jsxs("div",{className:"whitespace-nowrap",children:["Misc Expenses: ",r?.miscExpensesCount??0]})}),x},[r?.transactionsCount,r?.ledgerCount,r?.documentsCount,r?.miscExpensesCount,i,c,l,d,s?.missingInfo,g,y]);return n.jsx("td",{children:n.jsx(Bd,{chargeId:a,children:n.jsx(an,{items:m})})})},lu=({data:e,onChange:t})=>{const{tags:r,id:s,validationData:a,missingInfoSuggestions:o}=B(Ds,e),{updateCharge:i,fetching:c}=la(),[l,d]=p.useState(r??[]),[y,g]=p.useState(!1),m=a?.missingInfo?.includes(Ue.Tags),x=m&&!!o?.tags?.length;p.useEffect(()=>{r?.length&&!l.length&&d(r)},[r,l.length]),p.useEffect(()=>{l.length===0&&x&&d(o?.tags??[])},[l.length,x,o?.tags]);const f=p.useCallback(async u=>{await i({chargeId:s,fields:{tags:u?.map(j=>({id:j.id}))}}),g(!0)},[s,i]);return n.jsxs("td",{children:[n.jsx(Le,{inline:!0,size:12,disabled:!m,color:"red",zIndex:"auto",children:n.jsx(an,{items:l.map(u=>n.jsx(zt,{children:n.jsxs("div",{children:[u.namePath&&n.jsx(Be,{size:"xs",opacity:.65,children:`${u.namePath.join(" > ")} >`}),n.jsx(Be,{size:"sm",children:u.name})]})},u.id)),extraClassName:x?"bg-yellow-400":void 0})}),x&&n.jsx(Cs,{onClick:u=>{u.stopPropagation(),f(o.tags)},disabled:c}),n.jsx(_a,{chargeId:s,tagIds:o?.tags?.map(u=>({id:u.id})),open:y,onOpenChange:g,onClose:t})]})},du=({data:e})=>{const{validationData:t,taxCategory:r,__typename:s}=B(Ss,e),a=p.useMemo(()=>{switch(s){case"DividendCharge":case"InternalTransferCharge":case"SalaryCharge":case"BankDepositCharge":case"ForeignSecuritiesCharge":return!1;default:return!0}},[s]),o=p.useMemo(()=>t?.missingInfo?.includes(Ue.TaxCategory),[t?.missingInfo]);return a?n.jsx("td",{children:n.jsx(Le,{inline:!0,size:12,disabled:!o,color:"red",zIndex:"auto",children:r?.name??"N/A"})}):n.jsx("td",{})},uu=({data:e})=>{const t=B(wo,e),{__typename:r}=t,{text:s,icon:a}=p.useMemo(()=>({text:Rn(r),icon:Ws(r)}),[r]);return n.jsxs("td",{children:[n.jsx("div",{children:s}),n.jsx(zn,{radius:"xl",size:"xl",children:a})]})},fu=({data:e})=>{const{vat:t,totalAmount:r,validationData:s,__typename:a}=B(Io,e),o=p.useMemo(()=>s?.missingInfo?.includes(Ue.Vat),[s?.missingInfo]),i=p.useMemo(()=>!t&&r?.currency===sn.Ils,[t,r?.currency]),c=p.useMemo(()=>(t?.raw??0)>0&&(r?.raw??0)<0||(t?.raw??0)<0&&(r?.raw??0)>0,[t?.raw,r?.raw]),l=i||c;return p.useMemo(()=>{switch(a){case"BusinessTripCharge":case"DividendCharge":case"ConversionCharge":case"SalaryCharge":case"InternalTransferCharge":case"BankDepositCharge":case"ForeignSecuritiesCharge":case"CreditcardBankCharge":return!1;default:return!0}},[a])?n.jsx("td",{children:n.jsx("div",{className:l?"whitespace-nowrap text-red-500":"whitespace-nowrap text-green-700",children:n.jsx(Le,{inline:!0,size:12,disabled:!o,color:"red",zIndex:"auto",children:t?.formatted})})}):n.jsx("td",{})},pu="insertDepreciationRecord",gu=()=>{const[{fetching:e},t]=Ee(_o),r=p.useCallback(async s=>{const a="Error adding depreciation record",o=pu;F.loading("Adding depreciation record",{id:o});try{const i=await t(s),c=Oe(i,a,o,"insertDepreciationRecord");if(c)return F.success("Success",{id:o,description:"Depreciation record was added"}),c.insertDepreciationRecord}catch(i){console.error(`${a}: ${i}`),F.error("Error",{id:o,description:a,duration:1e5,closeButton:!0})}},[t]);return{fetching:e,addDepreciationRecord:r}};function Yr(e){const{chargeId:t,onAdd:r}=e,[s,{close:a,open:o}]=xt(!1);return n.jsxs(n.Fragment,{children:[n.jsx(Ke,{content:"Add Depreciation Record",children:n.jsx(q,{variant:"outline",size:"icon",className:"size-7.5",onClick:i=>{i.stopPropagation(),o()},children:n.jsx(ws,{className:"size-5"})})}),s&&n.jsx(mu,{chargeId:t,opened:s,close:a,onAdd:r})]})}function mu({chargeId:e,opened:t,close:r,onAdd:s}){const{control:a,handleSubmit:o}=An({defaultValues:{chargeId:e}}),[i,c]=p.useState(!1),[{data:l,fetching:d}]=ke({query:Is}),{addDepreciationRecord:y,fetching:g}=gu(),m=f=>{y({fields:f}).then(()=>{s?.(),r()})},x=l?.depreciationCategories?.map(f=>({value:f.id,label:f.name}))??[];return p.useEffect(()=>{c(!!(d||g))},[d,g]),n.jsxs(mt,{opened:t,onClose:r,centered:!0,lockScroll:!0,children:[n.jsx(mt.Title,{children:"Add Depreciation Record"}),n.jsx(mt.Body,{children:n.jsxs("form",{onSubmit:o(m),children:[n.jsx(Fe,{name:"activationDate",control:a,rules:{pattern:{value:_s,message:"Date must be im format yyyy-mm-dd"}},render:({field:{value:f,...u}})=>{const j=f?new Date(f):void 0;return n.jsx(Es,{...u,onChange:v=>{const b=v?typeof v=="string"?v:He(v,"yyyy-MM-dd"):void 0;b!==f&&u.onChange(b)},value:j,label:"Activation Date",popoverProps:{withinPortal:!0}})}}),n.jsx(Fe,{name:"amount",control:a,render:({field:f,fieldState:u})=>n.jsx(Fe,{name:"currency",control:a,render:({field:j,fieldState:v})=>n.jsx(Os,{...f,value:f.value??void 0,error:u.error?.message||v.error?.message,label:"Amount",currencyCodeProps:{...j,label:"Currency"}})})}),n.jsx(Fe,{name:"categoryId",control:a,render:({field:f,fieldState:u})=>n.jsx(Lt,{...f,disabled:d,data:x,label:"Category",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:u.error?.message,withinPortal:!0})}),n.jsx(Fe,{name:"type",control:a,render:({field:f,fieldState:u})=>n.jsx(Lt,{...f,data:Ea,value:f.value,label:"Type",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:u.error?.message,withinPortal:!0})}),n.jsx("div",{className:"flex justify-center mt-5 gap-3",children:n.jsx("button",{type:"submit",className:"text-white bg-indigo-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-indigo-600 rounded-sm text-lg",children:"Add"})})]})}),(g||i)&&n.jsx(ps,{blur:1,center:!0,children:n.jsx(Dt,{})})]})}const hu="updateDepreciationRecord",xu=()=>{const[{fetching:e},t]=Ee(Eo),r=p.useCallback(async s=>{const a="Error updating depreciation record",o=hu;F.loading("Updating depreciation record",{id:o});try{const i=await t(s),c=Oe(i,a,o,"updateDepreciationRecord");if(c)return F.success("Success",{id:o,description:"Depreciation record was updated"}),c.updateDepreciationRecord}catch(i){console.error(`${a}: ${i}`),F.error("Error",{id:o,description:a,duration:1e5,closeButton:!0})}},[t]);return{fetching:e,updateDepreciationRecord:r}},yu="deleteDepreciationRecord",vu=()=>{const[{fetching:e},t]=Ee(Oo),r=p.useCallback(async s=>{const a="Error deleting depreciation record",o=`${yu}-${s.depreciationRecordId}`;F.loading("Deleting depreciation record",{id:o});try{const i=await t(s),c=Oe(i,a,o);if(c)return F.success("Success",{id:o,description:"Depreciation record was deleted"}),c.deleteDepreciationRecord}catch(i){console.error(`${a}: ${i}`),F.error("Error",{id:o,description:a,duration:1e5,closeButton:!0})}},[t]);return{fetching:e,deleteDepreciationRecord:r}};function ju(e){const{fetching:t,deleteDepreciationRecord:r}=vu(),s=p.useCallback(()=>{r({depreciationRecordId:e.depreciationRecordId}).then(()=>{e.onDelete?.()})},[e,r]);return n.jsx(Ke,{content:"Remove Depreciation",children:n.jsx(en,{onConfirm:s,title:"Are you sure you want to delete the depreciation record?",children:n.jsx(q,{variant:"outline",size:"icon",className:"size-7.5 text-red-500",disabled:t,children:n.jsx(Fn,{className:"size-5"})})})})}const bu=({data:e,onChange:t})=>{const r=B(Po,e),[s,a]=p.useState(!1),[{data:o,fetching:i},c]=ke({query:Is,pause:!0}),{control:l,handleSubmit:d,formState:{dirtyFields:y}}=An({defaultValues:{id:r.id}}),{updateDepreciationRecord:g,fetching:m}=xu(),x=u=>{const j=No(u,y);j&&Object.keys(j).length>0&&g({fields:{...u,id:r.id}}).then(()=>{t?.(),a(!1)})},f=o?.depreciationCategories.map(u=>({value:u.id,label:u.name}));return p.useEffect(()=>{s&&!o&&c()},[s,o,c]),n.jsxs("tr",{children:[n.jsx("td",{children:n.jsx("form",{id:`form ${r.id}`,onSubmit:d(x),children:s?n.jsx(Fe,{name:"amount",control:l,render:({field:u,fieldState:j})=>n.jsx(Fe,{name:"currency",control:l,render:({field:v,fieldState:b})=>n.jsx(Os,{...u,defaultValue:r.amount?.raw??r.charge.totalAmount?.raw,value:u.value??void 0,error:j.error?.message||b.error?.message,label:"Amount",currencyCodeProps:{...v,label:"Currency",defaultValue:r.amount?.currency??r.charge.totalAmount?.currency}})})}):n.jsx("div",{children:r.amount?.formatted??r.charge.totalAmount?.formatted})})}),n.jsx("td",{children:n.jsx("div",{className:"flex flex-col gap-2 justify-center",children:s?n.jsx(Fe,{name:"activationDate",control:l,defaultValue:r.activationDate,rules:{pattern:{value:_s,message:"Date must be im format yyyy-mm-dd"}},render:({field:{value:u,...j},fieldState:v})=>{const b=u?new Date(u):void 0;return n.jsx(Es,{...j,form:`form ${r.id}`,onChange:C=>{const S=C?typeof C=="string"?C:He(C,"yyyy-MM-dd"):void 0;S!==u&&j.onChange(S)},value:b,label:"Activation Date",error:v.error?.message,popoverProps:{withinPortal:!0}})}}):n.jsx("div",{children:He(new Date(r.activationDate),"dd/MM/yy")})})}),n.jsx("td",{children:s?n.jsx(Fe,{name:"categoryId",control:l,render:({field:u,fieldState:j})=>n.jsx(Lt,{...u,form:`form ${r.id}`,disabled:i,data:f??[],label:"Category",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:j.error?.message,withinPortal:!0})}):n.jsxs("div",{children:[r.category.name," (",r.category.percentage,"%)"]})}),n.jsx("td",{children:s?n.jsx(Fe,{name:"type",control:l,render:({field:u,fieldState:j})=>n.jsx(Lt,{...u,form:`form ${r.id}`,data:Ea,value:u.value,label:"Type",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:j.error?.message,withinPortal:!0})}):n.jsx("div",{children:r.type})}),n.jsxs("td",{children:[n.jsx(Ke,{content:"Edit",children:n.jsx(q,{disabled:m||i,variant:s?"default":"outline",size:"icon",className:"size-7.5",onClick:u=>{u.stopPropagation(),a(j=>!j)},children:n.jsx(ys,{className:"size-5"})})}),s&&n.jsx(Ke,{content:"Confirm Changes",children:n.jsx(q,{type:"submit",form:`form ${r.id}`,variant:"outline",size:"icon",className:"size-7.5 text-green-500",children:n.jsx(Ao,{className:"size-5"})})}),n.jsx(ju,{depreciationRecordId:r.id,onDelete:t})]})]},r.id)},Cu=({chargeId:e,onChange:t})=>{const[{data:r,fetching:s}]=ke({query:To,variables:{chargeId:e}});return!s&&!r?.depreciationRecordsByCharge.length?n.jsx(Yr,{chargeId:e,onAdd:t}):s?n.jsx(Mn,{className:"h-10 w-10 animate-spin mr-2 self-center"}):n.jsx("div",{className:"flex flex-col gap-2 mt-5",children:n.jsxs(Gs,{highlightOnHover:!0,withBorder:!0,children:[n.jsx("thead",{children:n.jsxs("tr",{children:[n.jsx("th",{children:"Amount"}),n.jsx("th",{children:"Activation Date"}),n.jsx("th",{children:"Category"}),n.jsx("th",{children:"Type"}),n.jsx("th",{})]})}),n.jsxs("tbody",{children:[r?.depreciationRecordsByCharge.map(a=>n.jsx(bu,{data:a,onChange:t},a.id)),n.jsx("tr",{children:n.jsx("td",{colSpan:5,children:n.jsx(Yr,{chargeId:e,onAdd:t})})})]})]})})},Ea=Object.entries(ko).map(([e,t])=>({value:t,label:e}));function Du({chargeId:e,chargeType:t,setInsertDocument:r,setMatchDocuments:s,onChange:a,isIncome:o}){const{deleteCharge:i}=el(),[c,l]=p.useState(!1),[d,{open:y,close:g}]=xt(!1),[m,x]=p.useState(!1),[f,{open:u,close:j}]=xt(!1),[v,b]=p.useState(!1),[C,S]=p.useState(!1);function O(){i({chargeId:e}),a?.()}function _(){l(!1)}return n.jsxs(n.Fragment,{children:[n.jsxs(ie,{shadow:"md",width:200,opened:c,children:[n.jsx(ie.Target,{children:n.jsx(Ci,{opened:c,onClick:D=>{D.stopPropagation(),l(E=>!E)}})}),n.jsxs(ie.Dropdown,{children:[n.jsx(ie.Label,{children:"Charge"}),n.jsx(en,{onConfirm:O,title:"Are you sure you want to delete this charge?",children:n.jsx(ie.Item,{icon:n.jsx(Fn,{size:14}),children:"Delete Charge"})}),n.jsx(ie.Divider,{}),n.jsx(ie.Label,{children:"Documents"}),r&&n.jsx(ie.Item,{icon:n.jsx(un,{size:14}),onClick:D=>{D.stopPropagation(),r(),_()},children:"Insert Document"}),n.jsx(ie.Item,{icon:n.jsx(gr,{size:14}),onClick:D=>{D.stopPropagation(),S(!0),_()},children:"Upload Documents"}),s&&n.jsx(ie.Item,{icon:n.jsx($o,{size:14}),onClick:()=>{s(),_()},children:"Match Document"}),o&&n.jsx(ie.Item,{icon:n.jsx(un,{size:14}),onClick:D=>{D.stopPropagation(),b(!0),_()},children:"Issue Document"}),n.jsx(ie.Divider,{}),n.jsx(ie.Label,{children:"Misc Expenses"}),n.jsx(ie.Item,{icon:n.jsx(un,{size:14}),onClick:D=>{D.stopPropagation(),_(),x(!0)},children:"Add expense"}),t==="CommonCharge"&&n.jsxs(n.Fragment,{children:[n.jsx(ie.Divider,{}),n.jsx(ie.Label,{children:"Depreciation"}),n.jsx(ie.Item,{icon:n.jsx(Ai,{size:14}),onClick:D=>{D.stopPropagation(),y(),_()},children:"Depreciation"})]}),t==="SalaryCharge"&&n.jsxs(n.Fragment,{children:[n.jsx(ie.Divider,{}),n.jsx(ie.Label,{children:"Salaries"}),n.jsx(ie.Item,{icon:n.jsx(gr,{size:14}),onClick:D=>{D.stopPropagation(),_(),u()},children:"Payroll file upload"})]})]})]}),n.jsx(mt,{withinPortal:!0,size:"xl",centered:!0,opened:d,onClose:g,title:"Depreciation",onClick:D=>D.stopPropagation(),children:n.jsx(Cu,{chargeId:e,onChange:()=>{g(),a?.()}})}),n.jsx(St,{open:m,onOpenChange:x,children:n.jsx(wt,{className:"sm:max-w-[425px]",onClick:D=>D.stopPropagation(),children:n.jsx(ui,{onDone:()=>{x(!1),a?.()},chargeId:e})})}),n.jsx(mt,{centered:!0,opened:f,onClose:j,title:"Upload Payroll File",onClick:D=>D.stopPropagation(),children:n.jsx(ul,{onDone:()=>{j(),a?.()},chargeId:e})}),n.jsx(Fo,{open:C,onOpenChange:S,onChange:a,chargeId:e}),n.jsx(bn,{chargeId:e,open:v,setOpen:b,onDone:()=>a?.()})]})}function Su(e){return Object.prototype.toString.call(e)==="[object Object]"}function Qr(e){return Su(e)||Array.isArray(e)}function wu(){return!!(typeof window<"u"&&window.document&&window.document.createElement)}function Vn(e,t){const r=Object.keys(e),s=Object.keys(t);if(r.length!==s.length)return!1;const a=JSON.stringify(Object.keys(e.breakpoints||{})),o=JSON.stringify(Object.keys(t.breakpoints||{}));return a!==o?!1:r.every(i=>{const c=e[i],l=t[i];return typeof c=="function"?`${c}`==`${l}`:!Qr(c)||!Qr(l)?c===l:Vn(c,l)})}function Jr(e){return e.concat().sort((t,r)=>t.name>r.name?1:-1).map(t=>t.options)}function Iu(e,t){if(e.length!==t.length)return!1;const r=Jr(e),s=Jr(t);return r.every((a,o)=>{const i=s[o];return Vn(a,i)})}function Un(e){return typeof e=="number"}function En(e){return typeof e=="string"}function on(e){return typeof e=="boolean"}function Xr(e){return Object.prototype.toString.call(e)==="[object Object]"}function X(e){return Math.abs(e)}function Kn(e){return Math.sign(e)}function ht(e,t){return X(e-t)}function _u(e,t){if(e===0||t===0||X(e)<=X(t))return 0;const r=ht(X(e),X(t));return X(r/e)}function Eu(e){return Math.round(e*100)/100}function jt(e){return bt(e).map(Number)}function Te(e){return e[_t(e)]}function _t(e){return Math.max(0,e.length-1)}function Hn(e,t){return t===_t(e)}function Zr(e,t=0){return Array.from(Array(e),(r,s)=>t+s)}function bt(e){return Object.keys(e)}function Oa(e,t){return[e,t].reduce((r,s)=>(bt(s).forEach(a=>{const o=r[a],i=s[a],c=Xr(o)&&Xr(i);r[a]=c?Oa(o,i):i}),r),{})}function On(e,t){return typeof t.MouseEvent<"u"&&e instanceof t.MouseEvent}function Ou(e,t){const r={start:s,center:a,end:o};function s(){return 0}function a(l){return o(l)/2}function o(l){return t-l}function i(l,d){return En(e)?r[e](l):e(t,l,d)}return{measure:i}}function Ct(){let e=[];function t(a,o,i,c={passive:!0}){let l;if("addEventListener"in a)a.addEventListener(o,i,c),l=()=>a.removeEventListener(o,i,c);else{const d=a;d.addListener(i),l=()=>d.removeListener(i)}return e.push(l),s}function r(){e=e.filter(a=>a())}const s={add:t,clear:r};return s}function Au(e,t,r,s){const a=Ct(),o=1e3/60;let i=null,c=0,l=0;function d(){a.add(e,"visibilitychange",()=>{e.hidden&&f()})}function y(){x(),a.clear()}function g(j){if(!l)return;i||(i=j,r(),r());const v=j-i;for(i=j,c+=v;c>=o;)r(),c-=o;const b=c/o;s(b),l&&(l=t.requestAnimationFrame(g))}function m(){l||(l=t.requestAnimationFrame(g))}function x(){t.cancelAnimationFrame(l),i=null,c=0,l=0}function f(){i=null,c=0}return{init:d,destroy:y,start:m,stop:x,update:r,render:s}}function Pu(e,t){const r=t==="rtl",s=e==="y",a=s?"y":"x",o=s?"x":"y",i=!s&&r?-1:1,c=y(),l=g();function d(f){const{height:u,width:j}=f;return s?u:j}function y(){return s?"top":r?"right":"left"}function g(){return s?"bottom":r?"left":"right"}function m(f){return f*i}return{scroll:a,cross:o,startEdge:c,endEdge:l,measureSize:d,direction:m}}function Ze(e=0,t=0){const r=X(e-t);function s(d){return d<e}function a(d){return d>t}function o(d){return s(d)||a(d)}function i(d){return o(d)?s(d)?e:t:d}function c(d){return r?d-r*Math.ceil((d-t)/r):d}return{length:r,max:t,min:e,constrain:i,reachedAny:o,reachedMax:a,reachedMin:s,removeOffset:c}}function Aa(e,t,r){const{constrain:s}=Ze(0,e),a=e+1;let o=i(t);function i(m){return r?X((a+m)%a):s(m)}function c(){return o}function l(m){return o=i(m),g}function d(m){return y().set(c()+m)}function y(){return Aa(e,c(),r)}const g={get:c,set:l,add:d,clone:y};return g}function Nu(e,t,r,s,a,o,i,c,l,d,y,g,m,x,f,u,j,v,b){const{cross:C,direction:S}=e,O=["INPUT","SELECT","TEXTAREA"],_={passive:!1},D=Ct(),E=Ct(),A=Ze(50,225).constrain(x.measure(20)),M={mouse:300,touch:400},h={mouse:500,touch:600},T=f?43:25;let Q=!1,R=0,V=0,ue=!1,le=!1,ee=!1,H=!1;function ye(I){if(!b)return;function U(re){(on(b)||b(I,re))&&ce(re)}const W=t;D.add(W,"dragstart",re=>re.preventDefault(),_).add(W,"touchmove",()=>{},_).add(W,"touchend",()=>{}).add(W,"touchstart",U).add(W,"mousedown",U).add(W,"touchcancel",N).add(W,"contextmenu",N).add(W,"click",fe,!0)}function L(){D.clear(),E.clear()}function se(){const I=H?r:t;E.add(I,"touchmove",te,_).add(I,"touchend",N).add(I,"mousemove",te,_).add(I,"mouseup",N)}function me(I){const U=I.nodeName||"";return O.includes(U)}function G(){return(f?h:M)[H?"mouse":"touch"]}function ve(I,U){const W=g.add(Kn(I)*-1),re=y.byDistance(I,!f).distance;return f||X(I)<A?re:j&&U?re*.5:y.byIndex(W.get(),0).distance}function ce(I){const U=On(I,s);H=U,ee=f&&U&&!I.buttons&&Q,Q=ht(a.get(),i.get())>=2,!(U&&I.button!==0)&&(me(I.target)||(ue=!0,o.pointerDown(I),d.useFriction(0).useDuration(0),a.set(i),se(),R=o.readPoint(I),V=o.readPoint(I,C),m.emit("pointerDown")))}function te(I){if(!On(I,s)&&I.touches.length>=2)return N(I);const W=o.readPoint(I),re=o.readPoint(I,C),pe=ht(W,R),de=ht(re,V);if(!le&&!H&&(!I.cancelable||(le=pe>de,!le)))return N(I);const je=o.pointerMove(I);pe>u&&(ee=!0),d.useFriction(.3).useDuration(.75),c.start(),a.add(S(je)),I.preventDefault()}function N(I){const W=y.byDistance(0,!1).index!==g.get(),re=o.pointerUp(I)*G(),pe=ve(S(re),W),de=_u(re,pe),je=T-10*de,ge=v+de/50;le=!1,ue=!1,E.clear(),d.useDuration(je).useFriction(ge),l.distance(pe,!f),H=!1,m.emit("pointerUp")}function fe(I){ee&&(I.stopPropagation(),I.preventDefault(),ee=!1)}function ne(){return ue}return{init:ye,destroy:L,pointerDown:ne}}function Tu(e,t){let s,a;function o(g){return g.timeStamp}function i(g,m){const f=`client${(m||e.scroll)==="x"?"X":"Y"}`;return(On(g,t)?g:g.touches[0])[f]}function c(g){return s=g,a=g,i(g)}function l(g){const m=i(g)-i(a),x=o(g)-o(s)>170;return a=g,x&&(s=g),m}function d(g){if(!s||!a)return 0;const m=i(a)-i(s),x=o(g)-o(s),f=o(g)-o(a)>170,u=m/x;return x&&!f&&X(u)>.1?u:0}return{pointerDown:c,pointerMove:l,pointerUp:d,readPoint:i}}function ku(){function e(r){const{offsetTop:s,offsetLeft:a,offsetWidth:o,offsetHeight:i}=r;return{top:s,right:a+o,bottom:s+i,left:a,width:o,height:i}}return{measure:e}}function $u(e){function t(s){return e*(s/100)}return{measure:t}}function Fu(e,t,r,s,a,o,i){const c=[e].concat(s);let l,d,y=[],g=!1;function m(j){return a.measureSize(i.measure(j))}function x(j){if(!o)return;d=m(e),y=s.map(m);function v(b){for(const C of b){if(g)return;const S=C.target===e,O=s.indexOf(C.target),_=S?d:y[O],D=m(S?e:s[O]);if(X(D-_)>=.5){j.reInit(),t.emit("resize");break}}}l=new ResizeObserver(b=>{(on(o)||o(j,b))&&v(b)}),r.requestAnimationFrame(()=>{c.forEach(b=>l.observe(b))})}function f(){g=!0,l&&l.disconnect()}return{init:x,destroy:f}}function Mu(e,t,r,s,a,o){let i=0,c=0,l=a,d=o,y=e.get(),g=0;function m(){const _=s.get()-e.get(),D=!l;let E=0;return D?(i=0,r.set(s),e.set(s),E=_):(r.set(e),i+=_/l,i*=d,y+=i,e.add(i),E=y-g),c=Kn(E),g=y,O}function x(){const _=s.get()-t.get();return X(_)<.001}function f(){return l}function u(){return c}function j(){return i}function v(){return C(a)}function b(){return S(o)}function C(_){return l=_,O}function S(_){return d=_,O}const O={direction:u,duration:f,velocity:j,seek:m,settled:x,useBaseFriction:b,useBaseDuration:v,useFriction:S,useDuration:C};return O}function Ru(e,t,r,s,a){const o=a.measure(10),i=a.measure(50),c=Ze(.1,.99);let l=!1;function d(){return!(l||!e.reachedAny(r.get())||!e.reachedAny(t.get()))}function y(x){if(!d())return;const f=e.reachedMin(t.get())?"min":"max",u=X(e[f]-t.get()),j=r.get()-t.get(),v=c.constrain(u/i);r.subtract(j*v),!x&&X(j)<o&&(r.set(e.constrain(r.get())),s.useDuration(25).useBaseFriction())}function g(x){l=!x}return{shouldConstrain:d,constrain:y,toggleActive:g}}function zu(e,t,r,s,a){const o=Ze(-t+e,0),i=g(),c=y(),l=m();function d(f,u){return ht(f,u)<=1}function y(){const f=i[0],u=Te(i),j=i.lastIndexOf(f),v=i.indexOf(u)+1;return Ze(j,v)}function g(){return r.map((f,u)=>{const{min:j,max:v}=o,b=o.constrain(f),C=!u,S=Hn(r,u);return C?v:S||d(j,b)?j:d(v,b)?v:b}).map(f=>parseFloat(f.toFixed(3)))}function m(){if(t<=e+a)return[o.max];if(s==="keepSnaps")return i;const{min:f,max:u}=c;return i.slice(f,u)}return{snapsContained:l,scrollContainLimit:c}}function Lu(e,t,r){const s=t[0],a=r?s-e:Te(t);return{limit:Ze(a,s)}}function Bu(e,t,r,s){const o=t.min+.1,i=t.max+.1,{reachedMin:c,reachedMax:l}=Ze(o,i);function d(m){return m===1?l(r.get()):m===-1?c(r.get()):!1}function y(m){if(!d(m))return;const x=e*(m*-1);s.forEach(f=>f.add(x))}return{loop:y}}function Vu(e){const{max:t,length:r}=e;function s(o){const i=o-t;return r?i/-r:0}return{get:s}}function Uu(e,t,r,s,a){const{startEdge:o,endEdge:i}=e,{groupSlides:c}=a,l=g().map(t.measure),d=m(),y=x();function g(){return c(s).map(u=>Te(u)[i]-u[0][o]).map(X)}function m(){return s.map(u=>r[o]-u[o]).map(u=>-X(u))}function x(){return c(d).map(u=>u[0]).map((u,j)=>u+l[j])}return{snaps:d,snapsAligned:y}}function Ku(e,t,r,s,a,o){const{groupSlides:i}=a,{min:c,max:l}=s,d=y();function y(){const m=i(o),x=!e||t==="keepSnaps";return r.length===1?[o]:x?m:m.slice(c,l).map((f,u,j)=>{const v=!u,b=Hn(j,u);if(v){const C=Te(j[0])+1;return Zr(C)}if(b){const C=_t(o)-Te(j)[0]+1;return Zr(C,Te(j)[0])}return f})}return{slideRegistry:d}}function Hu(e,t,r,s,a){const{reachedAny:o,removeOffset:i,constrain:c}=s;function l(f){return f.concat().sort((u,j)=>X(u)-X(j))[0]}function d(f){const u=e?i(f):c(f),j=t.map((b,C)=>({diff:y(b-u,0),index:C})).sort((b,C)=>X(b.diff)-X(C.diff)),{index:v}=j[0];return{index:v,distance:u}}function y(f,u){const j=[f,f+r,f-r];if(!e)return f;if(!u)return l(j);const v=j.filter(b=>Kn(b)===u);return v.length?l(v):Te(j)-r}function g(f,u){const j=t[f]-a.get(),v=y(j,u);return{index:f,distance:v}}function m(f,u){const j=a.get()+f,{index:v,distance:b}=d(j),C=!e&&o(j);if(!u||C)return{index:v,distance:f};const S=t[v]-b,O=f+y(S,0);return{index:v,distance:O}}return{byDistance:m,byIndex:g,shortcut:y}}function Gu(e,t,r,s,a,o,i){function c(g){const m=g.distance,x=g.index!==t.get();o.add(m),m&&(s.duration()?e.start():(e.update(),e.render(1),e.update())),x&&(r.set(t.get()),t.set(g.index),i.emit("select"))}function l(g,m){const x=a.byDistance(g,m);c(x)}function d(g,m){const x=t.clone().set(g),f=a.byIndex(x.get(),m);c(f)}return{distance:l,index:d}}function qu(e,t,r,s,a,o,i,c){const l={passive:!0,capture:!0};let d=0;function y(x){if(!c)return;function f(u){if(new Date().getTime()-d>10)return;i.emit("slideFocusStart"),e.scrollLeft=0;const b=r.findIndex(C=>C.includes(u));Un(b)&&(a.useDuration(0),s.index(b,0),i.emit("slideFocus"))}o.add(document,"keydown",g,!1),t.forEach((u,j)=>{o.add(u,"focus",v=>{(on(c)||c(x,v))&&f(j)},l)})}function g(x){x.code==="Tab"&&(d=new Date().getTime())}return{init:y}}function gt(e){let t=e;function r(){return t}function s(l){t=i(l)}function a(l){t+=i(l)}function o(l){t-=i(l)}function i(l){return Un(l)?l:l.get()}return{get:r,set:s,add:a,subtract:o}}function Pa(e,t){const r=e.scroll==="x"?i:c,s=t.style;let a=null,o=!1;function i(m){return`translate3d(${m}px,0px,0px)`}function c(m){return`translate3d(0px,${m}px,0px)`}function l(m){if(o)return;const x=Eu(e.direction(m));x!==a&&(s.transform=r(x),a=x)}function d(m){o=!m}function y(){o||(s.transform="",t.getAttribute("style")||t.removeAttribute("style"))}return{clear:y,to:l,toggleActive:d}}function Wu(e,t,r,s,a,o,i,c,l){const y=jt(a),g=jt(a).reverse(),m=v().concat(b());function x(D,E){return D.reduce((A,M)=>A-a[M],E)}function f(D,E){return D.reduce((A,M)=>x(A,E)>0?A.concat([M]):A,[])}function u(D){return o.map((E,A)=>({start:E-s[A]+.5+D,end:E+t-.5+D}))}function j(D,E,A){const M=u(E);return D.map(h=>{const T=A?0:-r,Q=A?r:0,R=A?"end":"start",V=M[h][R];return{index:h,loopPoint:V,slideLocation:gt(-1),translate:Pa(e,l[h]),target:()=>c.get()>V?T:Q}})}function v(){const D=i[0],E=f(g,D);return j(E,r,!1)}function b(){const D=t-i[0]-1,E=f(y,D);return j(E,-r,!0)}function C(){return m.every(({index:D})=>{const E=y.filter(A=>A!==D);return x(E,t)<=.1})}function S(){m.forEach(D=>{const{target:E,translate:A,slideLocation:M}=D,h=E();h!==M.get()&&(A.to(h),M.set(h))})}function O(){m.forEach(D=>D.translate.clear())}return{canLoop:C,clear:O,loop:S,loopPoints:m}}function Yu(e,t,r){let s,a=!1;function o(l){if(!r)return;function d(y){for(const g of y)if(g.type==="childList"){l.reInit(),t.emit("slidesChanged");break}}s=new MutationObserver(y=>{a||(on(r)||r(l,y))&&d(y)}),s.observe(e,{childList:!0})}function i(){s&&s.disconnect(),a=!0}return{init:o,destroy:i}}function Qu(e,t,r,s){const a={};let o=null,i=null,c,l=!1;function d(){c=new IntersectionObserver(f=>{l||(f.forEach(u=>{const j=t.indexOf(u.target);a[j]=u}),o=null,i=null,r.emit("slidesInView"))},{root:e.parentElement,threshold:s}),t.forEach(f=>c.observe(f))}function y(){c&&c.disconnect(),l=!0}function g(f){return bt(a).reduce((u,j)=>{const v=parseInt(j),{isIntersecting:b}=a[v];return(f&&b||!f&&!b)&&u.push(v),u},[])}function m(f=!0){if(f&&o)return o;if(!f&&i)return i;const u=g(f);return f&&(o=u),f||(i=u),u}return{init:d,destroy:y,get:m}}function Ju(e,t,r,s,a,o){const{measureSize:i,startEdge:c,endEdge:l}=e,d=r[0]&&a,y=f(),g=u(),m=r.map(i),x=j();function f(){if(!d)return 0;const b=r[0];return X(t[c]-b[c])}function u(){if(!d)return 0;const b=o.getComputedStyle(Te(s));return parseFloat(b.getPropertyValue(`margin-${l}`))}function j(){return r.map((b,C,S)=>{const O=!C,_=Hn(S,C);return O?m[C]+y:_?m[C]+g:S[C+1][c]-b[c]}).map(X)}return{slideSizes:m,slideSizesWithGaps:x,startGap:y,endGap:g}}function Xu(e,t,r,s,a,o,i,c,l){const{startEdge:d,endEdge:y,direction:g}=e,m=Un(r);function x(v,b){return jt(v).filter(C=>C%b===0).map(C=>v.slice(C,C+b))}function f(v){return v.length?jt(v).reduce((b,C,S)=>{const O=Te(b)||0,_=O===0,D=C===_t(v),E=a[d]-o[O][d],A=a[d]-o[C][y],M=!s&&_?g(i):0,h=!s&&D?g(c):0,T=X(A-h-(E+M));return S&&T>t+l&&b.push(C),D&&b.push(v.length),b},[]).map((b,C,S)=>{const O=Math.max(S[C-1]||0);return v.slice(O,b)}):[]}function u(v){return m?x(v,r):f(v)}return{groupSlides:u}}function Zu(e,t,r,s,a,o,i){const{align:c,axis:l,direction:d,startIndex:y,loop:g,duration:m,dragFree:x,dragThreshold:f,inViewThreshold:u,slidesToScroll:j,skipSnaps:v,containScroll:b,watchResize:C,watchSlides:S,watchDrag:O,watchFocus:_}=o,D=2,E=ku(),A=E.measure(t),M=r.map(E.measure),h=Pu(l,d),T=h.measureSize(A),Q=$u(T),R=Ou(c,T),V=!g&&!!b,ue=g||!!b,{slideSizes:le,slideSizesWithGaps:ee,startGap:H,endGap:ye}=Ju(h,A,M,r,ue,a),L=Xu(h,T,j,g,A,M,H,ye,D),{snaps:se,snapsAligned:me}=Uu(h,R,A,M,L),G=-Te(se)+Te(ee),{snapsContained:ve,scrollContainLimit:ce}=zu(T,G,me,b,D),te=V?ve:me,{limit:N}=Lu(G,te,g),fe=Aa(_t(te),y,g),ne=fe.clone(),K=jt(r),I=({dragHandler:Se,scrollBody:Ye,scrollBounds:Qe,options:{loop:Ve}})=>{Ve||Qe.constrain(Se.pointerDown()),Ye.seek()},U=({scrollBody:Se,translate:Ye,location:Qe,offsetLocation:Ve,previousLocation:et,scrollLooper:lt,slideLooper:dt,dragHandler:ut,animation:ft,eventHandler:Et,scrollBounds:Ma,options:{loop:Wn}},Yn)=>{const Qn=Se.settled(),Ra=!Ma.shouldConstrain(),Jn=Wn?Qn:Qn&&Ra,Xn=Jn&&!ut.pointerDown();Xn&&ft.stop();const za=Qe.get()*Yn+et.get()*(1-Yn);Ve.set(za),Wn&&(lt.loop(Se.direction()),dt.loop()),Ye.to(Ve.get()),Xn&&Et.emit("settle"),Jn||Et.emit("scroll")},W=Au(s,a,()=>I(Re),Se=>U(Re,Se)),re=.68,pe=te[fe.get()],de=gt(pe),je=gt(pe),ge=gt(pe),be=gt(pe),ae=Mu(de,ge,je,be,m,re),Me=Hu(g,te,G,N,be),ct=Gu(W,fe,ne,ae,Me,be,i),w=Vu(N),P=Ct(),Z=Qu(t,r,i,u),{slideRegistry:oe}=Ku(V,b,te,ce,L,K),he=qu(e,r,oe,ct,ae,P,i,_),Re={ownerDocument:s,ownerWindow:a,eventHandler:i,containerRect:A,slideRects:M,animation:W,axis:h,dragHandler:Nu(h,e,s,a,be,Tu(h,a),de,W,ct,ae,Me,fe,i,Q,x,f,v,re,O),eventStore:P,percentOfView:Q,index:fe,indexPrevious:ne,limit:N,location:de,offsetLocation:ge,previousLocation:je,options:o,resizeHandler:Fu(t,i,a,r,h,C,E),scrollBody:ae,scrollBounds:Ru(N,ge,be,ae,Q),scrollLooper:Bu(G,N,ge,[de,ge,je,be]),scrollProgress:w,scrollSnapList:te.map(w.get),scrollSnaps:te,scrollTarget:Me,scrollTo:ct,slideLooper:Wu(h,T,G,le,ee,se,te,ge,r),slideFocus:he,slidesHandler:Yu(t,i,S),slidesInView:Z,slideIndexes:K,slideRegistry:oe,slidesToScroll:L,target:be,translate:Pa(h,t)};return Re}function ef(){let e={},t;function r(d){t=d}function s(d){return e[d]||[]}function a(d){return s(d).forEach(y=>y(t,d)),l}function o(d,y){return e[d]=s(d).concat([y]),l}function i(d,y){return e[d]=s(d).filter(g=>g!==y),l}function c(){e={}}const l={init:r,emit:a,off:i,on:o,clear:c};return l}const tf={align:"center",axis:"x",container:null,slides:null,containScroll:"trimSnaps",direction:"ltr",slidesToScroll:1,inViewThreshold:0,breakpoints:{},dragFree:!1,dragThreshold:10,loop:!1,skipSnaps:!1,duration:25,startIndex:0,active:!0,watchDrag:!0,watchResize:!0,watchSlides:!0,watchFocus:!0};function nf(e){function t(o,i){return Oa(o,i||{})}function r(o){const i=o.breakpoints||{},c=bt(i).filter(l=>e.matchMedia(l).matches).map(l=>i[l]).reduce((l,d)=>t(l,d),{});return t(o,c)}function s(o){return o.map(i=>bt(i.breakpoints||{})).reduce((i,c)=>i.concat(c),[]).map(e.matchMedia)}return{mergeOptions:t,optionsAtMedia:r,optionsMediaQueries:s}}function rf(e){let t=[];function r(o,i){return t=i.filter(({options:c})=>e.optionsAtMedia(c).active!==!1),t.forEach(c=>c.init(o,e)),i.reduce((c,l)=>Object.assign(c,{[l.name]:l}),{})}function s(){t=t.filter(o=>o.destroy())}return{init:r,destroy:s}}function Jt(e,t,r){const s=e.ownerDocument,a=s.defaultView,o=nf(a),i=rf(o),c=Ct(),l=ef(),{mergeOptions:d,optionsAtMedia:y,optionsMediaQueries:g}=o,{on:m,off:x,emit:f}=l,u=h;let j=!1,v,b=d(tf,Jt.globalOptions),C=d(b),S=[],O,_,D;function E(){const{container:K,slides:I}=C;_=(En(K)?e.querySelector(K):K)||e.children[0];const W=En(I)?_.querySelectorAll(I):I;D=[].slice.call(W||_.children)}function A(K){const I=Zu(e,_,D,s,a,K,l);if(K.loop&&!I.slideLooper.canLoop()){const U=Object.assign({},K,{loop:!1});return A(U)}return I}function M(K,I){j||(b=d(b,K),C=y(b),S=I||S,E(),v=A(C),g([b,...S.map(({options:U})=>U)]).forEach(U=>c.add(U,"change",h)),C.active&&(v.translate.to(v.location.get()),v.animation.init(),v.slidesInView.init(),v.slideFocus.init(ne),v.eventHandler.init(ne),v.resizeHandler.init(ne),v.slidesHandler.init(ne),v.options.loop&&v.slideLooper.loop(),_.offsetParent&&D.length&&v.dragHandler.init(ne),O=i.init(ne,S)))}function h(K,I){const U=L();T(),M(d({startIndex:U},K),I),l.emit("reInit")}function T(){v.dragHandler.destroy(),v.eventStore.clear(),v.translate.clear(),v.slideLooper.clear(),v.resizeHandler.destroy(),v.slidesHandler.destroy(),v.slidesInView.destroy(),v.animation.destroy(),i.destroy(),c.clear()}function Q(){j||(j=!0,c.clear(),T(),l.emit("destroy"),l.clear())}function R(K,I,U){!C.active||j||(v.scrollBody.useBaseFriction().useDuration(I===!0?0:C.duration),v.scrollTo.index(K,U||0))}function V(K){const I=v.index.add(1).get();R(I,K,-1)}function ue(K){const I=v.index.add(-1).get();R(I,K,1)}function le(){return v.index.add(1).get()!==L()}function ee(){return v.index.add(-1).get()!==L()}function H(){return v.scrollSnapList}function ye(){return v.scrollProgress.get(v.offsetLocation.get())}function L(){return v.index.get()}function se(){return v.indexPrevious.get()}function me(){return v.slidesInView.get()}function G(){return v.slidesInView.get(!1)}function ve(){return O}function ce(){return v}function te(){return e}function N(){return _}function fe(){return D}const ne={canScrollNext:le,canScrollPrev:ee,containerNode:N,internalEngine:ce,destroy:Q,off:x,on:m,emit:f,plugins:ve,previousScrollSnap:se,reInit:u,rootNode:te,scrollNext:V,scrollPrev:ue,scrollProgress:ye,scrollSnapList:H,scrollTo:R,selectedScrollSnap:L,slideNodes:fe,slidesInView:me,slidesNotInView:G};return M(t,r),setTimeout(()=>l.emit("init"),0),ne}Jt.globalOptions=void 0;function Gn(e={},t=[]){const r=p.useRef(e),s=p.useRef(t),[a,o]=p.useState(),[i,c]=p.useState(),l=p.useCallback(()=>{a&&a.reInit(r.current,s.current)},[a]);return p.useEffect(()=>{Vn(r.current,e)||(r.current=e,l())},[e,l]),p.useEffect(()=>{Iu(s.current,t)||(s.current=t,l())},[t,l]),p.useEffect(()=>{if(wu()&&i){Jt.globalOptions=Gn.globalOptions;const d=Jt(i,r.current,s.current);return o(d),()=>d.destroy()}else o(void 0)},[i,o]),[c,a]}Gn.globalOptions=void 0;const sf={context:"[@mantine/carousel] Carousel.Slide was rendered outside of Carousel context"},[af,of]=ms(sf.context);var cf=Object.defineProperty,lf=Object.defineProperties,df=Object.getOwnPropertyDescriptors,es=Object.getOwnPropertySymbols,uf=Object.prototype.hasOwnProperty,ff=Object.prototype.propertyIsEnumerable,ts=(e,t,r)=>t in e?cf(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,yn=(e,t)=>{for(var r in t||(t={}))uf.call(t,r)&&ts(e,r,t[r]);if(es)for(var r of es(t))ff.call(t,r)&&ts(e,r,t[r]);return e},pf=(e,t)=>lf(e,df(t)),gf=Ge((e,{controlSize:t,controlsOffset:r,orientation:s,height:a,includeGapInSize:o,breakpoints:i=[],slideGap:c})=>{const l=s==="horizontal",d=m=>{if(!o)return{};const x=Ie({size:m,sizes:e.spacing});return{[s==="horizontal"?"marginRight":"marginBottom"]:`calc(${x} * -1)`}},g=i.some(m=>typeof m.slideGap<"u"||typeof m.slideSize<"u")?As(e,i).reduce((m,x)=>{const f="maxWidth"in x?"max-width":"min-width",u=Ie({size:f==="max-width"?x.maxWidth:x.minWidth,sizes:e.breakpoints}),j=typeof x.slideGap>"u"?void 0:$(x.slideGap),v=Ps(u)-(f==="max-width"?1:0);return m[`@media (${f}: ${$(v)})`]=d(j),m},{}):null;return{root:{position:"relative"},viewport:{height:$(a),overflow:"hidden"},container:yn(yn({display:"flex",flexDirection:l?"row":"column",height:$(a)},d(c)),g),controls:{position:"absolute",zIndex:1,left:l?0:`calc(50% - ${$(t)} / 2)`,right:l?0:void 0,top:l?`calc(50% - ${$(t)} / 2)`:0,bottom:l?void 0:0,display:"flex",flexDirection:l?"row":"column",alignItems:"center",justifyContent:"space-between",paddingLeft:l?Ie({size:r,sizes:e.spacing}):void 0,paddingRight:l?Ie({size:r,sizes:e.spacing}):void 0,paddingTop:l?void 0:Ie({size:r,sizes:e.spacing}),paddingBottom:l?void 0:Ie({size:r,sizes:e.spacing}),pointerEvents:"none"},control:pf(yn({display:"flex",justifyContent:"center",alignItems:"center",minWidth:$(t),minHeight:$(t),borderRadius:$(t),pointerEvents:"all",backgroundColor:e.white,color:e.black,boxShadow:e.shadows.md,opacity:e.colorScheme==="dark"?.65:.85,border:`${$(1)} solid ${e.colors.gray[3]}`,transition:`opacity 150ms ${e.transitionTimingFunction}`},e.fn.hover({opacity:1})),{"&:active":e.activeStyles}),indicators:{position:"absolute",bottom:l?e.spacing.md:0,top:l?void 0:0,left:l?0:void 0,right:l?0:e.spacing.md,display:"flex",flexDirection:l?"row":"column",justifyContent:"center",gap:$(8),pointerEvents:"none"},indicator:{pointerEvents:"all",width:l?$(25):$(5),height:l?$(5):$(25),borderRadius:e.radius.xl,backgroundColor:e.white,boxShadow:e.shadows.sm,opacity:.6,transition:`opacity 150ms ${e.transitionTimingFunction}`,"&[data-active]":{opacity:1}}}}),mf=Object.defineProperty,ns=Object.getOwnPropertySymbols,hf=Object.prototype.hasOwnProperty,xf=Object.prototype.propertyIsEnumerable,rs=(e,t,r)=>t in e?mf(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,vn=(e,t)=>{for(var r in t||(t={}))hf.call(t,r)&&rs(e,r,t[r]);if(ns)for(var r of ns(t))xf.call(t,r)&&rs(e,r,t[r]);return e},yf=Ge((e,{size:t,gap:r,orientation:s,includeGapInSize:a,breakpoints:o=[]})=>{const i=(d,y)=>{const g=Ie({size:d,sizes:e.spacing}),m=$(y),x=a?{[s==="horizontal"?"paddingRight":"paddingBottom"]:g}:{[s==="horizontal"?"marginRight":"marginBottom"]:g};return vn({flex:`0 0 ${m}`},x)},l=o.some(d=>typeof d.slideGap<"u"||typeof d.slideSize<"u")?As(e,o).reduce((d,y)=>{const g="maxWidth"in y?"max-width":"min-width",m=Ie({size:g==="max-width"?y.maxWidth:y.minWidth,sizes:e.breakpoints}),x=typeof y.slideGap>"u"?r:y.slideGap,f=Ps(m)-(g==="max-width"?1:0);return d[`@media (${g}: ${$(f)})`]=i(x,y.slideSize),d},{}):null;return{slide:vn(vn({position:"relative"},i(r,t)),l)}}),vf=Object.defineProperty,Xt=Object.getOwnPropertySymbols,Na=Object.prototype.hasOwnProperty,Ta=Object.prototype.propertyIsEnumerable,ss=(e,t,r)=>t in e?vf(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,jf=(e,t)=>{for(var r in t||(t={}))Na.call(t,r)&&ss(e,r,t[r]);if(Xt)for(var r of Xt(t))Ta.call(t,r)&&ss(e,r,t[r]);return e},bf=(e,t)=>{var r={};for(var s in e)Na.call(e,s)&&t.indexOf(s)<0&&(r[s]=e[s]);if(e!=null&&Xt)for(var s of Xt(e))t.indexOf(s)<0&&Ta.call(e,s)&&(r[s]=e[s]);return r};const ka=p.forwardRef((e,t)=>{var r=e,{children:s,className:a,size:o,gap:i}=r,c=bf(r,["children","className","size","gap"]);const l=of(),{classes:d,cx:y}=yf({gap:typeof i>"u"?l.slideGap:i,size:typeof o>"u"?l.slideSize:o,orientation:l.orientation,includeGapInSize:l.includeGapInSize,breakpoints:l.breakpoints},{name:"Carousel",classNames:l.classNames,styles:l.styles,unstyled:l.unstyled,variant:l.variant});return k.createElement(We,jf({className:y(d.slide,a),ref:t},c),s)});ka.displayName="@mantine/carousel/CarouselSlide";function as({dir:e,orientation:t,direction:r}){return r==="previous"?t==="horizontal"?90*(e==="ltr"?1:-1):-180:t==="horizontal"?90*(e==="ltr"?-1:1):0}var Cf=Object.defineProperty,Zt=Object.getOwnPropertySymbols,$a=Object.prototype.hasOwnProperty,Fa=Object.prototype.propertyIsEnumerable,os=(e,t,r)=>t in e?Cf(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Df=(e,t)=>{for(var r in t||(t={}))$a.call(t,r)&&os(e,r,t[r]);if(Zt)for(var r of Zt(t))Fa.call(t,r)&&os(e,r,t[r]);return e},Sf=(e,t)=>{var r={};for(var s in e)$a.call(e,s)&&t.indexOf(s)<0&&(r[s]=e[s]);if(e!=null&&Zt)for(var s of Zt(e))t.indexOf(s)<0&&Fa.call(e,s)&&(r[s]=e[s]);return r};const wf={controlSize:26,controlsOffset:"sm",slideSize:"100%",slideGap:0,orientation:"horizontal",align:"center",slidesToScroll:1,includeGapInSize:!0,draggable:!0,dragFree:!1,loop:!1,speed:10,initialSlide:0,inViewThreshold:0,withControls:!0,withIndicators:!1,skipSnaps:!1,containScroll:"",withKeyboardEvents:!0},qn=p.forwardRef((e,t)=>{const r=qe("Carousel",wf,e),{children:s,className:a,getEmblaApi:o,onNextSlide:i,onPreviousSlide:c,onSlideChange:l,nextControlLabel:d,previousControlLabel:y,controlSize:g,controlsOffset:m,classNames:x,styles:f,unstyled:u,slideSize:j,slideGap:v,orientation:b,height:C,align:S,slidesToScroll:O,includeGapInSize:_,draggable:D,dragFree:E,loop:A,speed:M,initialSlide:h,inViewThreshold:T,withControls:Q,withIndicators:R,plugins:V,nextControlIcon:ue,previousControlIcon:le,breakpoints:ee,skipSnaps:H,containScroll:ye,withKeyboardEvents:L,variant:se}=r,me=Sf(r,["children","className","getEmblaApi","onNextSlide","onPreviousSlide","onSlideChange","nextControlLabel","previousControlLabel","controlSize","controlsOffset","classNames","styles","unstyled","slideSize","slideGap","orientation","height","align","slidesToScroll","includeGapInSize","draggable","dragFree","loop","speed","initialSlide","inViewThreshold","withControls","withIndicators","plugins","nextControlIcon","previousControlIcon","breakpoints","skipSnaps","containScroll","withKeyboardEvents","variant"]),{classes:G,cx:ve,theme:ce}=gf({controlSize:g,controlsOffset:m,orientation:b,height:C,includeGapInSize:_,breakpoints:ee,slideGap:v},{name:"Carousel",classNames:x,styles:f,unstyled:u,variant:se}),[te,N]=Gn({axis:b==="horizontal"?"x":"y",direction:b==="horizontal"?ce.dir:void 0,startIndex:h,loop:A,align:S,slidesToScroll:O,draggable:D,dragFree:E,speed:M,inViewThreshold:T,skipSnaps:H,containScroll:ye},V),[fe,ne]=p.useState(0),[K,I]=p.useState(0),U=p.useCallback(ae=>N&&N.scrollTo(ae),[N]),W=p.useCallback(()=>{if(!N)return;const ae=N.selectedScrollSnap();ne(ae),l?.(ae)},[N,ne]),re=p.useCallback(()=>{N?.scrollPrev(),c?.()},[N]),pe=p.useCallback(()=>{N?.scrollNext(),i?.()},[N]),de=p.useCallback(ae=>{L&&(ae.key==="ArrowRight"&&(ae.preventDefault(),pe()),ae.key==="ArrowLeft"&&(ae.preventDefault(),re()))},[N]);p.useEffect(()=>{if(N)return o?.(N),W(),I(N.scrollSnapList().length),N.on("select",W),()=>{N.off("select",W)}},[N,O]),p.useEffect(()=>{N&&(N.reInit(),I(N.scrollSnapList().length),ne(ae=>Mo(ae,0,p.Children.toArray(s).length-1)))},[p.Children.toArray(s).length,O]);const je=N?.canScrollPrev()||!1,ge=N?.canScrollNext()||!1,be=Array(K).fill(0).map((ae,Me)=>k.createElement(ln,{key:Me,"data-active":Me===fe||void 0,className:G.indicator,"aria-hidden":!0,tabIndex:-1,onClick:()=>U(Me)}));return k.createElement(af,{value:{slideGap:v,slideSize:j,embla:N,orientation:b,includeGapInSize:_,breakpoints:ee,classNames:x,styles:f,unstyled:u,variant:se}},k.createElement(We,Df({className:ve(G.root,a),ref:t,onKeyDownCapture:de},me),k.createElement("div",{className:G.viewport,ref:te},k.createElement("div",{className:G.container},s)),R&&k.createElement("div",{className:G.indicators},be),Q&&k.createElement("div",{className:G.controls},k.createElement(ln,{onClick:re,className:G.control,"aria-label":y,"data-inactive":!je||void 0,tabIndex:je?0:-1},typeof le<"u"?le:k.createElement(nr,{style:{transform:`rotate(${as({dir:ce.dir,orientation:b,direction:"previous"})}deg)`}})),k.createElement(ln,{onClick:pe,className:G.control,"aria-label":d,"data-inactive":!ge||void 0,tabIndex:ge?0:-1},typeof ue<"u"?ue:k.createElement(nr,{style:{transform:`rotate(${as({dir:ce.dir,orientation:b,direction:"next"})}deg)`}})))))});qn.Slide=ka;qn.displayName="@mantine/carousel/Carousel";const is=qn,If=({chargeProps:e,onChange:t})=>{const{additionalDocuments:r}=B(Ns,e),[s,a]=p.useState(void 0);return n.jsx("div",{className:"container mx-auto text-gray-600 body-font",children:r?.length>0?n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"flex flex-wrap",children:n.jsx(is,{sx:{maxWidth:320},mx:"auto",align:"center",withControls:r.length>1,slideGap:0,withIndicators:!0,className:"[&>*>.mantine-Carousel-indicator]:bg-gray-500",children:r.map(o=>n.jsx(is.Slide,{children:n.jsxs("div",{className:"flex flex-col items-center",children:[n.jsx("h2",{className:"text-gray-900 text-base font-medium",children:"documentType"in o?o.documentType:"Unprocessed"}),n.jsx("button",{className:"mx-10",onClick:()=>a(o.id),children:n.jsx("div",{className:"flex rounded-lg h-full bg-gray-100 p-2 m-2 flex-col",children:n.jsx(Ro,{src:o.image?.toString(),withPlaceholder:!0})})})]})},o.id))})}),n.jsx(zo,{documentId:s,onDone:()=>a(void 0),onChange:t})]}):n.jsx(Cn,{color:"red",children:"No Documents Related"})})},Ft=({foreignAmount:e,localAmount:t,diff:r})=>{const s=e!=null&&e.currency!==sn.Ils,a=r&&r.localAmount?.formatted!==t?.formatted,o=r&&r.foreignAmount?.formatted!==e?.formatted;return n.jsx("div",{className:"flex flex-col",children:(t||a)&&n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"flex gap-2 items-center",children:[s&&n.jsx("p",{className:o?"line-through":"",children:e.formatted}),o&&r.foreignAmount&&n.jsx("p",{className:"border-2 border-yellow-500 rounded-md",children:r.foreignAmount.formatted})]}),n.jsxs("div",{className:"flex gap-2 items-center",children:[t!=null&&n.jsx("p",{className:a?"line-through":"",children:t.formatted}),a&&r.localAmount&&n.jsx("p",{className:"border-2 border-yellow-500 rounded-md",children:r.localAmount.formatted})]})]})})},Mt=({account:e,diffAccount:t})=>{const r=t&&t?.id!==e?.id;return n.jsx("div",{className:"flex flex-col whitespace-normal",children:(e||r)&&n.jsxs(n.Fragment,{children:[e&&n.jsx(yt,{to:st.BUSINESSES.DETAIL(e.id),target:"_blank",rel:"noreferrer",onClick:s=>s.stopPropagation(),className:`inline-flex items-center font-semibold ${r?"line-through":""}`,children:e.name}),r&&t&&n.jsx("div",{className:"border-2 border-yellow-500 rounded-md",children:n.jsx(yt,{to:st.BUSINESSES.DETAIL(t.id),target:"_blank",rel:"noreferrer",onClick:s=>s.stopPropagation(),className:"inline-flex items-center font-semibold",children:t.name})})]})})},cs=({date:e,diff:t})=>{const r=e?He(new Date(e),"dd/MM/yy"):void 0,s=t?He(new Date(t),"dd/MM/yy"):void 0,a=s&&r!==s;return n.jsxs(n.Fragment,{children:[n.jsx("p",{className:a?"line-through":"",children:r??"Missing Data"}),a&&n.jsx("div",{className:"flex flex-col border-2 border-yellow-500 rounded-md",children:s})]})},Rt=(e,t)=>{const r=e.original[t],s=e.original.diff?.[t];return!r&&!s},ls=[{accessorKey:"invoiceDate",header:({column:e})=>n.jsxs(q,{variant:"ghost",onClick:()=>e.toggleSorting(e.getIsSorted()==="asc"),children:["Invoice Date",e.getIsSorted()&&(e.getIsSorted()==="asc"?n.jsx(we,{className:"ml-2 h-4 w-4"}):n.jsx(Ce,{className:"ml-2 h-4 w-4"}))]}),cell:({row:e})=>n.jsx(cs,{date:e.original.invoiceDate,diff:e.original.diff?.invoiceDate})},{accessorKey:"valueDate",header:({column:e})=>n.jsxs(q,{variant:"ghost",onClick:()=>e.toggleSorting(e.getIsSorted()==="asc"),children:["Value Date",e.getIsSorted()&&(e.getIsSorted()==="asc"?n.jsx(we,{className:"ml-2 h-4 w-4"}):n.jsx(Ce,{className:"ml-2 h-4 w-4"}))]}),cell:({row:e})=>n.jsx(cs,{date:e.original.valueDate,diff:e.original.diff?.valueDate})},{header:"Debit Account (Main)",columns:[{accessorKey:"debitAccount1.name",header:({column:e})=>n.jsxs(q,{variant:"ghost",onClick:()=>e.toggleSorting(e.getIsSorted()==="asc"),children:["Account",e.getIsSorted()&&(e.getIsSorted()==="asc"?n.jsx(we,{className:"ml-2 h-4 w-4"}):n.jsx(Ce,{className:"ml-2 h-4 w-4"}))]}),cell:({row:e})=>n.jsx(Mt,{account:e.original.debitAccount1,diffAccount:e.original.diff?.debitAccount1})},{accessorKey:"localCurrencyDebitAmount1.raw",header:({column:e})=>n.jsxs(q,{variant:"ghost",onClick:()=>e.toggleSorting(e.getIsSorted()==="asc"),children:["Amount",e.getIsSorted()&&(e.getIsSorted()==="asc"?n.jsx(we,{className:"ml-2 h-4 w-4"}):n.jsx(Ce,{className:"ml-2 h-4 w-4"}))]}),cell:({row:e})=>Rt(e,"debitAccount1")?null:n.jsx(Ft,{foreignAmount:e.original.debitAmount1,localAmount:e.original.localCurrencyDebitAmount1,diff:e.original.diff?{foreignAmount:e.original.diff.debitAmount1,localAmount:e.original.diff.localCurrencyDebitAmount1}:void 0})}]},{header:"Credit Account (Main)",columns:[{accessorKey:"creditAccount1.name",header:({column:e})=>n.jsxs(q,{variant:"ghost",onClick:()=>e.toggleSorting(e.getIsSorted()==="asc"),children:["Account",e.getIsSorted()&&(e.getIsSorted()==="asc"?n.jsx(we,{className:"ml-2 h-4 w-4"}):n.jsx(Ce,{className:"ml-2 h-4 w-4"}))]}),cell:({row:e})=>n.jsx(Mt,{account:e.original.creditAccount1,diffAccount:e.original.diff?.creditAccount1})},{accessorKey:"localCurrencyCreditAmount1.raw",header:({column:e})=>n.jsxs(q,{variant:"ghost",onClick:()=>e.toggleSorting(e.getIsSorted()==="asc"),children:["Amount",e.getIsSorted()&&(e.getIsSorted()==="asc"?n.jsx(we,{className:"ml-2 h-4 w-4"}):n.jsx(Ce,{className:"ml-2 h-4 w-4"}))]}),cell:({row:e})=>Rt(e,"creditAccount1")?null:n.jsx(Ft,{foreignAmount:e.original.creditAmount1,localAmount:e.original.localCurrencyCreditAmount1,diff:e.original.diff?{foreignAmount:e.original.diff.creditAmount1,localAmount:e.original.diff.localCurrencyCreditAmount1}:void 0})}]},{header:"Debit Account (Secondary)",columns:[{accessorKey:"debitAccount2.name",header:({column:e})=>n.jsxs(q,{variant:"ghost",onClick:()=>e.toggleSorting(e.getIsSorted()==="asc"),children:["Account",e.getIsSorted()&&(e.getIsSorted()==="asc"?n.jsx(we,{className:"ml-2 h-4 w-4"}):n.jsx(Ce,{className:"ml-2 h-4 w-4"}))]}),cell:({row:e})=>n.jsx(Mt,{account:e.original.debitAccount2,diffAccount:e.original.diff?.debitAccount2})},{accessorKey:"localCurrencyDebitAmount2.raw",header:({column:e})=>n.jsxs(q,{variant:"ghost",onClick:()=>e.toggleSorting(e.getIsSorted()==="asc"),children:["Amount",e.getIsSorted()&&(e.getIsSorted()==="asc"?n.jsx(we,{className:"ml-2 h-4 w-4"}):n.jsx(Ce,{className:"ml-2 h-4 w-4"}))]}),cell:({row:e})=>Rt(e,"debitAccount2")?null:n.jsx(Ft,{foreignAmount:e.original.debitAmount2,localAmount:e.original.localCurrencyDebitAmount2,diff:e.original.diff?{foreignAmount:e.original.diff.debitAmount2,localAmount:e.original.diff.localCurrencyDebitAmount2}:void 0})}]},{header:"Credit Account (Secondary)",columns:[{accessorKey:"creditAccount2.name",header:({column:e})=>n.jsxs(q,{variant:"ghost",onClick:()=>e.toggleSorting(e.getIsSorted()==="asc"),children:["Account",e.getIsSorted()&&(e.getIsSorted()==="asc"?n.jsx(we,{className:"ml-2 h-4 w-4"}):n.jsx(Ce,{className:"ml-2 h-4 w-4"}))]}),cell:({row:e})=>n.jsx(Mt,{account:e.original.creditAccount2,diffAccount:e.original.diff?.creditAccount2})},{accessorKey:"localCurrencyCreditAmount2.raw",header:({column:e})=>n.jsxs(q,{variant:"ghost",onClick:()=>e.toggleSorting(e.getIsSorted()==="asc"),children:["Amount",e.getIsSorted()&&(e.getIsSorted()==="asc"?n.jsx(we,{className:"ml-2 h-4 w-4"}):n.jsx(Ce,{className:"ml-2 h-4 w-4"}))]}),cell:({row:e})=>Rt(e,"creditAccount2")?null:n.jsx(Ft,{foreignAmount:e.original.creditAmount2,localAmount:e.original.localCurrencyCreditAmount2,diff:e.original.diff?{foreignAmount:e.original.diff.creditAmount2,localAmount:e.original.diff.localCurrencyCreditAmount2}:void 0})}]},{accessorKey:"description",header:({column:e})=>n.jsxs(q,{variant:"ghost",onClick:()=>e.toggleSorting(e.getIsSorted()==="asc"),children:["Details",e.getIsSorted()&&(e.getIsSorted()==="asc"?n.jsx(we,{className:"ml-2 h-4 w-4"}):n.jsx(Ce,{className:"ml-2 h-4 w-4"}))]}),cell:({row:{original:e}})=>{const t=e.diff&&e.diff.description!==e.description;return n.jsxs("div",{className:"flex flex-col whitespace-normal",children:[n.jsx("p",{className:t?"line-through":"",children:e.description}),t&&n.jsx("div",{className:"border-2 border-yellow-500 rounded-md",children:e.diff?.description})]})}},{accessorKey:"reference",header:({column:e})=>n.jsxs(q,{variant:"ghost",onClick:()=>e.toggleSorting(e.getIsSorted()==="asc"),children:["Reference",e.getIsSorted()&&(e.getIsSorted()==="asc"?n.jsx(we,{className:"ml-2 h-4 w-4"}):n.jsx(Ce,{className:"ml-2 h-4 w-4"}))]}),cell:({row:{original:e}})=>{const t=e.diff&&e.diff.reference!==e.reference;return n.jsxs("div",{className:"flex flex-col whitespace-normal",children:[n.jsx("p",{className:t?"line-through":"",children:e.reference}),t&&n.jsx("div",{className:"border-2 border-yellow-500 rounded-md",children:e.diff?.reference})]})}},{accessorKey:"matchingStatus",header:({column:e})=>n.jsxs(q,{variant:"ghost",onClick:()=>e.toggleSorting(e.getIsSorted()==="asc"),children:["Status",e.getIsSorted()&&(e.getIsSorted()==="asc"?n.jsx(we,{className:"ml-2 h-4 w-4"}):n.jsx(Ce,{className:"ml-2 h-4 w-4"}))]}),cell:({row:{original:{matchingStatus:e}}})=>{if(e){const t=e==="Deleted"?"bg-red-500":e==="Diff"?"bg-yellow-500":"bg-green-500";return n.jsx(Ts,{variant:"default",className:t,children:e})}return null}}];function _f(e){let t="";switch(e){case"New":t="bg-green-100/30";break;case"Deleted":t="bg-red-100/30";break;case"Diff":t="bg-yellow-100/30";break}return t}const Ef=({ledgerRecordsData:e,ledgerDiffData:t,matches:r})=>{const[s,a]=p.useState([]),o=p.useMemo(()=>{const c=e.map(g=>B(rr,g)),l=t?.map(g=>B(rr,g)),d=c.map(g=>{const m=l?.find(x=>x.id===g.id);return{...g,matchingStatus:!r||r?.includes(g.id)?void 0:m?"Diff":"Deleted",diff:m}}),y=l?.filter(g=>g.id===Lo).map(g=>({...g,matchingStatus:"New"}))??[];return d.push(...y),d},[e,t,r]),i=Tn({data:o,columns:ls,getCoreRowModel:$n(),onSortingChange:a,getSortedRowModel:kn(),getPaginationRowModel:Bo(),state:{sorting:s},initialState:{pagination:{pageIndex:0,pageSize:100},sorting:[{id:"invoiceDate",desc:!0}]}});return n.jsxs(n.Fragment,{children:[n.jsxs(tn,{children:[n.jsx(nn,{children:i.getHeaderGroups().map(c=>n.jsx(Ne,{children:c.headers.map(l=>n.jsx(Ae,{className:"text-center",colSpan:l.colSpan,children:l.isPlaceholder?null:rt(l.column.columnDef.header,l.getContext())},l.id))},c.id))}),n.jsx(rn,{children:i.getRowModel().rows?.length?i.getRowModel().rows.map(c=>n.jsx(Ne,{"data-state":c.getIsSelected()&&"selected",className:_f(c.original.matchingStatus),children:c.getVisibleCells().map(l=>n.jsx(xe,{children:rt(l.column.columnDef.cell,l.getContext())},l.id))},c.id)):n.jsx(Ne,{children:n.jsx(xe,{colSpan:ls.length,className:"h-24 text-center",children:"No results."})})})]}),n.jsx("div",{className:"flex items-center justify-end space-x-2 py-4",children:n.jsx(Vo,{currentPageIndex:i.getState().pagination.pageIndex,totalPages:i.getPageCount(),onChange:c=>i.setPageIndex(c)})})]})},Of=({data:e})=>{const t=B($s,e);return t?.errorsLedger?.validate?.errors?.length?n.jsxs(ks,{shadow:"xs",p:"md",children:[n.jsx(Be,{c:"red",children:"Errors:"}),n.jsx(dr,{size:"sm",withPadding:!0,children:t.errorsLedger.validate.errors.map((r,s)=>n.jsx(dr.Item,{children:n.jsx(Be,{c:"red",children:r})},s))})]}):null},Af=({transactionsProps:e,onChange:t})=>{const{transactions:r}=B(Fs,e);return n.jsx(Hs,{transactionsProps:r,onChange:t,enableEdit:!0})},Pf="createDeposit",Nf=()=>{const[{fetching:e},t]=Ee(Uo),r=p.useCallback(async s=>{const a=`Error creating new deposit in currency ${s.currency}`,o=`${Pf}-${s.currency}`;F.loading("Creating deposit",{id:o});try{const i=await t(s),c=Oe(i,a,o);if(c)return F.success("Deposit created",{id:o,description:`Deposit ${c.createDeposit.id} (${c.createDeposit.currency}) created successfully`}),c.createDeposit.id}catch(i){console.error(`${a}: ${i}`),F.error("Error",{id:o,description:a,duration:1e5,closeButton:!0})}return null},[t]);return{creating:e,createDeposit:r}},Tf=({chargeId:e,onChange:t})=>{const[{data:r,fetching:s}]=ke({query:Ko,variables:{chargeId:e}}),[{data:a,fetching:o}]=ke({query:Ho}),{creating:i,createDeposit:c}=Nf(),{assigning:l,assignChargeToDeposit:d}=Si(),[y,g]=p.useState(void 0),[m,x]=p.useState(!1),[f,u]=p.useState("ILS"),j=p.useMemo(()=>(a?.allDeposits??[]).filter(S=>S.isOpen),[a?.allDeposits]),v=p.useCallback(async()=>{const S=await c({currency:f});S&&(await d({chargeId:e,depositId:S}),x(!1),t?.())},[c,d,f,e,t]),b=p.useCallback(async()=>{y&&(await d({chargeId:e,depositId:y}),t?.())},[d,y,e,t]);return s||o||i||l?n.jsx(Mn,{className:"h-10 w-10 animate-spin"}):r?.depositByCharge?n.jsxs("div",{children:[n.jsxs("div",{className:"text-lg font-semibold mb-4",children:['Bank Deposit "',r?.depositByCharge?.id,'" Balance:'," ",r?.depositByCharge?.currentBalance.formatted]}),n.jsx("div",{className:"mb-4",children:n.jsx("span",{className:"text-sm text-gray-500",children:r?.depositByCharge?.isOpen?"Deposit is open":"Deposit is closed"})}),n.jsx(wi,{depositId:r.depositByCharge.id})]}):n.jsxs("div",{className:"space-y-4",children:[n.jsx("div",{className:"text-sm text-gray-500",children:"No bank deposit found for this charge."}),n.jsxs("div",{className:"flex items-center gap-4 flex-wrap",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsxs(sr,{value:y,onValueChange:S=>g(S),children:[n.jsx(ar,{className:"min-w-[220px]",children:n.jsx(or,{placeholder:j.length?"Select open deposit":"No open deposits"})}),n.jsx(ir,{children:j.map(S=>n.jsxs(cr,{value:S.id,children:[S.id," (",S.currency,")"]},S.id))})]}),n.jsx(q,{variant:"secondary",disabled:!y||l,onClick:b,children:l?"Assigning…":"Assign"})]}),n.jsx(q,{variant:"outline",onClick:()=>x(!0),children:"Create New Deposit"})]}),n.jsx(St,{open:m,onOpenChange:x,children:n.jsxs(wt,{children:[n.jsx(Pn,{children:n.jsx(Nn,{children:"Create Bank Deposit"})}),n.jsx("div",{className:"space-y-4",children:n.jsxs("div",{className:"flex flex-col gap-2",children:[n.jsx(Go,{htmlFor:"deposit-currency-select",children:"Currency"}),n.jsxs(sr,{value:f,onValueChange:S=>u(S),children:[n.jsx(ar,{className:"w-40",children:n.jsx(or,{id:"deposit-currency-select"})}),n.jsx(ir,{children:Object.entries(sn).map(([S,O])=>n.jsx(cr,{value:O,children:O},S))})]})]})}),n.jsx(qo,{children:n.jsx(q,{variant:"secondary",disabled:i,onClick:v,children:i?"Creating…":"Create"})})]})})]})};function kf({row:e}){const[t,r]=p.useState(["transactions","documents"]),[{data:s,fetching:a}]=ke({query:Wo,variables:{chargeId:e.original.id??""},pause:!e.original.id}),o=s?.charge.transactions,i=!!o&&o.length>0,c=s?.charge.additionalDocuments,l=!!c&&c.length>0;return n.jsxs(Ei,{type:"multiple",value:t,onValueChange:r,className:"space-y-4",children:[i&&n.jsxs(fr,{value:"transactions",className:"rounded-lg border-2",children:[n.jsx("div",{className:"px-2 bg-gray-600/10 rounded-t-lg",children:n.jsx(pr,{className:"hover:no-underline p-2",disabled:!i,children:n.jsx("h3",{className:"font-semibold text-lg",children:"Transactions"})})}),a?n.jsx(Ot,{children:n.jsx("div",{className:"p-2",children:n.jsx(Wr,{})})}):n.jsx(Ot,{children:o&&n.jsx("div",{className:"p-2",children:n.jsx(Hs,{transactionsProps:o})})})]}),l&&n.jsxs(fr,{value:"documents",className:"rounded-lg border-2",children:[n.jsx("div",{className:"px-2 bg-gray-600/10 rounded-t-lg",children:n.jsx(pr,{className:"hover:no-underline p-2",disabled:!l,children:n.jsx("h3",{className:"font-semibold text-lg",children:"Documents"})})}),a?n.jsx(Ot,{children:n.jsx("div",{className:"p-2",children:n.jsx(Wr,{})})}):n.jsx(Ot,{children:c&&n.jsx("div",{className:"p-2",children:n.jsx(Ms,{documentsProps:c})})})]})]})}const $f=({row:e})=>{const[t,r]=p.useState(!1);return n.jsxs(n.Fragment,{children:[n.jsxs(Ne,{children:[e.getVisibleCells().map(s=>n.jsx(xe,{children:rt(s.column.columnDef.cell,s.getContext())},s.id)),n.jsx(xe,{children:n.jsx(Ks,{toggleExpansion:r,isExpanded:t})})]},e.id),t&&n.jsx(Ne,{children:n.jsx(xe,{colSpan:e.getVisibleCells().length+1,children:n.jsx(kf,{row:e})})},`${e.id}-extensions`)]})},Ff=({business:e})=>e.id?n.jsx(yt,{to:st.BUSINESSES.DETAIL(e.id),target:"_blank",rel:"noreferrer",onClick:t=>t.stopPropagation(),className:"inline-flex items-center font-semibold",children:e.name}):n.jsx("div",{}),Mf=({date:e})=>n.jsx("p",{className:"text-sm font-medium",children:e?.toLocaleDateString(void 0,{timeZone:"UTC"})}),Rf=({tags:e})=>n.jsx(an,{items:e.map(t=>n.jsx(zt,{children:n.jsxs("div",{children:[t.namePath&&n.jsx(Be,{size:"xs",opacity:.65,children:`${t.namePath.join(" > ")} >`}),n.jsx(Be,{size:"sm",children:t.name})]})},t.id))}),zf=({taxCategory:e})=>n.jsx("p",{className:"text-sm font-medium",children:e?.name}),Lf=({type:e})=>{const{text:t,icon:r}=p.useMemo(()=>({text:Rn(e),icon:Ws(e)}),[e]);return n.jsxs(n.Fragment,{children:[n.jsx("div",{children:t}),n.jsx(zn,{radius:"xl",size:"xl",children:r})]})},ds=[{id:"select",cell:({row:e})=>n.jsx(jn,{checked:e.original.isSelected,onCheckedChange:t=>(e.original.selectCharge(t?e.original.id:null),t),"aria-label":"Select charge"}),enableSorting:!1,enableHiding:!1},{accessorKey:"confidenceScore",header:({column:e})=>n.jsx(ze,{column:e,title:"Score"}),cell:({row:e})=>{const t=e.getValue("confidenceScore");return n.jsx(Zd,{value:t*100,size:"sm"})}},{accessorKey:"type",header:({column:e})=>n.jsx(ze,{column:e,title:"Type"}),cell:({row:e})=>n.jsx(Lf,{type:e.getValue("type")})},{accessorKey:"date",header:({column:e})=>n.jsx(ze,{column:e,title:"Date"}),cell:({row:e})=>n.jsx(Mf,{date:e.getValue("date")})},{accessorKey:"amountRaw",header:({column:e})=>n.jsx(ze,{column:e,title:"Amount"}),cell:({row:e})=>{const t=e.original.amountFormatted;return n.jsx("p",{className:"text-sm font-medium",children:t})}},{accessorKey:"vatAmountRaw",header:({column:e})=>n.jsx(ze,{column:e,title:"VAT"}),cell:({row:e})=>{const t=e.original.vatAmountFormatted;return n.jsx("p",{className:"text-sm font-medium",children:t})}},{accessorKey:"businessName",header:({column:e})=>n.jsx(ze,{column:e,title:"Main Business"}),cell:({row:e})=>n.jsx(Ff,{business:{id:e.original.businessId,name:e.original.businessName}})},{accessorKey:"description",header:({column:e})=>n.jsx(ze,{column:e,title:"Description"}),cell:({row:e})=>{const t=e.getValue("description");return n.jsx("p",{className:"text-sm font-medium max-w-100 whitespace-normal",children:t})}},{accessorKey:"tags",header:({column:e})=>n.jsx(ze,{column:e,title:"Tags"}),cell:({row:e})=>n.jsx(Rf,{tags:e.getValue("tags")}),enableSorting:!1},{accessorKey:"taxCategoryName",header:({column:e})=>n.jsx(ze,{column:e,title:"Tax Category"}),cell:({row:e})=>n.jsx(zf,{taxCategory:{id:e.original.taxCategoryId,name:e.original.taxCategoryName}})}];function Bf(e,t,r){const s=B(ei,e),a=s.charge.minDocumentsDate||s.charge.minEventDate||s.charge.minDebitDate||void 0;return{id:s.charge.id,confidenceScore:s.confidenceScore,type:s.charge.__typename,date:a?new Date(a):void 0,amountRaw:s.charge.totalAmount?.raw,amountFormatted:s.charge.totalAmount?.formatted,vatAmountRaw:s.charge.vat?.raw,vatAmountFormatted:s.charge.vat?.formatted,businessId:s.charge.counterparty?.id,businessName:s.charge.counterparty?.name,description:s.charge.userDescription??void 0,tags:s.charge.tags.map(o=>({id:o.id,name:o.name,namePath:o.namePath??void 0})),taxCategoryId:s.charge.taxCategory?.id,taxCategoryName:s.charge.taxCategory?.name,selectCharge:t,isSelected:s.charge.id===r}}const Vf=({originChargeId:e,chargesProps:t,onChange:r})=>{const[s,a]=p.useState([{id:"confidenceScore",desc:!0},{id:"amountRaw",desc:!0}]),[o,i]=p.useState([]),[c,l]=p.useState(null),[d,y]=p.useState([{id:e,onChange:r}]);p.useEffect(()=>{y([e,...c?[c]:[]].map(x=>({id:x,onChange:r})))},[c,r,e]);const g=p.useMemo(()=>t?.map(x=>Bf(x,l,c)).sort((x,f)=>f.confidenceScore-x.confidenceScore)??[],[t,c]),m=Tn({data:g,columns:ds,getCoreRowModel:$n(),onSortingChange:a,getSortedRowModel:kn(),onColumnFiltersChange:i,getFilteredRowModel:Yo(),state:{sorting:s,columnFilters:o}});return n.jsxs("div",{className:"max-w-[90vw]",children:[n.jsxs("div",{className:"flex items-center py-4 gap-4",children:[n.jsx(Hd,{selected:d,resetMerge:()=>l(null)}),n.jsxs(Qo,{children:[n.jsx(Jo,{asChild:!0,className:"ml-auto",children:n.jsxs(q,{variant:"outline",children:["Columns ",n.jsx(Ce,{})]})}),n.jsx(Xo,{align:"end",children:m.getAllColumns().filter(x=>x.getCanHide()).map(x=>n.jsx(Zo,{className:"capitalize",checked:x.getIsVisible(),onCheckedChange:f=>x.toggleVisibility(!!f),children:x.id},x.id))})]})]}),n.jsx("div",{className:"overflow-hidden rounded-md border",children:n.jsxs(tn,{children:[n.jsx(nn,{children:m.getHeaderGroups().map(x=>n.jsxs(Ne,{children:[x.headers.map(f=>n.jsx(Ae,{colSpan:f.colSpan,children:f.isPlaceholder?null:rt(f.column.columnDef.header,f.getContext())},f.id)),n.jsx(Ae,{})]},x.id))}),n.jsx(rn,{children:m.getRowModel().rows?.length?m.getRowModel().rows.map(x=>n.jsx($f,{row:x},x.id)):n.jsx(Ne,{children:n.jsx(xe,{colSpan:ds.length,className:"h-24 text-center",children:"No results."})})})]})})]})},Uf=({chargeId:e,toggleAccordionItem:t,isOpened:r,onChange:s})=>{const[{data:a,fetching:o}]=ke({query:ti,variables:{chargeId:e},pause:!r});return n.jsxs(z.Item,{value:"charges-matches",children:[n.jsx(z.Control,{onClick:()=>t("charges-matches"),children:"Charge Matches"}),n.jsx(z.Panel,{children:o?n.jsx(Mn,{className:"h-10 w-10 animate-spin"}):n.jsx(Vf,{originChargeId:e,chargesProps:a?.findChargeMatches.matches,onChange:s})})]})},Kf=({chargeProps:e})=>{const t=B(Rs,e);if(t.__typename!=="ConversionCharge")return n.jsx(n.Fragment,{});const{eventRate:r,officialRate:s}=t;return n.jsxs(dn,{justify:"center",children:[s&&n.jsx(dn.Col,{span:"content",children:n.jsx(ur,{shadow:"sm",padding:"xs",radius:"md",withBorder:!0,children:n.jsxs(zt,{position:"apart",children:[n.jsx(Be,{weight:500,children:"Official Conversion Rate"}),n.jsx(Cn,{color:"green",variant:"light",children:`${Number(s.rate)} ${nt(s.from)} => ${nt(s.to)}`})]})})}),r&&n.jsx(dn.Col,{span:"content",children:n.jsx(ur,{shadow:"sm",padding:"xs",radius:"md",withBorder:!0,children:n.jsxs(zt,{position:"apart",children:[n.jsx(Be,{weight:500,children:"Bank Conversion Rate"}),n.jsx(Cn,{color:"green",variant:"light",children:`${Number(r.rate)} ${nt(r.from)} => ${nt(r.to)}`})]})})})]})},Hf=({chargeProps:e})=>{const t=B(zs,e),r=p.useMemo(()=>t.__typename==="CreditcardBankCharge"&&t.creditCardTransactions?t.creditCardTransactions.map(s=>B(ni,s)):[],[t]);return r.length?n.jsxs(tn,{children:[n.jsx(nn,{children:n.jsxs(Ne,{children:[n.jsx(Ae,{children:"Event Date"}),n.jsx(Ae,{children:"Debit Date"}),n.jsx(Ae,{children:"Amount"}),n.jsx(Ae,{children:"Account"}),n.jsx(Ae,{children:"Description"}),n.jsx(Ae,{children:"Reference#"}),n.jsx(Ae,{children:"Counterparty"}),n.jsx(Ae,{children:"Charge"})]})}),n.jsx(rn,{children:r.map(s=>{const a={...s,onUpdate:()=>{},editTransaction:()=>{},enableEdit:!1,enableChargeLink:!1};return n.jsxs(Ne,{children:[n.jsx(xe,{children:n.jsx(fi,{transaction:a})}),n.jsx(xe,{children:n.jsx(pi,{transaction:a})}),n.jsx(xe,{children:n.jsx(gi,{transaction:a})}),n.jsx(xe,{children:n.jsx(mi,{transaction:a})}),n.jsx(xe,{children:n.jsx(hi,{transaction:a})}),n.jsx(xe,{children:n.jsx(xi,{transaction:a})}),n.jsx(xe,{children:n.jsx(yi,{transaction:a})}),n.jsx(xe,{children:n.jsx(vi,{chargeId:s.chargeId})})]},s.id)})})]}):null},Gf=({chargeProps:e})=>{const t=B(Ls,e),r=p.useMemo(()=>t.__typename!=="FinancialCharge"?[]:Object.entries(t.exchangeRates??{}).sort((s,a)=>s[0].localeCompare(a[0])),[t]);return t.__typename!=="FinancialCharge"?n.jsx(n.Fragment,{}):n.jsx("div",{className:"flex flex-row flex-wrap gap-2 px-2",children:r.map(([s,a])=>n.jsx(vs,{className:"gap-0 py-2",children:n.jsxs(ri,{className:"flex flex-col px-2",children:[n.jsx(si,{className:"text-xl font-semibold",children:s.toLocaleUpperCase()}),n.jsxs("div",{className:"flex items-center space-x-2",children:[n.jsxs("span",{className:"whitespace-nowrap",children:[nt(s.toLocaleUpperCase()),"1="]}),n.jsxs(Ts,{variant:"default",className:"flex gap-1 rounded-lg text-md",children:[nt(sn.Ils),a]})]})]})},s))})},qf="deleteMiscExpense",Wf=()=>{const[{fetching:e},t]=Ee(ai),r=p.useCallback(async s=>{const a="Error deleting misc expense",o=`${qf}-${s.id}`;F.loading("Deleting misc expense",{id:o});try{const i=await t(s),c=Oe(i,a,o);if(c)return F.success("Success",{id:o,description:"Misc expense was deleted successfully"}),c.deleteMiscExpense}catch(i){console.error(`${a}: ${i}`),F.error("Error",{id:o,description:a,duration:1e5,closeButton:!0})}},[t]);return{fetching:e,deleteMiscExpense:r}};function Yf({miscExpenseId:e,onChange:t}){const{deleteMiscExpense:r}=Wf();async function s(){try{await r({id:e}),t?.()}catch(a){const o="Failed to delete misc expense";console.error(`${o}: ${a}`),F.error("Error",{description:o})}}return n.jsx(en,{onConfirm:s,title:"Are you sure you want to delete this expense?",children:n.jsx(q,{className:"size-7.5 text-red-500",variant:"ghost",children:n.jsx(Fn,{className:"size-5"})})})}const Qf=({miscExpensesData:e,onChange:t})=>{const r=B(Bs,e),{miscExpenses:s}=r;return n.jsxs("table",{className:"w-full h-full",children:[n.jsx("thead",{children:n.jsxs("tr",{children:[n.jsx("th",{children:"Creditor"}),n.jsx("th",{children:"Debtor"}),n.jsx("th",{children:"Amount"}),n.jsx("th",{children:"Invoice Date"}),n.jsx("th",{children:"Value Date"}),n.jsx("th",{children:"Description"}),n.jsx("th",{children:"Actions"})]})}),n.jsx("tbody",{children:s?.map(a=>n.jsxs("tr",{children:[n.jsx("td",{children:n.jsx("div",{children:a.creditor?.name})}),n.jsx("td",{children:n.jsx("div",{children:a.debtor?.name})}),n.jsx("td",{children:n.jsx("div",{children:a.amount?.formatted})}),n.jsx("td",{children:n.jsx("div",{children:a.invoiceDate})}),n.jsx("td",{children:n.jsx("div",{children:a.valueDate&&He(new Date(a.valueDate),"yyyy-MM-dd")})}),n.jsx("td",{children:n.jsx("div",{children:a.description})}),n.jsxs("td",{children:[n.jsx(Gd,{onDone:t,data:a}),n.jsx(Yf,{miscExpenseId:a.id,onChange:t})]})]},a?.id))})]})},Jf=({salaryRecordsProps:e})=>{const t=B(Vs,e);if(t.__typename!=="SalaryCharge")return n.jsx(n.Fragment,{});const{salaryRecords:r}=t;return n.jsxs("table",{className:"w-full h-full",children:[n.jsx("thead",{children:n.jsxs("tr",{children:[n.jsx("th",{children:"Employee"}),n.jsx("th",{children:"Direct Salary"}),n.jsx("th",{children:"Base Salary"}),n.jsx("th",{children:"Pension"}),n.jsx("th",{children:"Training Fund"}),n.jsx("th",{children:"Social Security"}),n.jsx("th",{children:"Tax"})]})}),n.jsx("tbody",{children:r?.map(s=>n.jsxs("tr",{children:[n.jsx("td",{children:n.jsx("div",{children:s.employee?.name??"Missing"})}),n.jsx("td",{children:n.jsx("div",{children:s.directAmount.formatted})}),n.jsx("td",{children:n.jsx("div",{children:s.baseAmount?.formatted})}),n.jsxs("td",{children:[n.jsx("div",{children:s.pensionFund?.name}),n.jsxs("div",{children:["Employee: ",s.pensionEmployeeAmount?.formatted]}),n.jsxs("div",{children:["Employer: ",s.pensionEmployerAmount?.formatted]}),n.jsxs("div",{children:["Compensation: ",s.compensationsAmount?.formatted]})]}),n.jsxs("td",{children:[n.jsx("div",{children:s.trainingFund?.name}),n.jsxs("div",{children:["Employee: ",s.trainingFundEmployeeAmount?.formatted]}),n.jsxs("div",{children:["Employer: ",s.trainingFundEmployerAmount?.formatted]})]}),n.jsxs("td",{children:[n.jsxs("div",{children:["Employee: ",s.socialSecurityEmployeeAmount?.formatted]}),n.jsxs("div",{children:["Employer: ",s.socialSecurityEmployerAmount?.formatted]}),n.jsxs("div",{children:["Health: ",s.healthInsuranceAmount?.formatted]})]}),n.jsx("td",{children:n.jsx("div",{children:s.incomeTaxAmount?.formatted})})]},`${s.employee?.name}-${s.baseAmount}`))})]})};function Xf({chargeID:e,onChange:t=()=>{},fetching:r}){const[s,a]=p.useState([]),[o,i]=p.useState(e),[c,{toggle:l}]=xt(!1),[d,y]=p.useState(void 0),[{data:g,fetching:m},x]=ke({query:Pe,variables:{chargeId:o}}),f=p.useCallback(()=>{x(),t()},[x,t]);p.useEffect(()=>{g?.charge&&y(g.charge)},[g]),p.useEffect(()=>{r&&x()},[r,x]),p.useEffect(()=>{e!==o&&(i(e),x())},[e,o,x]);const u=d?.__typename,j=!!d?.metadata?.ledgerCount,v=!!d?.metadata?.transactionsCount,b=!!d?.metadata?.documentsCount,C=!!d?.metadata?.receiptsCount,S=!!d?.metadata?.invoicesCount,O=u==="SalaryCharge",_=!!d?.miscExpenses?.length,D=d?.metadata?.openDocuments,E=(d?.totalAmount?.raw??0)>0&&!C,M=!(S||C)||!v;p.useEffect(()=>{const L=[];v&&L.push("transactions"),b&&L.push("documents"),j&&L.push("ledger"),O&&L.push("salaries"),_&&L.push("miscExpenses"),u==="BankDepositCharge"&&L.push("bankDeposit"),a(L)},[v,b,j,O,_,u]);function h(L){s.includes(L)?a(se=>se.filter(me=>me!==L)):a(se=>[...se,L])}const T=De(Pe,Ns,d),Q=De(Pe,lr,d),R=De(Pe,Us,d),V=De(Pe,Fs,d),ue=De(Pe,Bs,d),le=p.useMemo(()=>u==="ConversionCharge"&&De(Pe,Rs,d),[d,u]),ee=p.useMemo(()=>u==="FinancialCharge"&&De(Pe,Ls,d),[d,u]),H=u==="SalaryCharge"&&De(Pe,Vs,d),ye=p.useMemo(()=>u==="CreditcardBankCharge"&&De(Pe,zs,d),[d,u]);return n.jsxs("div",{className:"flex flex-col gap-5",children:[m&&n.jsx(Dt,{className:"flex self-center my-5",color:"dark",size:"xl",variant:"dots"}),De(Pe,$s,d)&&n.jsx(Of,{data:d}),d&&n.jsxs("div",{className:"flex flex-row",children:[n.jsxs(z,{className:"w-full",multiple:!0,value:s,chevron:n.jsx(ws,{size:"1rem"}),styles:{chevron:{"&[data-rotate]":{transform:"rotate(45deg)"}}},children:[u==="ConversionCharge"&&n.jsxs(z.Item,{value:"conversion",children:[n.jsx(z.Control,{disabled:!v,onClick:()=>h("conversion"),children:"Conversion Info"}),n.jsx(z.Panel,{children:le&&n.jsx(Kf,{chargeProps:d})})]}),u==="FinancialCharge"&&n.jsxs(z.Item,{value:"exchangeRates",children:[n.jsx(z.Control,{disabled:!ee,onClick:()=>h("exchangeRates"),children:"Exchange Rates"}),n.jsx(z.Panel,{children:ee&&n.jsx(Gf,{chargeProps:d})})]}),v&&n.jsxs(z.Item,{value:"transactions",children:[n.jsx(z.Control,{disabled:!v,onClick:()=>h("transactions"),children:n.jsxs("div",{className:"flex flex-row items-center gap-2 justify-between w-full",children:["Transactions",E&&n.jsx(bn,{chargeId:d.id})]})}),n.jsx(z.Panel,{children:V&&n.jsx(Af,{transactionsProps:d,onChange:f})})]}),_&&n.jsxs(z.Item,{value:"miscExpenses",children:[n.jsx(z.Control,{disabled:!_,onClick:()=>h("miscExpenses"),children:"Misc Expenses"}),n.jsx(z.Panel,{children:ue&&n.jsx(Qf,{miscExpensesData:d,onChange:f})})]}),b&&n.jsxs(z.Item,{value:"documents",children:[n.jsx(z.Control,{disabled:!b,onClick:()=>h("documents"),children:n.jsxs("div",{className:"flex flex-row items-center gap-2 justify-between w-full",children:[n.jsxs("div",{className:"flex flex-row items-center gap-2 justify-start",children:[b&&n.jsx(Ke,{content:"Documents Gallery",children:n.jsx(q,{onClick:L=>{L.stopPropagation(),l()},variant:"outline",disabled:!T,size:"icon",className:"size-7.5 text-gray-500",children:n.jsx(oi,{className:"size-5"})})}),"Documents"]}),D&&n.jsx(bn,{chargeId:d.id})]})}),n.jsx(z.Panel,{children:Q&&n.jsx(Ms,{documentsProps:B(lr,d)?.additionalDocuments,onChange:f})})]}),u==="SalaryCharge"&&n.jsxs(z.Item,{value:"salaries",children:[n.jsx(z.Control,{disabled:!O,onClick:()=>h("salaries"),children:"Salaries"}),n.jsx(z.Panel,{children:H&&n.jsx(Jf,{salaryRecordsProps:d})})]}),d.__typename==="BusinessTripCharge"&&n.jsxs(z.Item,{value:"businessTrip",children:[n.jsx(z.Control,{onClick:()=>h("businessTrip"),children:"Business Trip"}),n.jsx(z.Panel,{children:n.jsx(Xc,{data:d.businessTrip})})]}),u==="CreditcardBankCharge"&&n.jsxs(z.Item,{value:"creditcard",children:[n.jsx(z.Control,{onClick:()=>h("creditcard"),children:"CreditCard Transactions"}),n.jsx(z.Panel,{children:ye&&n.jsx(Hf,{chargeProps:d})})]}),u==="BankDepositCharge"&&n.jsxs(z.Item,{value:"bankDeposit",children:[n.jsx(z.Control,{onClick:()=>h("bankDeposit"),children:"Bank Deposit"}),n.jsx(z.Panel,{children:n.jsx(Tf,{chargeId:d.id})})]}),j&&n.jsxs(z.Item,{value:"ledger",children:[n.jsx(z.Control,{disabled:!j,onClick:L=>{L.stopPropagation(),h("ledger")},children:n.jsxs("div",{className:"flex flex-row items-center gap-2 justify-start w-full",children:[!d.metadata?.isLedgerLocked&&n.jsx(rl,{chargeId:d.id,onChange:f,variant:"outline"}),"Ledger Records"]})}),n.jsx(z.Panel,{children:R&&n.jsx(Zf,{data:d})})]}),M&&n.jsx(Uf,{chargeId:d.id,onChange:f,toggleAccordionItem:h,isOpened:s.includes("charges-matches")})]}),T&&n.jsx(We,{maw:"1/6",children:n.jsx(Di,{in:c,transitionDuration:500,transitionTimingFunction:"linear",children:n.jsx(If,{chargeProps:d,onChange:f})})})]}),!m&&!d&&n.jsx("p",{children:"Error fetching extended information for this charge"})]})}const Zf=({data:e})=>{const{ledger:t}=B(Us,e);return n.jsx(Ef,{ledgerRecordsData:t.records,ledgerDiffData:t.validate?.differences,matches:t.validate?.matches})},ep=({setEditCharge:e,setInsertDocument:t,setMatchDocuments:r,toggleMergeCharge:s,isSelectedForMerge:a,data:o,isAllOpened:i})=>{const[c,l]=p.useState(!1),[d,y]=p.useState(B(Je,o)),[{data:g,fetching:m},x]=ke({query:ii,pause:!0,variables:{chargeId:o.id}}),f=x;p.useEffect(()=>{const v=g?.charge;v&&y(B(Je,v))},[g]),p.useEffect(()=>{y(B(Je,o))},[o]),p.useEffect(()=>{l(i)},[i]);const u=p.useMemo(()=>!!(d.metadata?.documentsCount||d.metadata?.transactionsCount||d.metadata?.ledgerCount||d.metadata?.miscExpensesCount),[d.metadata?.documentsCount,d.metadata?.transactionsCount,d.metadata?.ledgerCount,d.metadata?.miscExpensesCount]),j=(d?.totalAmount?.raw??0)>0;return n.jsxs(n.Fragment,{children:[n.jsxs("tr",{onClick:()=>{u&&(l(v=>!v),f())},children:[n.jsx(uu,{data:d}),n.jsx(ou,{data:d}),n.jsx(ru,{data:d}),n.jsx(fu,{data:d}),De(Je,bs,d)?n.jsx(au,{data:d}):n.jsx("td",{}),n.jsx(iu,{data:d,onChange:f}),De(Je,Ds,d)?n.jsx(lu,{data:d,onChange:f}):n.jsx("td",{}),De(Je,Ss,d)?n.jsx(du,{data:d}):n.jsx("td",{}),De(Je,js,d)?n.jsx(su,{data:d}):n.jsx("td",{}),n.jsx(cu,{data:d}),n.jsx(nu,{data:d,onChange:f}),n.jsx("td",{children:n.jsxs("div",{className:"flex flex-col gap-2",children:[e&&n.jsx(ci,{onClick:v=>{v.stopPropagation(),e(f)},tooltip:"Edit Charge"}),s&&n.jsx(sl,{toggleMergeSelected:()=>s(f),mergeSelected:a})]})}),n.jsx("td",{children:n.jsxs("div",{className:"flex flex-col gap-2",children:[n.jsx(Du,{chargeId:d.id,chargeType:d.__typename,setInsertDocument:t?()=>t(f):void 0,setMatchDocuments:r,onChange:f,isIncome:j}),u&&n.jsx(Ks,{toggleExpansion:l,isExpanded:c,onClickAction:()=>f()})]})})]}),u&&c&&n.jsx("tr",{children:n.jsx("td",{colSpan:13,children:n.jsx(ks,{style:{width:"100%"},withBorder:!0,shadow:"lg",children:n.jsx(Xf,{chargeID:d.id,onChange:f,fetching:m})})})})]})},up=({setEditChargeId:e,setInsertDocument:t,setMatchDocuments:r,toggleMergeCharge:s,mergeSelectedCharges:a,data:o,isAllOpened:i})=>{const c=o?.map(l=>B(li,l))??[];return n.jsxs(Gs,{striped:!0,highlightOnHover:!0,children:[n.jsx("thead",{className:"sticky top-0 z-20",children:n.jsxs("tr",{className:"px-10 py-10 title-font tracking-wider font-medium text-gray-900 text-sm bg-gray-100 rounded-tl rounded-bl",children:[n.jsx("th",{children:"Type"}),n.jsx("th",{children:"Date"}),n.jsx("th",{children:"Amount"}),n.jsx("th",{children:"Vat"}),n.jsx("th",{children:"Counterparty"}),n.jsx("th",{children:"Description"}),n.jsx("th",{children:"Tags"}),n.jsx("th",{children:"Tax Category"}),n.jsx("th",{children:"Business Trip"}),n.jsx("th",{children:"More Info"}),n.jsx("th",{children:"Accountant Approval"}),n.jsx("th",{children:"Edit"}),n.jsx("th",{children:"More Info"})]})}),n.jsx("tbody",{children:c?.map(l=>n.jsx(ep,{data:l,setEditCharge:e?d=>e({id:l.id,onChange:d}):void 0,setInsertDocument:t?d=>t({id:l.id,onChange:d}):void 0,setMatchDocuments:r?()=>r({id:l.id,ownerId:l.owner.id}):void 0,toggleMergeCharge:s?d=>s(l.id,d):void 0,isSelectedForMerge:a?.has(l.id)??!1,isAllOpened:i},l.id))})]})};export{up as C,Ef as L,Hd as M,Qd as S,zn as T,Qi as W,sl as a,Xf as b,la as c,_a as d,qs as e,tu as u};
|
|
7
|
+
`)}`),activateOnClick:!1,activateOnKeyboard:!1,radius:0,padding:0,maxFiles:1/0,loading:r,sx:()=>({border:0,cursor:"default",width:"100%",height:"100%",zIndex:1}),children:e})},an=({items:e,extraClassName:t=""})=>{const r=["text-sm font-medium text-gray-900 bg-white border border-gray-200 rounded-lg",t].join(" ");return n.jsx("ul",{className:r,children:e.map((s,a)=>{const o=["w-full px-4 py-2",a===e.length-1?"rounded-b-lg":"border-b",a===0?"rounded-t-lg":"","border-gray-200",s&&typeof s=="object"&&"extraClassName"in s?s.extraClassName??"":""].join(" ");return n.jsx("li",{className:o,children:s&&typeof s=="object"&&"content"in s?s.content:s},a)})})};function Wr({columns:e=5,rows:t=5,headerHeight:r="h-10",rowHeight:s="h-8",showHeader:a=!0,columnWidths:o,...i}){const c=o||Array(e).fill("flex-1");return n.jsxs("div",{className:"space-y-2",...i,children:[a&&n.jsx("div",{className:"flex gap-2 border-b pb-2",children:c.map((l,d)=>n.jsx(tr,{className:`${r} ${l}`},d))}),[...Array(t)].map((l,d)=>n.jsx("div",{className:"flex gap-2 border-b py-2",children:c.map((y,g)=>n.jsx(tr,{className:`${s} ${y}`},g))},d))]})}const Vd="mergeCharges",Ud=()=>{const[{fetching:e},t]=Ee(co),r=p.useCallback(async s=>{const a=`Error merging into charge ID [${s.baseChargeID}]`,o=`${Vd}-${s.baseChargeID}`;F.loading("Merging Charges",{id:o});try{const i=await t(s),c=Oe(i,a,o,"mergeCharges");if(c)return F.success("Success",{id:o,description:"Charges were merged"}),c.mergeCharges.charge}catch(i){console.error(`${a}: ${i}`),F.error("Error",{id:o,description:a,duration:1e5,closeButton:!0})}},[t]);return{fetching:e,mergeCharges:r}};function Kd({chargeIds:e,onDone:t,resetMerge:r}){const{mergeCharges:s,fetching:a}=Ud(),o=Array.from(new Set(e)),[{data:i,fetching:c}]=ke({query:lo,variables:{chargeIds:o}}),[l,d]=p.useState(i?.chargesByIDs[0]),[y,g]=p.useState(void 0),[m,x]=p.useState(void 0),[f,u]=p.useState(void 0),[j,v]=p.useState(void 0),[b,C]=p.useState(void 0),[S,O]=p.useState(void 0),[_,D]=p.useState(void 0),E=i?.chargesByIDs.length!==o.length&&"Some charges were not Found"||void 0,A=i?.chargesByIDs||[],M=p.useCallback(async()=>{if(!l){F.error("Error",{description:"No main charge selected"});return}if(o.length<2){F.error("Error",{description:"At least 2 charges are required to execute a merge"});return}let h;return y&&y.value!==l.userDescription&&(h??={},h={...h,userDescription:y.value}),m&&m.value!==l.owner.id&&(h??={},h={...h,ownerId:m.value}),b&&b.value!==l.conversion&&(h??={},h={...h,isConversion:b.value}),f&&f.value!==l.optionalVAT&&(h??={},h={...h,optionalVAT:f.value}),j&&j.value!==l.optionalDocuments&&(h??={},h={...h,optionalDocuments:j.value}),_&&_.value!==l.tags.map(T=>T.name).join(",")&&(h??={},h={...h,tags:_.value.split(",").filter(T=>T!=="").map(T=>({id:T}))}),S&&S.value!==l.isInvoicePaymentDifferentCurrency&&(h??={},h={...h,isInvoicePaymentDifferentCurrency:S.value}),await s({baseChargeID:l.id,chargeIdsToMerge:o.filter(T=>T!==l.id),fields:h}),r(),t()},[l,o,s,y,m,b,f,S,_,t,r]);return n.jsxs(n.Fragment,{children:[c&&n.jsx("div",{className:"flex flex-col text-center w-full mb-1",children:n.jsx(hs,{})}),!c&&E&&n.jsx("div",{className:"flex flex-col text-center w-full mb-1",children:n.jsx("h3",{className:"sm:text-2xl text-xl font-medium title-font mb-6 text-gray-900",children:E})}),!c&&!E&&n.jsxs(n.Fragment,{children:[n.jsxs("table",{children:[n.jsxs("tr",{children:[n.jsx("th",{children:"Main"}),A.map(h=>n.jsx("td",{children:n.jsx("div",{className:"flex items-center justify-center mx-2 px-2 py-2 border-2 border-b-0 rounded-t-xl",children:n.jsx(Ii,{checked:h.id===l?.id,size:"xl",onClick:()=>{d(h),g({id:h.id,value:h.userDescription??""}),x({id:h.id,value:h.owner.id}),u({id:h.id,value:h.optionalVAT??!1}),v({id:h.id,value:h.optionalDocuments??!1}),O({id:h.id,value:h.isInvoicePaymentDifferentCurrency??!1}),C({id:h.id,value:h.conversion??!1}),D({id:h.id,value:(h.tags.map(T=>T.name)??[]).join(",")})}})})},h.id))]}),n.jsxs("tr",{children:[n.jsx("th",{children:"Description"}),A.map(h=>n.jsx("td",{children:n.jsx("button",{className:"w-full px-2",disabled:!h.userDescription||y?.value===h.userDescription,onClick:()=>g({id:h.id,value:h.userDescription??""}),children:n.jsx("div",{className:"flex items-center justify-center px-2 py-2 border-x-2",style:y?.id===h.id?{background:"#228be633"}:{},children:h.userDescription})})},h.id))]}),n.jsxs("tr",{children:[n.jsx("th",{children:"Owner"}),A.map(h=>n.jsx("td",{children:n.jsx("button",{className:"w-full px-2",disabled:m?.value===h.owner.id,onClick:()=>x({id:h.id,value:h.owner.id}),children:n.jsx("div",{className:"flex items-center justify-center px-2 py-2 border-x-2",style:m?.id===h.id?{background:"#228be633"}:{},children:h.owner.name})})},h.id))]}),n.jsxs("tr",{children:[n.jsx("th",{children:"Is Conversion"}),A.map(h=>n.jsx("td",{children:n.jsx("button",{className:"w-full px-2",disabled:h.conversion==null||h.conversion===b?.value,onClick:()=>{C({id:h.id,value:h.conversion??!1})},children:n.jsx("div",{className:"flex items-center justify-center px-2 py-2 border-x-2",style:b?.id===h.id?{background:"#228be633"}:{},children:h.conversion?n.jsx(At,{size:20,color:"green"}):n.jsx(Pt,{size:20,color:"red"})})})},h.id))]}),n.jsxs("tr",{children:[n.jsx("th",{children:"Optional VAT"}),A.map(h=>n.jsx("td",{children:n.jsx("button",{className:"w-full px-2",disabled:h.optionalVAT==null||h.optionalVAT===f?.value,onClick:()=>{u({id:h.id,value:h.optionalVAT??!1})},children:n.jsx("div",{className:"flex items-center justify-center px-2 py-2 border-x-2",style:f?.id===h.id?{background:"#228be633"}:{},children:h.optionalVAT?n.jsx(At,{size:20,color:"green"}):n.jsx(Pt,{size:20,color:"red"})})})},h.id))]}),n.jsxs("tr",{children:[n.jsx("th",{children:"Optional Documents"}),A.map(h=>n.jsx("td",{children:n.jsx("button",{className:"w-full px-2",disabled:h.optionalDocuments==null||h.optionalDocuments===j?.value,onClick:()=>{v({id:h.id,value:h.optionalDocuments??!1})},children:n.jsx("div",{className:"flex items-center justify-center px-2 py-2 border-x-2",style:j?.id===h.id?{background:"#228be633"}:{},children:h.optionalDocuments?n.jsx(At,{size:20,color:"green"}):n.jsx(Pt,{size:20,color:"red"})})})},h.id))]}),n.jsxs("tr",{children:[n.jsx("th",{children:"Invoice-Payment Currency Difference"}),A.map(h=>n.jsx("td",{children:n.jsx("button",{className:"w-full px-2",disabled:h.isInvoicePaymentDifferentCurrency==null||h.isInvoicePaymentDifferentCurrency===S?.value,onClick:()=>{O({id:h.id,value:h.isInvoicePaymentDifferentCurrency??!1})},children:n.jsx("div",{className:"flex items-center justify-center px-2 py-2 border-x-2",style:S?.id===h.id?{background:"#228be633"}:{},children:h.isInvoicePaymentDifferentCurrency?n.jsx(At,{size:20,color:"green"}):n.jsx(Pt,{size:20,color:"red"})})})},h.id))]}),n.jsxs("tr",{children:[n.jsx("th",{children:"Tags"}),A.map(h=>n.jsx("td",{children:n.jsx("button",{className:"w-full px-2",disabled:h.tags==null||h.tags.map(T=>T.name).join(",")===_?.value,onClick:()=>{D({id:h.id,value:(h.tags.map(T=>T.name)??[]).join(",")})},children:n.jsx("div",{className:"flex items-center justify-center px-2 py-2 border-x-2",style:_?.id===h.id?{background:"#228be633"}:{},children:n.jsx(an,{items:h.tags.map(T=>n.jsxs("div",{className:"flex flex-col items-center",children:[n.jsx("div",{children:T.name}),T.namePath&&n.jsx("div",{children:T.namePath.join(" > ")})]},T.id))})})})},h.id))]}),n.jsxs("tr",{children:[n.jsx("th",{children:"Transactions"}),A.map(h=>n.jsx("td",{children:n.jsx("div",{className:"flex items-center justify-center mx-2 px-2 py-2 border-x-2",children:h.metadata?.transactionsCount??0})},h.id))]}),n.jsxs("tr",{children:[n.jsx("th",{children:"Invoices"}),A.map(h=>n.jsx("td",{children:n.jsx("div",{className:"flex items-center justify-center mx-2 px-2 py-2 border-2 border-t-0 rounded-b-xl",children:h.metadata?.invoicesCount??0})},h.id))]})]}),n.jsxs("div",{className:"flex justify-center gap-5 mt-5",children:[n.jsx("button",{type:"button",className:" text-white bg-blue-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-blue-600 rounded-sm text-lg",disabled:c||a,onClick:M,children:"Accept"}),n.jsx("button",{type:"button",className:" text-white bg-red-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-red-600 rounded-sm text-lg",onClick:t,children:"Cancel"}),n.jsx("button",{type:"button",className:" text-white bg-red-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-red-600 rounded-sm text-lg",onClick:()=>{r(),t()},children:"Reset Merge"})]})]})]})}function Hd(e){const[t,r]=p.useState(!1),{selected:s,resetMerge:a}=e,o=new Set(s.map(({id:g})=>g)),i=o.size>1,[c,l]=p.useState(i?"default":"outline");p.useEffect(()=>{l(i?"default":"outline")},[i]);const d=p.useCallback(()=>{r(!1),s.map(({onChange:g})=>g())},[s]),y=p.useMemo(()=>i?`Merge ${o.size} selected charges`:"Select at least two different charges to merge",[i,o.size]);return n.jsxs(St,{open:t,onOpenChange:r,children:[n.jsx(xs,{disabled:!i,children:n.jsxs(uo,{children:[n.jsx(fo,{children:n.jsx(q,{disabled:!i,variant:c,className:"size-7.5",children:n.jsx(_i,{className:"size-5"})})}),n.jsx(po,{children:n.jsx("p",{children:y})})]})}),n.jsxs(wt,{className:"w-[90vw] sm:max-w-[95%] max-h-[90vh] overflow-y-auto",children:[n.jsx(Pn,{children:n.jsx(Nn,{children:"Issue New Document"})}),n.jsx(Kd,{chargeIds:Array.from(o),onDone:d,resetMerge:a})]})]})}const Gd=({onDone:e,data:t})=>{const[r,s]=p.useState(!1);function a(){s(!1),e?.()}return n.jsxs(St,{open:r,onOpenChange:s,children:[n.jsx(Ke,{content:"Edit Misc Expense",children:n.jsx(xs,{asChild:!0,children:n.jsx(q,{variant:"ghost",size:"icon",className:"size-7.5",children:n.jsx(ys,{className:"size-5"})})})}),n.jsx(wt,{className:"sm:max-w-[425px]",children:n.jsx(cl,{onDone:a,data:t})})]})},qd="batchUpdateCharges",Wd=()=>{const[{fetching:e},t]=Ee(go),r=p.useCallback(async s=>{const a=Array.isArray(s.chargeIds)?s.chargeIds:[s.chargeIds],o=`Error updating charge IDs [${a.join(", ")}]`,i=`${qd}-${a[0]}`;F.loading("Updating charge",{id:i});try{const c=await t(s),l=Oe(c,o,i,"batchUpdateCharges");if(l)return F.success("Success",{id:i,description:`${a.length} charge${a.length>1?"s":""} updated`}),l.batchUpdateCharges.charges}catch(c){console.error(`${o}: ${c}`),F.error("Error",{id:i,description:o,duration:1e5,closeButton:!0})}},[t]);return{fetching:e,batchUpdateCharges:r}},Yd=[{id:"select",header:({table:e})=>n.jsx(jn,{checked:e.getIsAllPageRowsSelected()||e.getIsSomePageRowsSelected()&&"indeterminate",onCheckedChange:t=>e.toggleAllPageRowsSelected(!!t),"aria-label":"Select all"}),cell:({row:e})=>n.jsx(jn,{checked:e.getIsSelected(),onCheckedChange:t=>e.toggleSelected(!!t),"aria-label":"Select row"}),enableSorting:!1,enableHiding:!1},{accessorKey:"chargeType",header:"Type",cell:({row:e})=>n.jsx("div",{children:e.getValue("chargeType")})},{accessorKey:"counterpartyName",header:"Counterparty",cell:({row:e})=>n.jsx("div",{children:e.getValue("counterpartyName")})},{accessorKey:"date",header:"Date",cell:({row:e})=>{const t=e.getValue("date");return n.jsx("div",{children:t?He(new Date(t),"yyyy-MM-dd"):"Missing"})}},{accessorKey:"amountRaw",header:"Amount",cell:({row:e})=>n.jsx("div",{children:e.original.amountFormatted})},{accessorKey:"vatAmountRaw",header:"VAT Amount",cell:({row:e})=>n.jsx("div",{children:e.original.vatAmountFormatted})},{accessorKey:"description",header:"Description",cell:({row:e})=>n.jsx("div",{children:e.getValue("description")})},{accessorKey:"taxCategoryName",header:"Tax Category",cell:({row:e})=>n.jsx("div",{children:e.getValue("taxCategoryName")})},{accessorKey:"tags",header:"Tags",cell:({row:e})=>{const t=e.getValue("tags");return!t||!Array.isArray(t)||t.length===0?n.jsx("div",{children:"No tags"}):n.jsx("div",{children:t.join(" | ")})}},{accessorKey:"businessTripName",header:"Business Trip",cell:({row:e})=>n.jsx("div",{children:e.getValue("businessTripName")})},{accessorKey:"moreInfo",header:"More Info",cell:({row:e})=>{const t=e.original.transactions||0,r=e.original.documents||0,s=e.original.miscExpenses||0,a=e.original.ledgerRecords||0;return n.jsxs("div",{className:"flex flex-col justify-center text-sm",children:[t>0&&n.jsxs("div",{children:["Transactions: ",t]}),r>0&&n.jsxs("div",{children:["Documents: ",r]}),s>0&&n.jsxs("div",{children:["Misc Expenses: ",s]}),a>0&&n.jsxs("div",{children:["Ledger Records: ",a]})]})},enableSorting:!1}];function Qd({data:e,tagIds:t,description:r,onOpenChange:s,title:a="Similar Charges"}){const[o,i]=k.useState([]),[c,l]=k.useState({}),d=p.useMemo(()=>e.map(f=>L(mo,f)),[e]),y=p.useMemo(()=>d.map(u=>({id:u.id,chargeType:Rn(u.__typename),counterpartyName:u.counterparty?.name,date:u.minEventDate||u.minDebitDate||u.minDocumentsDate||void 0,amountRaw:u.totalAmount?.raw,amountFormatted:u.totalAmount?.formatted,vatAmountRaw:u.vat?.raw,vatAmountFormatted:u.vat?.formatted,description:u.userDescription||void 0,tags:u.tags.map(j=>j.name),taxCategoryName:u.taxCategory?.name,businessTripName:u.__typename==="BusinessTripCharge"?u.businessTrip?.name:void 0,ledgerRecords:u.metadata?.ledgerCount??0,documents:u.metadata?.documentsCount??0,transactions:u.metadata?.transactionsCount??0,miscExpenses:u.metadata?.miscExpensesCount??0}))??[],[d]);p.useEffect(()=>{e&&y.length===0&&s(!1)},[e,y.length,s]);const g=Tn({data:y,columns:Yd,onSortingChange:i,getCoreRowModel:$n(),getSortedRowModel:kn(),onRowSelectionChange:l,state:{sorting:o,rowSelection:c}}),{batchUpdateCharges:m}=Wd(),x=p.useCallback(async()=>{const f=g.getSelectedRowModel().rows.map(u=>u.original.id);await m({chargeIds:f,fields:{...t?{tags:t}:{},...r?{userDescription:r}:{}}}),s(!1)},[m,s,g,t,r]);return p.useEffect(()=>{e.length===0&&s(!1)},[e.length,s]),e.length?n.jsxs(n.Fragment,{children:[n.jsxs(Pn,{className:"flex flex-row items-center justify-between",children:[n.jsx(Nn,{children:a}),n.jsx(q,{onClick:x,children:"Approve selected"})]}),n.jsx(vs,{children:n.jsxs(tn,{children:[n.jsx(nn,{children:g.getHeaderGroups().map(f=>n.jsx(Ne,{children:f.headers.map(u=>n.jsx(Ae,{children:u.isPlaceholder?null:rt(u.column.columnDef.header,u.getContext())},u.id))},f.id))}),n.jsx(rn,{children:g.getRowModel().rows.map(f=>n.jsx(Ne,{"data-state":f.getIsSelected()&&"selected",children:f.getVisibleCells().map(u=>n.jsx(xe,{children:rt(u.column.columnDef.cell,u.getContext())},u.id))},f.id))})]})})]}):null}function _a({chargeId:e,tagIds:t,description:r,open:s,onOpenChange:a,onClose:o,showChargesWithExistingSuggestions:i=!1}){const[{data:c,fetching:l},d]=ke({pause:!0,query:ho,variables:{chargeId:e,withMissingTags:i?!1:!!t,withMissingDescription:i?!1:!!r,tagsDifferentThan:i&&t?t.map(m=>m.id):void 0,descriptionDifferentThan:i?r:void 0}});p.useEffect(()=>{s&&(t||r)&&!c&&d()},[s,t,r,d,c]);const y=p.useCallback(m=>{a(m),s&&!m&&o?.()},[a,o,s]);p.useEffect(()=>{s&&!l&&c?.similarCharges.length===0&&o?.()},[s,l,c,o]);const g=p.useMemo(()=>s&&(!!t||!!r)&&c&&c?.similarCharges.length>0,[s,t,r,c]);return n.jsx(St,{open:g,onOpenChange:y,children:n.jsx(wt,{className:"overflow-scroll max-h-screen w-full sm:max-w-[640px] md:max-w-[768px] lg:max-w-[900px]",onClick:m=>m.stopPropagation(),children:n.jsx(xo,{fallback:n.jsx("div",{children:"Error fetching similar charges"}),children:l?n.jsx(hs,{}):t||r?n.jsx(Qd,{data:c?.similarCharges??[],tagIds:t,description:r,onOpenChange:y}):null})})})}function Jd(e){switch(e){case"xs":return"size-8";case"sm":return"size-10";case"md":return"size-15";case"lg":return"size-25";case"xl":return"size-40";default:return"size-10"}}function Xd(e){switch(e){case"xs":return"text-2xs";case"sm":return"text-base";case"md":return"text-2xl";case"lg":return"text-3xl";case"xl":return"text-5xl";default:return"text-base"}}const Zd=({value:e,size:t="xl"})=>{const s=(o=>{const i=Math.max(0,Math.min(100,o)),c=Math.round(155*(1-i/100)+100),l=Math.round(155*(i/100)+0);return`rgb(${c}, ${l}, 0)`})(e),a=e/100*75;return n.jsxs("div",{className:"relative "+Jd(t),children:[n.jsxs("svg",{className:"rotate-[135deg] size-full",viewBox:"0 0 36 36",xmlns:"http://www.w3.org/2000/svg",children:[n.jsx("circle",{cx:"18",cy:"18",r:"16",fill:"none",className:"stroke-current text-gray-200 dark:text-neutral-700",strokeWidth:"1",strokeDasharray:"75 100",strokeLinecap:"round"}),n.jsx("circle",{cx:"18",cy:"18",r:"16",fill:"none",stroke:s,strokeWidth:"2",strokeDasharray:`${a} 100`,strokeLinecap:"round"})]}),n.jsx("div",{className:"absolute top-1/2 start-1/2 transform -translate-x-1/2 -translate-y-1/2 text-center",children:n.jsx("span",{className:"font-bold "+Xd(t),style:{color:s},children:e.toFixed(0)})})]})},eu="updateChargeAccountantApproval",tu=()=>{const[{fetching:e},t]=Ee(yo),r=p.useCallback(async s=>{const a=`Error toggling accountant approval to ledger record ID [${s.chargeId}]`,o=`${eu}-${s.chargeId}`;F.loading("Updating approval status",{id:o});try{const i=await t(s),c=Oe(i,a,o,"updateChargeAccountantApproval");if(c)return F.success("Success",{id:o,description:"Accountant approval was updated"}),c.updateChargeAccountantApproval}catch(i){console.error(`${a}: ${i}`),F.error("Error",{id:o,description:a,duration:1e5,closeButton:!0})}},[t]);return{fetching:e,updateChargeAccountantApproval:r}};function nu({data:e,onChange:t}){const r=L(jo,e),[s,a]=p.useState(r.accountantApproval),{updateChargeAccountantApproval:o}=tu();return p.useEffect(()=>{s==null&&r.accountantApproval!=null&&a(r.accountantApproval)},[s,r.accountantApproval]),n.jsx("td",{children:n.jsx(vo,{value:s,onChange:i=>o({chargeId:r.id,status:i}).then(t)})})}const ru=({data:e})=>{const t=L(bo,e),[r,s]=p.useState(!0),[a,o]=p.useState(!0),i="validCreditCardAmount"in t?t.validCreditCardAmount:null;return p.useEffect(()=>{t.__typename==="CreditcardBankCharge"&&(o(i==null),i!=null&&s(i))},[t.__typename,i]),n.jsx("td",{children:n.jsx("div",{children:n.jsx(Le,{inline:!0,size:12,disabled:r,processing:a,color:"red",zIndex:"auto",children:n.jsx("p",{className:(t.totalAmount?.raw??0)>0?"whitespace-nowrap text-green-700":"whitespace-nowrap text-red-500",children:t.totalAmount?.formatted})})})})},su=({data:e})=>{const t=L(js,e);return"businessTrip"in t?n.jsx("td",{children:n.jsx(yt,{to:t.businessTrip?.id?st.BUSINESS_TRIPS.DETAIL(t.businessTrip?.id):st.BUSINESS_TRIPS.ROOT,target:"_blank",rel:"noreferrer",onClick:r=>r.stopPropagation(),className:"inline-flex items-center font-semibold",children:t.businessTrip?.name})}):n.jsx("td",{})},au=({data:e})=>{const{counterparty:t,validationData:r,__typename:s}=L(bs,e),a=p.useMemo(()=>{switch(s){case"BusinessTripCharge":case"DividendCharge":case"ConversionCharge":case"SalaryCharge":case"InternalTransferCharge":return!1;default:return!0}},[s]),o=p.useMemo(()=>a&&r?.missingInfo?.includes(Ue.Counterparty),[a,r?.missingInfo]),{name:i,id:c}=t??{name:"Missing",id:void 0};return n.jsx("td",{children:n.jsx("div",{className:"flex flex-wrap",children:n.jsxs(Le,{inline:!0,size:12,disabled:!o,color:"red",zIndex:"auto",children:[!o&&c&&n.jsx(yt,{to:st.BUSINESSES.DETAIL(c),target:"_blank",rel:"noreferrer",onClick:l=>l.stopPropagation(),className:"inline-flex items-center font-semibold",children:i}),o&&i]})})})},ou=({data:e})=>{const t=L(Co,e),{minDebitDate:r,minEventDate:s,minDocumentsDate:a}=t,o=r||s||a;return n.jsx("td",{children:n.jsx("div",{children:o&&He(new Date(o),"dd/MM/yy")})})},iu=({data:e,onChange:t})=>{const[r,s]=p.useState(!1),a=L(Do,e),o=p.useMemo(()=>a?.validationData?.missingInfo?.includes(Ue.Description),[a?.validationData?.missingInfo]),i=p.useMemo(()=>o&&!!a.missingInfoSuggestions?.description?.trim().length,[o,a.missingInfoSuggestions?.description]),{userDescription:c,id:l}=a,d=p.useMemo(()=>c&&c?.trim()!==""?c:a.missingInfoSuggestions?.description?a.missingInfoSuggestions.description:"Missing",[c,a.missingInfoSuggestions?.description]),{updateCharge:y,fetching:g}=la(),m=p.useCallback(async x=>{x!==void 0&&(await y({chargeId:l,fields:{userDescription:x}}),s(!0))},[l,y]);return n.jsxs("td",{children:[n.jsxs("div",{className:"flex flex-wrap",children:[n.jsx("div",{className:"flex flex-col justify-center",children:n.jsx(Le,{inline:!0,size:12,disabled:!o,color:"red",zIndex:"auto",children:n.jsx("p",{className:i?"bg-yellow-400":void 0,children:d})})}),i&&n.jsx(Cs,{onClick:x=>{x.stopPropagation(),m(a.missingInfoSuggestions.description)},disabled:g})]}),n.jsx(_a,{chargeId:l,description:a.missingInfoSuggestions?.description??void 0,open:r,onOpenChange:s,onClose:t})]})},cu=({data:e})=>{const t=L(So,e),{metadata:r,validationData:s,id:a,__typename:o}=t,i=p.useMemo(()=>{switch(o){case"BusinessTripCharge":case"ConversionCharge":case"DividendCharge":case"InternalTransferCharge":case"SalaryCharge":case"MonthlyVatCharge":case"BankDepositCharge":case"ForeignSecuritiesCharge":case"CreditcardBankCharge":case"FinancialCharge":return!1;default:return!0}},[o]),c=p.useMemo(()=>o!=="FinancialCharge",[o]),l=p.useMemo(()=>c&&s?.missingInfo?.includes(Ue.Transactions),[c,s?.missingInfo]),d=p.useMemo(()=>i&&s?.missingInfo?.includes(Ue.Documents),[i,s?.missingInfo]),y=p.useMemo(()=>!r?.invalidLedger,[r?.invalidLedger]),g=p.useMemo(()=>r?.invalidLedger,[r?.invalidLedger]),m=p.useMemo(()=>{const x=[];return(l||r?.transactionsCount||c)&&x.push({extraClassName:r?.transactionsCount||!c?void 0:"bg-yellow-400",content:n.jsx(Le,{inline:!0,size:12,disabled:!l,color:"red",zIndex:"auto",children:n.jsxs("div",{className:"whitespace-nowrap",children:["Transactions: ",r?.transactionsCount??0]})},"transactions")}),x.push({content:n.jsx(Le,{inline:!0,size:12,processing:y,disabled:g==="VALID",color:g==="DIFF"?"orange":"red",zIndex:"auto",children:n.jsxs("div",{className:"whitespace-nowrap",children:["Ledger Records: ",r?.ledgerCount??0]})},"ledger")}),(d||r?.documentsCount)&&x.push({content:n.jsx(Le,{inline:!0,size:12,disabled:!d,color:"red",zIndex:"auto",children:n.jsxs("div",{className:"whitespace-nowrap",children:["Documents: ",r?.documentsCount??0]})},"documents"),extraClassName:!s?.missingInfo?.includes(Ue.Documents)||!i?void 0:"bg-yellow-400"}),r?.miscExpensesCount&&x.push({content:n.jsxs("div",{className:"whitespace-nowrap",children:["Misc Expenses: ",r?.miscExpensesCount??0]})}),x},[r?.transactionsCount,r?.ledgerCount,r?.documentsCount,r?.miscExpensesCount,i,c,l,d,s?.missingInfo,g,y]);return n.jsx("td",{children:n.jsx(Bd,{chargeId:a,children:n.jsx(an,{items:m})})})},lu=({data:e,onChange:t})=>{const{tags:r,id:s,validationData:a,missingInfoSuggestions:o}=L(Ds,e),{updateCharge:i,fetching:c}=la(),[l,d]=p.useState(r??[]),[y,g]=p.useState(!1),m=a?.missingInfo?.includes(Ue.Tags),x=m&&!!o?.tags?.length;p.useEffect(()=>{r?.length&&!l.length&&d(r)},[r,l.length]),p.useEffect(()=>{l.length===0&&x&&d(o?.tags??[])},[l.length,x,o?.tags]);const f=p.useCallback(async u=>{await i({chargeId:s,fields:{tags:u?.map(j=>({id:j.id}))}}),g(!0)},[s,i]);return n.jsxs("td",{children:[n.jsx(Le,{inline:!0,size:12,disabled:!m,color:"red",zIndex:"auto",children:n.jsx(an,{items:l.map(u=>n.jsx(zt,{children:n.jsxs("div",{children:[u.namePath&&n.jsx(Be,{size:"xs",opacity:.65,children:`${u.namePath.join(" > ")} >`}),n.jsx(Be,{size:"sm",children:u.name})]})},u.id)),extraClassName:x?"bg-yellow-400":void 0})}),x&&n.jsx(Cs,{onClick:u=>{u.stopPropagation(),f(o.tags)},disabled:c}),n.jsx(_a,{chargeId:s,tagIds:o?.tags?.map(u=>({id:u.id})),open:y,onOpenChange:g,onClose:t})]})},du=({data:e})=>{const{validationData:t,taxCategory:r,__typename:s}=L(Ss,e),a=p.useMemo(()=>{switch(s){case"DividendCharge":case"InternalTransferCharge":case"SalaryCharge":case"BankDepositCharge":case"ForeignSecuritiesCharge":return!1;default:return!0}},[s]),o=p.useMemo(()=>t?.missingInfo?.includes(Ue.TaxCategory),[t?.missingInfo]);return a?n.jsx("td",{children:n.jsx(Le,{inline:!0,size:12,disabled:!o,color:"red",zIndex:"auto",children:r?.name??"N/A"})}):n.jsx("td",{})},uu=({data:e})=>{const t=L(wo,e),{__typename:r}=t,{text:s,icon:a}=p.useMemo(()=>({text:Rn(r),icon:Ws(r)}),[r]);return n.jsxs("td",{children:[n.jsx("div",{children:s}),n.jsx(zn,{radius:"xl",size:"xl",children:a})]})},fu=({data:e})=>{const{vat:t,totalAmount:r,validationData:s,__typename:a}=L(Io,e),o=p.useMemo(()=>s?.missingInfo?.includes(Ue.Vat),[s?.missingInfo]),i=p.useMemo(()=>!t&&r?.currency===sn.Ils,[t,r?.currency]),c=p.useMemo(()=>(t?.raw??0)>0&&(r?.raw??0)<0||(t?.raw??0)<0&&(r?.raw??0)>0,[t?.raw,r?.raw]),l=i||c;return p.useMemo(()=>{switch(a){case"BusinessTripCharge":case"DividendCharge":case"ConversionCharge":case"SalaryCharge":case"InternalTransferCharge":case"BankDepositCharge":case"ForeignSecuritiesCharge":case"CreditcardBankCharge":return!1;default:return!0}},[a])?n.jsx("td",{children:n.jsx("div",{className:l?"whitespace-nowrap text-red-500":"whitespace-nowrap text-green-700",children:n.jsx(Le,{inline:!0,size:12,disabled:!o,color:"red",zIndex:"auto",children:t?.formatted})})}):n.jsx("td",{})},pu="insertDepreciationRecord",gu=()=>{const[{fetching:e},t]=Ee(_o),r=p.useCallback(async s=>{const a="Error adding depreciation record",o=pu;F.loading("Adding depreciation record",{id:o});try{const i=await t(s),c=Oe(i,a,o,"insertDepreciationRecord");if(c)return F.success("Success",{id:o,description:"Depreciation record was added"}),c.insertDepreciationRecord}catch(i){console.error(`${a}: ${i}`),F.error("Error",{id:o,description:a,duration:1e5,closeButton:!0})}},[t]);return{fetching:e,addDepreciationRecord:r}};function Yr(e){const{chargeId:t,onAdd:r}=e,[s,{close:a,open:o}]=xt(!1);return n.jsxs(n.Fragment,{children:[n.jsx(Ke,{content:"Add Depreciation Record",children:n.jsx(q,{variant:"outline",size:"icon",className:"size-7.5",onClick:i=>{i.stopPropagation(),o()},children:n.jsx(ws,{className:"size-5"})})}),s&&n.jsx(mu,{chargeId:t,opened:s,close:a,onAdd:r})]})}function mu({chargeId:e,opened:t,close:r,onAdd:s}){const{control:a,handleSubmit:o}=An({defaultValues:{chargeId:e}}),[i,c]=p.useState(!1),[{data:l,fetching:d}]=ke({query:Is}),{addDepreciationRecord:y,fetching:g}=gu(),m=f=>{y({fields:f}).then(()=>{s?.(),r()})},x=l?.depreciationCategories?.map(f=>({value:f.id,label:f.name}))??[];return p.useEffect(()=>{c(!!(d||g))},[d,g]),n.jsxs(mt,{opened:t,onClose:r,centered:!0,lockScroll:!0,children:[n.jsx(mt.Title,{children:"Add Depreciation Record"}),n.jsx(mt.Body,{children:n.jsxs("form",{onSubmit:o(m),children:[n.jsx(Fe,{name:"activationDate",control:a,rules:{pattern:{value:_s,message:"Date must be im format yyyy-mm-dd"}},render:({field:{value:f,...u}})=>{const j=f?new Date(f):void 0;return n.jsx(Es,{...u,onChange:v=>{const b=v?typeof v=="string"?v:He(v,"yyyy-MM-dd"):void 0;b!==f&&u.onChange(b)},value:j,label:"Activation Date",popoverProps:{withinPortal:!0}})}}),n.jsx(Fe,{name:"amount",control:a,render:({field:f,fieldState:u})=>n.jsx(Fe,{name:"currency",control:a,render:({field:j,fieldState:v})=>n.jsx(Os,{...f,value:f.value??void 0,error:u.error?.message||v.error?.message,label:"Amount",currencyCodeProps:{...j,label:"Currency"}})})}),n.jsx(Fe,{name:"categoryId",control:a,render:({field:f,fieldState:u})=>n.jsx(Lt,{...f,disabled:d,data:x,label:"Category",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:u.error?.message,withinPortal:!0})}),n.jsx(Fe,{name:"type",control:a,render:({field:f,fieldState:u})=>n.jsx(Lt,{...f,data:Ea,value:f.value,label:"Type",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:u.error?.message,withinPortal:!0})}),n.jsx("div",{className:"flex justify-center mt-5 gap-3",children:n.jsx("button",{type:"submit",className:"text-white bg-indigo-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-indigo-600 rounded-sm text-lg",children:"Add"})})]})}),(g||i)&&n.jsx(ps,{blur:1,center:!0,children:n.jsx(Dt,{})})]})}const hu="updateDepreciationRecord",xu=()=>{const[{fetching:e},t]=Ee(Eo),r=p.useCallback(async s=>{const a="Error updating depreciation record",o=hu;F.loading("Updating depreciation record",{id:o});try{const i=await t(s),c=Oe(i,a,o,"updateDepreciationRecord");if(c)return F.success("Success",{id:o,description:"Depreciation record was updated"}),c.updateDepreciationRecord}catch(i){console.error(`${a}: ${i}`),F.error("Error",{id:o,description:a,duration:1e5,closeButton:!0})}},[t]);return{fetching:e,updateDepreciationRecord:r}},yu="deleteDepreciationRecord",vu=()=>{const[{fetching:e},t]=Ee(Oo),r=p.useCallback(async s=>{const a="Error deleting depreciation record",o=`${yu}-${s.depreciationRecordId}`;F.loading("Deleting depreciation record",{id:o});try{const i=await t(s),c=Oe(i,a,o);if(c)return F.success("Success",{id:o,description:"Depreciation record was deleted"}),c.deleteDepreciationRecord}catch(i){console.error(`${a}: ${i}`),F.error("Error",{id:o,description:a,duration:1e5,closeButton:!0})}},[t]);return{fetching:e,deleteDepreciationRecord:r}};function ju(e){const{fetching:t,deleteDepreciationRecord:r}=vu(),s=p.useCallback(()=>{r({depreciationRecordId:e.depreciationRecordId}).then(()=>{e.onDelete?.()})},[e,r]);return n.jsx(Ke,{content:"Remove Depreciation",children:n.jsx(en,{onConfirm:s,title:"Are you sure you want to delete the depreciation record?",children:n.jsx(q,{variant:"outline",size:"icon",className:"size-7.5 text-red-500",disabled:t,children:n.jsx(Fn,{className:"size-5"})})})})}const bu=({data:e,onChange:t})=>{const r=L(Po,e),[s,a]=p.useState(!1),[{data:o,fetching:i},c]=ke({query:Is,pause:!0}),{control:l,handleSubmit:d,formState:{dirtyFields:y}}=An({defaultValues:{id:r.id}}),{updateDepreciationRecord:g,fetching:m}=xu(),x=u=>{const j=No(u,y);j&&Object.keys(j).length>0&&g({fields:{...u,id:r.id}}).then(()=>{t?.(),a(!1)})},f=o?.depreciationCategories.map(u=>({value:u.id,label:u.name}));return p.useEffect(()=>{s&&!o&&c()},[s,o,c]),n.jsxs("tr",{children:[n.jsx("td",{children:n.jsx("form",{id:`form ${r.id}`,onSubmit:d(x),children:s?n.jsx(Fe,{name:"amount",control:l,render:({field:u,fieldState:j})=>n.jsx(Fe,{name:"currency",control:l,render:({field:v,fieldState:b})=>n.jsx(Os,{...u,defaultValue:r.amount?.raw??r.charge.totalAmount?.raw,value:u.value??void 0,error:j.error?.message||b.error?.message,label:"Amount",currencyCodeProps:{...v,label:"Currency",defaultValue:r.amount?.currency??r.charge.totalAmount?.currency}})})}):n.jsx("div",{children:r.amount?.formatted??r.charge.totalAmount?.formatted})})}),n.jsx("td",{children:n.jsx("div",{className:"flex flex-col gap-2 justify-center",children:s?n.jsx(Fe,{name:"activationDate",control:l,defaultValue:r.activationDate,rules:{pattern:{value:_s,message:"Date must be im format yyyy-mm-dd"}},render:({field:{value:u,...j},fieldState:v})=>{const b=u?new Date(u):void 0;return n.jsx(Es,{...j,form:`form ${r.id}`,onChange:C=>{const S=C?typeof C=="string"?C:He(C,"yyyy-MM-dd"):void 0;S!==u&&j.onChange(S)},value:b,label:"Activation Date",error:v.error?.message,popoverProps:{withinPortal:!0}})}}):n.jsx("div",{children:He(new Date(r.activationDate),"dd/MM/yy")})})}),n.jsx("td",{children:s?n.jsx(Fe,{name:"categoryId",control:l,render:({field:u,fieldState:j})=>n.jsx(Lt,{...u,form:`form ${r.id}`,disabled:i,data:f??[],label:"Category",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:j.error?.message,withinPortal:!0})}):n.jsxs("div",{children:[r.category.name," (",r.category.percentage,"%)"]})}),n.jsx("td",{children:s?n.jsx(Fe,{name:"type",control:l,render:({field:u,fieldState:j})=>n.jsx(Lt,{...u,form:`form ${r.id}`,data:Ea,value:u.value,label:"Type",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:j.error?.message,withinPortal:!0})}):n.jsx("div",{children:r.type})}),n.jsxs("td",{children:[n.jsx(Ke,{content:"Edit",children:n.jsx(q,{disabled:m||i,variant:s?"default":"outline",size:"icon",className:"size-7.5",onClick:u=>{u.stopPropagation(),a(j=>!j)},children:n.jsx(ys,{className:"size-5"})})}),s&&n.jsx(Ke,{content:"Confirm Changes",children:n.jsx(q,{type:"submit",form:`form ${r.id}`,variant:"outline",size:"icon",className:"size-7.5 text-green-500",children:n.jsx(Ao,{className:"size-5"})})}),n.jsx(ju,{depreciationRecordId:r.id,onDelete:t})]})]},r.id)},Cu=({chargeId:e,onChange:t})=>{const[{data:r,fetching:s}]=ke({query:To,variables:{chargeId:e}});return!s&&!r?.depreciationRecordsByCharge.length?n.jsx(Yr,{chargeId:e,onAdd:t}):s?n.jsx(Mn,{className:"h-10 w-10 animate-spin mr-2 self-center"}):n.jsx("div",{className:"flex flex-col gap-2 mt-5",children:n.jsxs(Gs,{highlightOnHover:!0,withBorder:!0,children:[n.jsx("thead",{children:n.jsxs("tr",{children:[n.jsx("th",{children:"Amount"}),n.jsx("th",{children:"Activation Date"}),n.jsx("th",{children:"Category"}),n.jsx("th",{children:"Type"}),n.jsx("th",{})]})}),n.jsxs("tbody",{children:[r?.depreciationRecordsByCharge.map(a=>n.jsx(bu,{data:a,onChange:t},a.id)),n.jsx("tr",{children:n.jsx("td",{colSpan:5,children:n.jsx(Yr,{chargeId:e,onAdd:t})})})]})]})})},Ea=Object.entries(ko).map(([e,t])=>({value:t,label:e}));function Du({chargeId:e,chargeType:t,setInsertDocument:r,setMatchDocuments:s,onChange:a,isIncome:o}){const{deleteCharge:i}=el(),[c,l]=p.useState(!1),[d,{open:y,close:g}]=xt(!1),[m,x]=p.useState(!1),[f,{open:u,close:j}]=xt(!1),[v,b]=p.useState(!1),[C,S]=p.useState(!1);function O(){i({chargeId:e}),a?.()}function _(){l(!1)}return n.jsxs(n.Fragment,{children:[n.jsxs(ie,{shadow:"md",width:200,opened:c,children:[n.jsx(ie.Target,{children:n.jsx(Ci,{opened:c,onClick:D=>{D.stopPropagation(),l(E=>!E)}})}),n.jsxs(ie.Dropdown,{children:[n.jsx(ie.Label,{children:"Charge"}),n.jsx(en,{onConfirm:O,title:"Are you sure you want to delete this charge?",children:n.jsx(ie.Item,{icon:n.jsx(Fn,{size:14}),children:"Delete Charge"})}),n.jsx(ie.Divider,{}),n.jsx(ie.Label,{children:"Documents"}),r&&n.jsx(ie.Item,{icon:n.jsx(un,{size:14}),onClick:D=>{D.stopPropagation(),r(),_()},children:"Insert Document"}),n.jsx(ie.Item,{icon:n.jsx(gr,{size:14}),onClick:D=>{D.stopPropagation(),S(!0),_()},children:"Upload Documents"}),s&&n.jsx(ie.Item,{icon:n.jsx($o,{size:14}),onClick:()=>{s(),_()},children:"Match Document"}),o&&n.jsx(ie.Item,{icon:n.jsx(un,{size:14}),onClick:D=>{D.stopPropagation(),b(!0),_()},children:"Issue Document"}),n.jsx(ie.Divider,{}),n.jsx(ie.Label,{children:"Misc Expenses"}),n.jsx(ie.Item,{icon:n.jsx(un,{size:14}),onClick:D=>{D.stopPropagation(),_(),x(!0)},children:"Add expense"}),t==="CommonCharge"&&n.jsxs(n.Fragment,{children:[n.jsx(ie.Divider,{}),n.jsx(ie.Label,{children:"Depreciation"}),n.jsx(ie.Item,{icon:n.jsx(Ai,{size:14}),onClick:D=>{D.stopPropagation(),y(),_()},children:"Depreciation"})]}),t==="SalaryCharge"&&n.jsxs(n.Fragment,{children:[n.jsx(ie.Divider,{}),n.jsx(ie.Label,{children:"Salaries"}),n.jsx(ie.Item,{icon:n.jsx(gr,{size:14}),onClick:D=>{D.stopPropagation(),_(),u()},children:"Payroll file upload"})]})]})]}),n.jsx(mt,{withinPortal:!0,size:"xl",centered:!0,opened:d,onClose:g,title:"Depreciation",onClick:D=>D.stopPropagation(),children:n.jsx(Cu,{chargeId:e,onChange:()=>{g(),a?.()}})}),n.jsx(St,{open:m,onOpenChange:x,children:n.jsx(wt,{className:"sm:max-w-[425px]",onClick:D=>D.stopPropagation(),children:n.jsx(ui,{onDone:()=>{x(!1),a?.()},chargeId:e})})}),n.jsx(mt,{centered:!0,opened:f,onClose:j,title:"Upload Payroll File",onClick:D=>D.stopPropagation(),children:n.jsx(ul,{onDone:()=>{j(),a?.()},chargeId:e})}),n.jsx(Fo,{open:C,onOpenChange:S,onChange:a,chargeId:e}),n.jsx(bn,{chargeId:e,open:v,setOpen:b,onDone:()=>a?.()})]})}function Su(e){return Object.prototype.toString.call(e)==="[object Object]"}function Qr(e){return Su(e)||Array.isArray(e)}function wu(){return!!(typeof window<"u"&&window.document&&window.document.createElement)}function Vn(e,t){const r=Object.keys(e),s=Object.keys(t);if(r.length!==s.length)return!1;const a=JSON.stringify(Object.keys(e.breakpoints||{})),o=JSON.stringify(Object.keys(t.breakpoints||{}));return a!==o?!1:r.every(i=>{const c=e[i],l=t[i];return typeof c=="function"?`${c}`==`${l}`:!Qr(c)||!Qr(l)?c===l:Vn(c,l)})}function Jr(e){return e.concat().sort((t,r)=>t.name>r.name?1:-1).map(t=>t.options)}function Iu(e,t){if(e.length!==t.length)return!1;const r=Jr(e),s=Jr(t);return r.every((a,o)=>{const i=s[o];return Vn(a,i)})}function Un(e){return typeof e=="number"}function En(e){return typeof e=="string"}function on(e){return typeof e=="boolean"}function Xr(e){return Object.prototype.toString.call(e)==="[object Object]"}function X(e){return Math.abs(e)}function Kn(e){return Math.sign(e)}function ht(e,t){return X(e-t)}function _u(e,t){if(e===0||t===0||X(e)<=X(t))return 0;const r=ht(X(e),X(t));return X(r/e)}function Eu(e){return Math.round(e*100)/100}function jt(e){return bt(e).map(Number)}function Te(e){return e[_t(e)]}function _t(e){return Math.max(0,e.length-1)}function Hn(e,t){return t===_t(e)}function Zr(e,t=0){return Array.from(Array(e),(r,s)=>t+s)}function bt(e){return Object.keys(e)}function Oa(e,t){return[e,t].reduce((r,s)=>(bt(s).forEach(a=>{const o=r[a],i=s[a],c=Xr(o)&&Xr(i);r[a]=c?Oa(o,i):i}),r),{})}function On(e,t){return typeof t.MouseEvent<"u"&&e instanceof t.MouseEvent}function Ou(e,t){const r={start:s,center:a,end:o};function s(){return 0}function a(l){return o(l)/2}function o(l){return t-l}function i(l,d){return En(e)?r[e](l):e(t,l,d)}return{measure:i}}function Ct(){let e=[];function t(a,o,i,c={passive:!0}){let l;if("addEventListener"in a)a.addEventListener(o,i,c),l=()=>a.removeEventListener(o,i,c);else{const d=a;d.addListener(i),l=()=>d.removeListener(i)}return e.push(l),s}function r(){e=e.filter(a=>a())}const s={add:t,clear:r};return s}function Au(e,t,r,s){const a=Ct(),o=1e3/60;let i=null,c=0,l=0;function d(){a.add(e,"visibilitychange",()=>{e.hidden&&f()})}function y(){x(),a.clear()}function g(j){if(!l)return;i||(i=j,r(),r());const v=j-i;for(i=j,c+=v;c>=o;)r(),c-=o;const b=c/o;s(b),l&&(l=t.requestAnimationFrame(g))}function m(){l||(l=t.requestAnimationFrame(g))}function x(){t.cancelAnimationFrame(l),i=null,c=0,l=0}function f(){i=null,c=0}return{init:d,destroy:y,start:m,stop:x,update:r,render:s}}function Pu(e,t){const r=t==="rtl",s=e==="y",a=s?"y":"x",o=s?"x":"y",i=!s&&r?-1:1,c=y(),l=g();function d(f){const{height:u,width:j}=f;return s?u:j}function y(){return s?"top":r?"right":"left"}function g(){return s?"bottom":r?"left":"right"}function m(f){return f*i}return{scroll:a,cross:o,startEdge:c,endEdge:l,measureSize:d,direction:m}}function Ze(e=0,t=0){const r=X(e-t);function s(d){return d<e}function a(d){return d>t}function o(d){return s(d)||a(d)}function i(d){return o(d)?s(d)?e:t:d}function c(d){return r?d-r*Math.ceil((d-t)/r):d}return{length:r,max:t,min:e,constrain:i,reachedAny:o,reachedMax:a,reachedMin:s,removeOffset:c}}function Aa(e,t,r){const{constrain:s}=Ze(0,e),a=e+1;let o=i(t);function i(m){return r?X((a+m)%a):s(m)}function c(){return o}function l(m){return o=i(m),g}function d(m){return y().set(c()+m)}function y(){return Aa(e,c(),r)}const g={get:c,set:l,add:d,clone:y};return g}function Nu(e,t,r,s,a,o,i,c,l,d,y,g,m,x,f,u,j,v,b){const{cross:C,direction:S}=e,O=["INPUT","SELECT","TEXTAREA"],_={passive:!1},D=Ct(),E=Ct(),A=Ze(50,225).constrain(x.measure(20)),M={mouse:300,touch:400},h={mouse:500,touch:600},T=f?43:25;let Q=!1,R=0,V=0,ue=!1,le=!1,ee=!1,H=!1;function ye(I){if(!b)return;function U(re){(on(b)||b(I,re))&&ce(re)}const W=t;D.add(W,"dragstart",re=>re.preventDefault(),_).add(W,"touchmove",()=>{},_).add(W,"touchend",()=>{}).add(W,"touchstart",U).add(W,"mousedown",U).add(W,"touchcancel",N).add(W,"contextmenu",N).add(W,"click",fe,!0)}function B(){D.clear(),E.clear()}function se(){const I=H?r:t;E.add(I,"touchmove",te,_).add(I,"touchend",N).add(I,"mousemove",te,_).add(I,"mouseup",N)}function me(I){const U=I.nodeName||"";return O.includes(U)}function G(){return(f?h:M)[H?"mouse":"touch"]}function ve(I,U){const W=g.add(Kn(I)*-1),re=y.byDistance(I,!f).distance;return f||X(I)<A?re:j&&U?re*.5:y.byIndex(W.get(),0).distance}function ce(I){const U=On(I,s);H=U,ee=f&&U&&!I.buttons&&Q,Q=ht(a.get(),i.get())>=2,!(U&&I.button!==0)&&(me(I.target)||(ue=!0,o.pointerDown(I),d.useFriction(0).useDuration(0),a.set(i),se(),R=o.readPoint(I),V=o.readPoint(I,C),m.emit("pointerDown")))}function te(I){if(!On(I,s)&&I.touches.length>=2)return N(I);const W=o.readPoint(I),re=o.readPoint(I,C),pe=ht(W,R),de=ht(re,V);if(!le&&!H&&(!I.cancelable||(le=pe>de,!le)))return N(I);const je=o.pointerMove(I);pe>u&&(ee=!0),d.useFriction(.3).useDuration(.75),c.start(),a.add(S(je)),I.preventDefault()}function N(I){const W=y.byDistance(0,!1).index!==g.get(),re=o.pointerUp(I)*G(),pe=ve(S(re),W),de=_u(re,pe),je=T-10*de,ge=v+de/50;le=!1,ue=!1,E.clear(),d.useDuration(je).useFriction(ge),l.distance(pe,!f),H=!1,m.emit("pointerUp")}function fe(I){ee&&(I.stopPropagation(),I.preventDefault(),ee=!1)}function ne(){return ue}return{init:ye,destroy:B,pointerDown:ne}}function Tu(e,t){let s,a;function o(g){return g.timeStamp}function i(g,m){const f=`client${(m||e.scroll)==="x"?"X":"Y"}`;return(On(g,t)?g:g.touches[0])[f]}function c(g){return s=g,a=g,i(g)}function l(g){const m=i(g)-i(a),x=o(g)-o(s)>170;return a=g,x&&(s=g),m}function d(g){if(!s||!a)return 0;const m=i(a)-i(s),x=o(g)-o(s),f=o(g)-o(a)>170,u=m/x;return x&&!f&&X(u)>.1?u:0}return{pointerDown:c,pointerMove:l,pointerUp:d,readPoint:i}}function ku(){function e(r){const{offsetTop:s,offsetLeft:a,offsetWidth:o,offsetHeight:i}=r;return{top:s,right:a+o,bottom:s+i,left:a,width:o,height:i}}return{measure:e}}function $u(e){function t(s){return e*(s/100)}return{measure:t}}function Fu(e,t,r,s,a,o,i){const c=[e].concat(s);let l,d,y=[],g=!1;function m(j){return a.measureSize(i.measure(j))}function x(j){if(!o)return;d=m(e),y=s.map(m);function v(b){for(const C of b){if(g)return;const S=C.target===e,O=s.indexOf(C.target),_=S?d:y[O],D=m(S?e:s[O]);if(X(D-_)>=.5){j.reInit(),t.emit("resize");break}}}l=new ResizeObserver(b=>{(on(o)||o(j,b))&&v(b)}),r.requestAnimationFrame(()=>{c.forEach(b=>l.observe(b))})}function f(){g=!0,l&&l.disconnect()}return{init:x,destroy:f}}function Mu(e,t,r,s,a,o){let i=0,c=0,l=a,d=o,y=e.get(),g=0;function m(){const _=s.get()-e.get(),D=!l;let E=0;return D?(i=0,r.set(s),e.set(s),E=_):(r.set(e),i+=_/l,i*=d,y+=i,e.add(i),E=y-g),c=Kn(E),g=y,O}function x(){const _=s.get()-t.get();return X(_)<.001}function f(){return l}function u(){return c}function j(){return i}function v(){return C(a)}function b(){return S(o)}function C(_){return l=_,O}function S(_){return d=_,O}const O={direction:u,duration:f,velocity:j,seek:m,settled:x,useBaseFriction:b,useBaseDuration:v,useFriction:S,useDuration:C};return O}function Ru(e,t,r,s,a){const o=a.measure(10),i=a.measure(50),c=Ze(.1,.99);let l=!1;function d(){return!(l||!e.reachedAny(r.get())||!e.reachedAny(t.get()))}function y(x){if(!d())return;const f=e.reachedMin(t.get())?"min":"max",u=X(e[f]-t.get()),j=r.get()-t.get(),v=c.constrain(u/i);r.subtract(j*v),!x&&X(j)<o&&(r.set(e.constrain(r.get())),s.useDuration(25).useBaseFriction())}function g(x){l=!x}return{shouldConstrain:d,constrain:y,toggleActive:g}}function zu(e,t,r,s,a){const o=Ze(-t+e,0),i=g(),c=y(),l=m();function d(f,u){return ht(f,u)<=1}function y(){const f=i[0],u=Te(i),j=i.lastIndexOf(f),v=i.indexOf(u)+1;return Ze(j,v)}function g(){return r.map((f,u)=>{const{min:j,max:v}=o,b=o.constrain(f),C=!u,S=Hn(r,u);return C?v:S||d(j,b)?j:d(v,b)?v:b}).map(f=>parseFloat(f.toFixed(3)))}function m(){if(t<=e+a)return[o.max];if(s==="keepSnaps")return i;const{min:f,max:u}=c;return i.slice(f,u)}return{snapsContained:l,scrollContainLimit:c}}function Lu(e,t,r){const s=t[0],a=r?s-e:Te(t);return{limit:Ze(a,s)}}function Bu(e,t,r,s){const o=t.min+.1,i=t.max+.1,{reachedMin:c,reachedMax:l}=Ze(o,i);function d(m){return m===1?l(r.get()):m===-1?c(r.get()):!1}function y(m){if(!d(m))return;const x=e*(m*-1);s.forEach(f=>f.add(x))}return{loop:y}}function Vu(e){const{max:t,length:r}=e;function s(o){const i=o-t;return r?i/-r:0}return{get:s}}function Uu(e,t,r,s,a){const{startEdge:o,endEdge:i}=e,{groupSlides:c}=a,l=g().map(t.measure),d=m(),y=x();function g(){return c(s).map(u=>Te(u)[i]-u[0][o]).map(X)}function m(){return s.map(u=>r[o]-u[o]).map(u=>-X(u))}function x(){return c(d).map(u=>u[0]).map((u,j)=>u+l[j])}return{snaps:d,snapsAligned:y}}function Ku(e,t,r,s,a,o){const{groupSlides:i}=a,{min:c,max:l}=s,d=y();function y(){const m=i(o),x=!e||t==="keepSnaps";return r.length===1?[o]:x?m:m.slice(c,l).map((f,u,j)=>{const v=!u,b=Hn(j,u);if(v){const C=Te(j[0])+1;return Zr(C)}if(b){const C=_t(o)-Te(j)[0]+1;return Zr(C,Te(j)[0])}return f})}return{slideRegistry:d}}function Hu(e,t,r,s,a){const{reachedAny:o,removeOffset:i,constrain:c}=s;function l(f){return f.concat().sort((u,j)=>X(u)-X(j))[0]}function d(f){const u=e?i(f):c(f),j=t.map((b,C)=>({diff:y(b-u,0),index:C})).sort((b,C)=>X(b.diff)-X(C.diff)),{index:v}=j[0];return{index:v,distance:u}}function y(f,u){const j=[f,f+r,f-r];if(!e)return f;if(!u)return l(j);const v=j.filter(b=>Kn(b)===u);return v.length?l(v):Te(j)-r}function g(f,u){const j=t[f]-a.get(),v=y(j,u);return{index:f,distance:v}}function m(f,u){const j=a.get()+f,{index:v,distance:b}=d(j),C=!e&&o(j);if(!u||C)return{index:v,distance:f};const S=t[v]-b,O=f+y(S,0);return{index:v,distance:O}}return{byDistance:m,byIndex:g,shortcut:y}}function Gu(e,t,r,s,a,o,i){function c(g){const m=g.distance,x=g.index!==t.get();o.add(m),m&&(s.duration()?e.start():(e.update(),e.render(1),e.update())),x&&(r.set(t.get()),t.set(g.index),i.emit("select"))}function l(g,m){const x=a.byDistance(g,m);c(x)}function d(g,m){const x=t.clone().set(g),f=a.byIndex(x.get(),m);c(f)}return{distance:l,index:d}}function qu(e,t,r,s,a,o,i,c){const l={passive:!0,capture:!0};let d=0;function y(x){if(!c)return;function f(u){if(new Date().getTime()-d>10)return;i.emit("slideFocusStart"),e.scrollLeft=0;const b=r.findIndex(C=>C.includes(u));Un(b)&&(a.useDuration(0),s.index(b,0),i.emit("slideFocus"))}o.add(document,"keydown",g,!1),t.forEach((u,j)=>{o.add(u,"focus",v=>{(on(c)||c(x,v))&&f(j)},l)})}function g(x){x.code==="Tab"&&(d=new Date().getTime())}return{init:y}}function gt(e){let t=e;function r(){return t}function s(l){t=i(l)}function a(l){t+=i(l)}function o(l){t-=i(l)}function i(l){return Un(l)?l:l.get()}return{get:r,set:s,add:a,subtract:o}}function Pa(e,t){const r=e.scroll==="x"?i:c,s=t.style;let a=null,o=!1;function i(m){return`translate3d(${m}px,0px,0px)`}function c(m){return`translate3d(0px,${m}px,0px)`}function l(m){if(o)return;const x=Eu(e.direction(m));x!==a&&(s.transform=r(x),a=x)}function d(m){o=!m}function y(){o||(s.transform="",t.getAttribute("style")||t.removeAttribute("style"))}return{clear:y,to:l,toggleActive:d}}function Wu(e,t,r,s,a,o,i,c,l){const y=jt(a),g=jt(a).reverse(),m=v().concat(b());function x(D,E){return D.reduce((A,M)=>A-a[M],E)}function f(D,E){return D.reduce((A,M)=>x(A,E)>0?A.concat([M]):A,[])}function u(D){return o.map((E,A)=>({start:E-s[A]+.5+D,end:E+t-.5+D}))}function j(D,E,A){const M=u(E);return D.map(h=>{const T=A?0:-r,Q=A?r:0,R=A?"end":"start",V=M[h][R];return{index:h,loopPoint:V,slideLocation:gt(-1),translate:Pa(e,l[h]),target:()=>c.get()>V?T:Q}})}function v(){const D=i[0],E=f(g,D);return j(E,r,!1)}function b(){const D=t-i[0]-1,E=f(y,D);return j(E,-r,!0)}function C(){return m.every(({index:D})=>{const E=y.filter(A=>A!==D);return x(E,t)<=.1})}function S(){m.forEach(D=>{const{target:E,translate:A,slideLocation:M}=D,h=E();h!==M.get()&&(A.to(h),M.set(h))})}function O(){m.forEach(D=>D.translate.clear())}return{canLoop:C,clear:O,loop:S,loopPoints:m}}function Yu(e,t,r){let s,a=!1;function o(l){if(!r)return;function d(y){for(const g of y)if(g.type==="childList"){l.reInit(),t.emit("slidesChanged");break}}s=new MutationObserver(y=>{a||(on(r)||r(l,y))&&d(y)}),s.observe(e,{childList:!0})}function i(){s&&s.disconnect(),a=!0}return{init:o,destroy:i}}function Qu(e,t,r,s){const a={};let o=null,i=null,c,l=!1;function d(){c=new IntersectionObserver(f=>{l||(f.forEach(u=>{const j=t.indexOf(u.target);a[j]=u}),o=null,i=null,r.emit("slidesInView"))},{root:e.parentElement,threshold:s}),t.forEach(f=>c.observe(f))}function y(){c&&c.disconnect(),l=!0}function g(f){return bt(a).reduce((u,j)=>{const v=parseInt(j),{isIntersecting:b}=a[v];return(f&&b||!f&&!b)&&u.push(v),u},[])}function m(f=!0){if(f&&o)return o;if(!f&&i)return i;const u=g(f);return f&&(o=u),f||(i=u),u}return{init:d,destroy:y,get:m}}function Ju(e,t,r,s,a,o){const{measureSize:i,startEdge:c,endEdge:l}=e,d=r[0]&&a,y=f(),g=u(),m=r.map(i),x=j();function f(){if(!d)return 0;const b=r[0];return X(t[c]-b[c])}function u(){if(!d)return 0;const b=o.getComputedStyle(Te(s));return parseFloat(b.getPropertyValue(`margin-${l}`))}function j(){return r.map((b,C,S)=>{const O=!C,_=Hn(S,C);return O?m[C]+y:_?m[C]+g:S[C+1][c]-b[c]}).map(X)}return{slideSizes:m,slideSizesWithGaps:x,startGap:y,endGap:g}}function Xu(e,t,r,s,a,o,i,c,l){const{startEdge:d,endEdge:y,direction:g}=e,m=Un(r);function x(v,b){return jt(v).filter(C=>C%b===0).map(C=>v.slice(C,C+b))}function f(v){return v.length?jt(v).reduce((b,C,S)=>{const O=Te(b)||0,_=O===0,D=C===_t(v),E=a[d]-o[O][d],A=a[d]-o[C][y],M=!s&&_?g(i):0,h=!s&&D?g(c):0,T=X(A-h-(E+M));return S&&T>t+l&&b.push(C),D&&b.push(v.length),b},[]).map((b,C,S)=>{const O=Math.max(S[C-1]||0);return v.slice(O,b)}):[]}function u(v){return m?x(v,r):f(v)}return{groupSlides:u}}function Zu(e,t,r,s,a,o,i){const{align:c,axis:l,direction:d,startIndex:y,loop:g,duration:m,dragFree:x,dragThreshold:f,inViewThreshold:u,slidesToScroll:j,skipSnaps:v,containScroll:b,watchResize:C,watchSlides:S,watchDrag:O,watchFocus:_}=o,D=2,E=ku(),A=E.measure(t),M=r.map(E.measure),h=Pu(l,d),T=h.measureSize(A),Q=$u(T),R=Ou(c,T),V=!g&&!!b,ue=g||!!b,{slideSizes:le,slideSizesWithGaps:ee,startGap:H,endGap:ye}=Ju(h,A,M,r,ue,a),B=Xu(h,T,j,g,A,M,H,ye,D),{snaps:se,snapsAligned:me}=Uu(h,R,A,M,B),G=-Te(se)+Te(ee),{snapsContained:ve,scrollContainLimit:ce}=zu(T,G,me,b,D),te=V?ve:me,{limit:N}=Lu(G,te,g),fe=Aa(_t(te),y,g),ne=fe.clone(),K=jt(r),I=({dragHandler:Se,scrollBody:Ye,scrollBounds:Qe,options:{loop:Ve}})=>{Ve||Qe.constrain(Se.pointerDown()),Ye.seek()},U=({scrollBody:Se,translate:Ye,location:Qe,offsetLocation:Ve,previousLocation:et,scrollLooper:lt,slideLooper:dt,dragHandler:ut,animation:ft,eventHandler:Et,scrollBounds:Ma,options:{loop:Wn}},Yn)=>{const Qn=Se.settled(),Ra=!Ma.shouldConstrain(),Jn=Wn?Qn:Qn&&Ra,Xn=Jn&&!ut.pointerDown();Xn&&ft.stop();const za=Qe.get()*Yn+et.get()*(1-Yn);Ve.set(za),Wn&&(lt.loop(Se.direction()),dt.loop()),Ye.to(Ve.get()),Xn&&Et.emit("settle"),Jn||Et.emit("scroll")},W=Au(s,a,()=>I(Re),Se=>U(Re,Se)),re=.68,pe=te[fe.get()],de=gt(pe),je=gt(pe),ge=gt(pe),be=gt(pe),ae=Mu(de,ge,je,be,m,re),Me=Hu(g,te,G,N,be),ct=Gu(W,fe,ne,ae,Me,be,i),w=Vu(N),P=Ct(),Z=Qu(t,r,i,u),{slideRegistry:oe}=Ku(V,b,te,ce,B,K),he=qu(e,r,oe,ct,ae,P,i,_),Re={ownerDocument:s,ownerWindow:a,eventHandler:i,containerRect:A,slideRects:M,animation:W,axis:h,dragHandler:Nu(h,e,s,a,be,Tu(h,a),de,W,ct,ae,Me,fe,i,Q,x,f,v,re,O),eventStore:P,percentOfView:Q,index:fe,indexPrevious:ne,limit:N,location:de,offsetLocation:ge,previousLocation:je,options:o,resizeHandler:Fu(t,i,a,r,h,C,E),scrollBody:ae,scrollBounds:Ru(N,ge,be,ae,Q),scrollLooper:Bu(G,N,ge,[de,ge,je,be]),scrollProgress:w,scrollSnapList:te.map(w.get),scrollSnaps:te,scrollTarget:Me,scrollTo:ct,slideLooper:Wu(h,T,G,le,ee,se,te,ge,r),slideFocus:he,slidesHandler:Yu(t,i,S),slidesInView:Z,slideIndexes:K,slideRegistry:oe,slidesToScroll:B,target:be,translate:Pa(h,t)};return Re}function ef(){let e={},t;function r(d){t=d}function s(d){return e[d]||[]}function a(d){return s(d).forEach(y=>y(t,d)),l}function o(d,y){return e[d]=s(d).concat([y]),l}function i(d,y){return e[d]=s(d).filter(g=>g!==y),l}function c(){e={}}const l={init:r,emit:a,off:i,on:o,clear:c};return l}const tf={align:"center",axis:"x",container:null,slides:null,containScroll:"trimSnaps",direction:"ltr",slidesToScroll:1,inViewThreshold:0,breakpoints:{},dragFree:!1,dragThreshold:10,loop:!1,skipSnaps:!1,duration:25,startIndex:0,active:!0,watchDrag:!0,watchResize:!0,watchSlides:!0,watchFocus:!0};function nf(e){function t(o,i){return Oa(o,i||{})}function r(o){const i=o.breakpoints||{},c=bt(i).filter(l=>e.matchMedia(l).matches).map(l=>i[l]).reduce((l,d)=>t(l,d),{});return t(o,c)}function s(o){return o.map(i=>bt(i.breakpoints||{})).reduce((i,c)=>i.concat(c),[]).map(e.matchMedia)}return{mergeOptions:t,optionsAtMedia:r,optionsMediaQueries:s}}function rf(e){let t=[];function r(o,i){return t=i.filter(({options:c})=>e.optionsAtMedia(c).active!==!1),t.forEach(c=>c.init(o,e)),i.reduce((c,l)=>Object.assign(c,{[l.name]:l}),{})}function s(){t=t.filter(o=>o.destroy())}return{init:r,destroy:s}}function Jt(e,t,r){const s=e.ownerDocument,a=s.defaultView,o=nf(a),i=rf(o),c=Ct(),l=ef(),{mergeOptions:d,optionsAtMedia:y,optionsMediaQueries:g}=o,{on:m,off:x,emit:f}=l,u=h;let j=!1,v,b=d(tf,Jt.globalOptions),C=d(b),S=[],O,_,D;function E(){const{container:K,slides:I}=C;_=(En(K)?e.querySelector(K):K)||e.children[0];const W=En(I)?_.querySelectorAll(I):I;D=[].slice.call(W||_.children)}function A(K){const I=Zu(e,_,D,s,a,K,l);if(K.loop&&!I.slideLooper.canLoop()){const U=Object.assign({},K,{loop:!1});return A(U)}return I}function M(K,I){j||(b=d(b,K),C=y(b),S=I||S,E(),v=A(C),g([b,...S.map(({options:U})=>U)]).forEach(U=>c.add(U,"change",h)),C.active&&(v.translate.to(v.location.get()),v.animation.init(),v.slidesInView.init(),v.slideFocus.init(ne),v.eventHandler.init(ne),v.resizeHandler.init(ne),v.slidesHandler.init(ne),v.options.loop&&v.slideLooper.loop(),_.offsetParent&&D.length&&v.dragHandler.init(ne),O=i.init(ne,S)))}function h(K,I){const U=B();T(),M(d({startIndex:U},K),I),l.emit("reInit")}function T(){v.dragHandler.destroy(),v.eventStore.clear(),v.translate.clear(),v.slideLooper.clear(),v.resizeHandler.destroy(),v.slidesHandler.destroy(),v.slidesInView.destroy(),v.animation.destroy(),i.destroy(),c.clear()}function Q(){j||(j=!0,c.clear(),T(),l.emit("destroy"),l.clear())}function R(K,I,U){!C.active||j||(v.scrollBody.useBaseFriction().useDuration(I===!0?0:C.duration),v.scrollTo.index(K,U||0))}function V(K){const I=v.index.add(1).get();R(I,K,-1)}function ue(K){const I=v.index.add(-1).get();R(I,K,1)}function le(){return v.index.add(1).get()!==B()}function ee(){return v.index.add(-1).get()!==B()}function H(){return v.scrollSnapList}function ye(){return v.scrollProgress.get(v.offsetLocation.get())}function B(){return v.index.get()}function se(){return v.indexPrevious.get()}function me(){return v.slidesInView.get()}function G(){return v.slidesInView.get(!1)}function ve(){return O}function ce(){return v}function te(){return e}function N(){return _}function fe(){return D}const ne={canScrollNext:le,canScrollPrev:ee,containerNode:N,internalEngine:ce,destroy:Q,off:x,on:m,emit:f,plugins:ve,previousScrollSnap:se,reInit:u,rootNode:te,scrollNext:V,scrollPrev:ue,scrollProgress:ye,scrollSnapList:H,scrollTo:R,selectedScrollSnap:B,slideNodes:fe,slidesInView:me,slidesNotInView:G};return M(t,r),setTimeout(()=>l.emit("init"),0),ne}Jt.globalOptions=void 0;function Gn(e={},t=[]){const r=p.useRef(e),s=p.useRef(t),[a,o]=p.useState(),[i,c]=p.useState(),l=p.useCallback(()=>{a&&a.reInit(r.current,s.current)},[a]);return p.useEffect(()=>{Vn(r.current,e)||(r.current=e,l())},[e,l]),p.useEffect(()=>{Iu(s.current,t)||(s.current=t,l())},[t,l]),p.useEffect(()=>{if(wu()&&i){Jt.globalOptions=Gn.globalOptions;const d=Jt(i,r.current,s.current);return o(d),()=>d.destroy()}else o(void 0)},[i,o]),[c,a]}Gn.globalOptions=void 0;const sf={context:"[@mantine/carousel] Carousel.Slide was rendered outside of Carousel context"},[af,of]=ms(sf.context);var cf=Object.defineProperty,lf=Object.defineProperties,df=Object.getOwnPropertyDescriptors,es=Object.getOwnPropertySymbols,uf=Object.prototype.hasOwnProperty,ff=Object.prototype.propertyIsEnumerable,ts=(e,t,r)=>t in e?cf(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,yn=(e,t)=>{for(var r in t||(t={}))uf.call(t,r)&&ts(e,r,t[r]);if(es)for(var r of es(t))ff.call(t,r)&&ts(e,r,t[r]);return e},pf=(e,t)=>lf(e,df(t)),gf=Ge((e,{controlSize:t,controlsOffset:r,orientation:s,height:a,includeGapInSize:o,breakpoints:i=[],slideGap:c})=>{const l=s==="horizontal",d=m=>{if(!o)return{};const x=Ie({size:m,sizes:e.spacing});return{[s==="horizontal"?"marginRight":"marginBottom"]:`calc(${x} * -1)`}},g=i.some(m=>typeof m.slideGap<"u"||typeof m.slideSize<"u")?As(e,i).reduce((m,x)=>{const f="maxWidth"in x?"max-width":"min-width",u=Ie({size:f==="max-width"?x.maxWidth:x.minWidth,sizes:e.breakpoints}),j=typeof x.slideGap>"u"?void 0:$(x.slideGap),v=Ps(u)-(f==="max-width"?1:0);return m[`@media (${f}: ${$(v)})`]=d(j),m},{}):null;return{root:{position:"relative"},viewport:{height:$(a),overflow:"hidden"},container:yn(yn({display:"flex",flexDirection:l?"row":"column",height:$(a)},d(c)),g),controls:{position:"absolute",zIndex:1,left:l?0:`calc(50% - ${$(t)} / 2)`,right:l?0:void 0,top:l?`calc(50% - ${$(t)} / 2)`:0,bottom:l?void 0:0,display:"flex",flexDirection:l?"row":"column",alignItems:"center",justifyContent:"space-between",paddingLeft:l?Ie({size:r,sizes:e.spacing}):void 0,paddingRight:l?Ie({size:r,sizes:e.spacing}):void 0,paddingTop:l?void 0:Ie({size:r,sizes:e.spacing}),paddingBottom:l?void 0:Ie({size:r,sizes:e.spacing}),pointerEvents:"none"},control:pf(yn({display:"flex",justifyContent:"center",alignItems:"center",minWidth:$(t),minHeight:$(t),borderRadius:$(t),pointerEvents:"all",backgroundColor:e.white,color:e.black,boxShadow:e.shadows.md,opacity:e.colorScheme==="dark"?.65:.85,border:`${$(1)} solid ${e.colors.gray[3]}`,transition:`opacity 150ms ${e.transitionTimingFunction}`},e.fn.hover({opacity:1})),{"&:active":e.activeStyles}),indicators:{position:"absolute",bottom:l?e.spacing.md:0,top:l?void 0:0,left:l?0:void 0,right:l?0:e.spacing.md,display:"flex",flexDirection:l?"row":"column",justifyContent:"center",gap:$(8),pointerEvents:"none"},indicator:{pointerEvents:"all",width:l?$(25):$(5),height:l?$(5):$(25),borderRadius:e.radius.xl,backgroundColor:e.white,boxShadow:e.shadows.sm,opacity:.6,transition:`opacity 150ms ${e.transitionTimingFunction}`,"&[data-active]":{opacity:1}}}}),mf=Object.defineProperty,ns=Object.getOwnPropertySymbols,hf=Object.prototype.hasOwnProperty,xf=Object.prototype.propertyIsEnumerable,rs=(e,t,r)=>t in e?mf(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,vn=(e,t)=>{for(var r in t||(t={}))hf.call(t,r)&&rs(e,r,t[r]);if(ns)for(var r of ns(t))xf.call(t,r)&&rs(e,r,t[r]);return e},yf=Ge((e,{size:t,gap:r,orientation:s,includeGapInSize:a,breakpoints:o=[]})=>{const i=(d,y)=>{const g=Ie({size:d,sizes:e.spacing}),m=$(y),x=a?{[s==="horizontal"?"paddingRight":"paddingBottom"]:g}:{[s==="horizontal"?"marginRight":"marginBottom"]:g};return vn({flex:`0 0 ${m}`},x)},l=o.some(d=>typeof d.slideGap<"u"||typeof d.slideSize<"u")?As(e,o).reduce((d,y)=>{const g="maxWidth"in y?"max-width":"min-width",m=Ie({size:g==="max-width"?y.maxWidth:y.minWidth,sizes:e.breakpoints}),x=typeof y.slideGap>"u"?r:y.slideGap,f=Ps(m)-(g==="max-width"?1:0);return d[`@media (${g}: ${$(f)})`]=i(x,y.slideSize),d},{}):null;return{slide:vn(vn({position:"relative"},i(r,t)),l)}}),vf=Object.defineProperty,Xt=Object.getOwnPropertySymbols,Na=Object.prototype.hasOwnProperty,Ta=Object.prototype.propertyIsEnumerable,ss=(e,t,r)=>t in e?vf(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,jf=(e,t)=>{for(var r in t||(t={}))Na.call(t,r)&&ss(e,r,t[r]);if(Xt)for(var r of Xt(t))Ta.call(t,r)&&ss(e,r,t[r]);return e},bf=(e,t)=>{var r={};for(var s in e)Na.call(e,s)&&t.indexOf(s)<0&&(r[s]=e[s]);if(e!=null&&Xt)for(var s of Xt(e))t.indexOf(s)<0&&Ta.call(e,s)&&(r[s]=e[s]);return r};const ka=p.forwardRef((e,t)=>{var r=e,{children:s,className:a,size:o,gap:i}=r,c=bf(r,["children","className","size","gap"]);const l=of(),{classes:d,cx:y}=yf({gap:typeof i>"u"?l.slideGap:i,size:typeof o>"u"?l.slideSize:o,orientation:l.orientation,includeGapInSize:l.includeGapInSize,breakpoints:l.breakpoints},{name:"Carousel",classNames:l.classNames,styles:l.styles,unstyled:l.unstyled,variant:l.variant});return k.createElement(We,jf({className:y(d.slide,a),ref:t},c),s)});ka.displayName="@mantine/carousel/CarouselSlide";function as({dir:e,orientation:t,direction:r}){return r==="previous"?t==="horizontal"?90*(e==="ltr"?1:-1):-180:t==="horizontal"?90*(e==="ltr"?-1:1):0}var Cf=Object.defineProperty,Zt=Object.getOwnPropertySymbols,$a=Object.prototype.hasOwnProperty,Fa=Object.prototype.propertyIsEnumerable,os=(e,t,r)=>t in e?Cf(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Df=(e,t)=>{for(var r in t||(t={}))$a.call(t,r)&&os(e,r,t[r]);if(Zt)for(var r of Zt(t))Fa.call(t,r)&&os(e,r,t[r]);return e},Sf=(e,t)=>{var r={};for(var s in e)$a.call(e,s)&&t.indexOf(s)<0&&(r[s]=e[s]);if(e!=null&&Zt)for(var s of Zt(e))t.indexOf(s)<0&&Fa.call(e,s)&&(r[s]=e[s]);return r};const wf={controlSize:26,controlsOffset:"sm",slideSize:"100%",slideGap:0,orientation:"horizontal",align:"center",slidesToScroll:1,includeGapInSize:!0,draggable:!0,dragFree:!1,loop:!1,speed:10,initialSlide:0,inViewThreshold:0,withControls:!0,withIndicators:!1,skipSnaps:!1,containScroll:"",withKeyboardEvents:!0},qn=p.forwardRef((e,t)=>{const r=qe("Carousel",wf,e),{children:s,className:a,getEmblaApi:o,onNextSlide:i,onPreviousSlide:c,onSlideChange:l,nextControlLabel:d,previousControlLabel:y,controlSize:g,controlsOffset:m,classNames:x,styles:f,unstyled:u,slideSize:j,slideGap:v,orientation:b,height:C,align:S,slidesToScroll:O,includeGapInSize:_,draggable:D,dragFree:E,loop:A,speed:M,initialSlide:h,inViewThreshold:T,withControls:Q,withIndicators:R,plugins:V,nextControlIcon:ue,previousControlIcon:le,breakpoints:ee,skipSnaps:H,containScroll:ye,withKeyboardEvents:B,variant:se}=r,me=Sf(r,["children","className","getEmblaApi","onNextSlide","onPreviousSlide","onSlideChange","nextControlLabel","previousControlLabel","controlSize","controlsOffset","classNames","styles","unstyled","slideSize","slideGap","orientation","height","align","slidesToScroll","includeGapInSize","draggable","dragFree","loop","speed","initialSlide","inViewThreshold","withControls","withIndicators","plugins","nextControlIcon","previousControlIcon","breakpoints","skipSnaps","containScroll","withKeyboardEvents","variant"]),{classes:G,cx:ve,theme:ce}=gf({controlSize:g,controlsOffset:m,orientation:b,height:C,includeGapInSize:_,breakpoints:ee,slideGap:v},{name:"Carousel",classNames:x,styles:f,unstyled:u,variant:se}),[te,N]=Gn({axis:b==="horizontal"?"x":"y",direction:b==="horizontal"?ce.dir:void 0,startIndex:h,loop:A,align:S,slidesToScroll:O,draggable:D,dragFree:E,speed:M,inViewThreshold:T,skipSnaps:H,containScroll:ye},V),[fe,ne]=p.useState(0),[K,I]=p.useState(0),U=p.useCallback(ae=>N&&N.scrollTo(ae),[N]),W=p.useCallback(()=>{if(!N)return;const ae=N.selectedScrollSnap();ne(ae),l?.(ae)},[N,ne]),re=p.useCallback(()=>{N?.scrollPrev(),c?.()},[N]),pe=p.useCallback(()=>{N?.scrollNext(),i?.()},[N]),de=p.useCallback(ae=>{B&&(ae.key==="ArrowRight"&&(ae.preventDefault(),pe()),ae.key==="ArrowLeft"&&(ae.preventDefault(),re()))},[N]);p.useEffect(()=>{if(N)return o?.(N),W(),I(N.scrollSnapList().length),N.on("select",W),()=>{N.off("select",W)}},[N,O]),p.useEffect(()=>{N&&(N.reInit(),I(N.scrollSnapList().length),ne(ae=>Mo(ae,0,p.Children.toArray(s).length-1)))},[p.Children.toArray(s).length,O]);const je=N?.canScrollPrev()||!1,ge=N?.canScrollNext()||!1,be=Array(K).fill(0).map((ae,Me)=>k.createElement(ln,{key:Me,"data-active":Me===fe||void 0,className:G.indicator,"aria-hidden":!0,tabIndex:-1,onClick:()=>U(Me)}));return k.createElement(af,{value:{slideGap:v,slideSize:j,embla:N,orientation:b,includeGapInSize:_,breakpoints:ee,classNames:x,styles:f,unstyled:u,variant:se}},k.createElement(We,Df({className:ve(G.root,a),ref:t,onKeyDownCapture:de},me),k.createElement("div",{className:G.viewport,ref:te},k.createElement("div",{className:G.container},s)),R&&k.createElement("div",{className:G.indicators},be),Q&&k.createElement("div",{className:G.controls},k.createElement(ln,{onClick:re,className:G.control,"aria-label":y,"data-inactive":!je||void 0,tabIndex:je?0:-1},typeof le<"u"?le:k.createElement(nr,{style:{transform:`rotate(${as({dir:ce.dir,orientation:b,direction:"previous"})}deg)`}})),k.createElement(ln,{onClick:pe,className:G.control,"aria-label":d,"data-inactive":!ge||void 0,tabIndex:ge?0:-1},typeof ue<"u"?ue:k.createElement(nr,{style:{transform:`rotate(${as({dir:ce.dir,orientation:b,direction:"next"})}deg)`}})))))});qn.Slide=ka;qn.displayName="@mantine/carousel/Carousel";const is=qn,If=({chargeProps:e,onChange:t})=>{const{additionalDocuments:r}=L(Ns,e),[s,a]=p.useState(void 0);return n.jsx("div",{className:"container mx-auto text-gray-600 body-font",children:r?.length>0?n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"flex flex-wrap",children:n.jsx(is,{sx:{maxWidth:320},mx:"auto",align:"center",withControls:r.length>1,slideGap:0,withIndicators:!0,className:"[&>*>.mantine-Carousel-indicator]:bg-gray-500",children:r.map(o=>n.jsx(is.Slide,{children:n.jsxs("div",{className:"flex flex-col items-center",children:[n.jsx("h2",{className:"text-gray-900 text-base font-medium",children:"documentType"in o?o.documentType:"Unprocessed"}),n.jsx("button",{className:"mx-10",onClick:()=>a(o.id),children:n.jsx("div",{className:"flex rounded-lg h-full bg-gray-100 p-2 m-2 flex-col",children:n.jsx(Ro,{src:o.image?.toString(),withPlaceholder:!0})})})]})},o.id))})}),n.jsx(zo,{documentId:s,onDone:()=>a(void 0),onChange:t})]}):n.jsx(Cn,{color:"red",children:"No Documents Related"})})},Ft=({foreignAmount:e,localAmount:t,diff:r})=>{const s=e!=null&&e.currency!==sn.Ils,a=r&&r.localAmount?.formatted!==t?.formatted,o=r&&r.foreignAmount?.formatted!==e?.formatted;return n.jsx("div",{className:"flex flex-col",children:(t||a)&&n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"flex gap-2 items-center",children:[s&&n.jsx("p",{className:o?"line-through":"",children:e.formatted}),o&&r.foreignAmount&&n.jsx("p",{className:"border-2 border-yellow-500 rounded-md",children:r.foreignAmount.formatted})]}),n.jsxs("div",{className:"flex gap-2 items-center",children:[t!=null&&n.jsx("p",{className:a?"line-through":"",children:t.formatted}),a&&r.localAmount&&n.jsx("p",{className:"border-2 border-yellow-500 rounded-md",children:r.localAmount.formatted})]})]})})},Mt=({account:e,diffAccount:t})=>{const r=t&&t?.id!==e?.id;return n.jsx("div",{className:"flex flex-col whitespace-normal",children:(e||r)&&n.jsxs(n.Fragment,{children:[e&&n.jsx(yt,{to:st.BUSINESSES.DETAIL(e.id),target:"_blank",rel:"noreferrer",onClick:s=>s.stopPropagation(),className:`inline-flex items-center font-semibold ${r?"line-through":""}`,children:e.name}),r&&t&&n.jsx("div",{className:"border-2 border-yellow-500 rounded-md",children:n.jsx(yt,{to:st.BUSINESSES.DETAIL(t.id),target:"_blank",rel:"noreferrer",onClick:s=>s.stopPropagation(),className:"inline-flex items-center font-semibold",children:t.name})})]})})},cs=({date:e,diff:t})=>{const r=e?He(new Date(e),"dd/MM/yy"):void 0,s=t?He(new Date(t),"dd/MM/yy"):void 0,a=s&&r!==s;return n.jsxs(n.Fragment,{children:[n.jsx("p",{className:a?"line-through":"",children:r??"Missing Data"}),a&&n.jsx("div",{className:"flex flex-col border-2 border-yellow-500 rounded-md",children:s})]})},Rt=(e,t)=>{const r=e.original[t],s=e.original.diff?.[t];return!r&&!s},ls=[{accessorKey:"invoiceDate",header:({column:e})=>n.jsxs(q,{variant:"ghost",onClick:()=>e.toggleSorting(e.getIsSorted()==="asc"),children:["Invoice Date",e.getIsSorted()&&(e.getIsSorted()==="asc"?n.jsx(we,{className:"ml-2 h-4 w-4"}):n.jsx(Ce,{className:"ml-2 h-4 w-4"}))]}),cell:({row:e})=>n.jsx(cs,{date:e.original.invoiceDate,diff:e.original.diff?.invoiceDate})},{accessorKey:"valueDate",header:({column:e})=>n.jsxs(q,{variant:"ghost",onClick:()=>e.toggleSorting(e.getIsSorted()==="asc"),children:["Value Date",e.getIsSorted()&&(e.getIsSorted()==="asc"?n.jsx(we,{className:"ml-2 h-4 w-4"}):n.jsx(Ce,{className:"ml-2 h-4 w-4"}))]}),cell:({row:e})=>n.jsx(cs,{date:e.original.valueDate,diff:e.original.diff?.valueDate})},{header:"Debit Account (Main)",columns:[{accessorKey:"debitAccount1.name",header:({column:e})=>n.jsxs(q,{variant:"ghost",onClick:()=>e.toggleSorting(e.getIsSorted()==="asc"),children:["Account",e.getIsSorted()&&(e.getIsSorted()==="asc"?n.jsx(we,{className:"ml-2 h-4 w-4"}):n.jsx(Ce,{className:"ml-2 h-4 w-4"}))]}),cell:({row:e})=>n.jsx(Mt,{account:e.original.debitAccount1,diffAccount:e.original.diff?.debitAccount1})},{accessorKey:"localCurrencyDebitAmount1.raw",header:({column:e})=>n.jsxs(q,{variant:"ghost",onClick:()=>e.toggleSorting(e.getIsSorted()==="asc"),children:["Amount",e.getIsSorted()&&(e.getIsSorted()==="asc"?n.jsx(we,{className:"ml-2 h-4 w-4"}):n.jsx(Ce,{className:"ml-2 h-4 w-4"}))]}),cell:({row:e})=>Rt(e,"debitAccount1")?null:n.jsx(Ft,{foreignAmount:e.original.debitAmount1,localAmount:e.original.localCurrencyDebitAmount1,diff:e.original.diff?{foreignAmount:e.original.diff.debitAmount1,localAmount:e.original.diff.localCurrencyDebitAmount1}:void 0})}]},{header:"Credit Account (Main)",columns:[{accessorKey:"creditAccount1.name",header:({column:e})=>n.jsxs(q,{variant:"ghost",onClick:()=>e.toggleSorting(e.getIsSorted()==="asc"),children:["Account",e.getIsSorted()&&(e.getIsSorted()==="asc"?n.jsx(we,{className:"ml-2 h-4 w-4"}):n.jsx(Ce,{className:"ml-2 h-4 w-4"}))]}),cell:({row:e})=>n.jsx(Mt,{account:e.original.creditAccount1,diffAccount:e.original.diff?.creditAccount1})},{accessorKey:"localCurrencyCreditAmount1.raw",header:({column:e})=>n.jsxs(q,{variant:"ghost",onClick:()=>e.toggleSorting(e.getIsSorted()==="asc"),children:["Amount",e.getIsSorted()&&(e.getIsSorted()==="asc"?n.jsx(we,{className:"ml-2 h-4 w-4"}):n.jsx(Ce,{className:"ml-2 h-4 w-4"}))]}),cell:({row:e})=>Rt(e,"creditAccount1")?null:n.jsx(Ft,{foreignAmount:e.original.creditAmount1,localAmount:e.original.localCurrencyCreditAmount1,diff:e.original.diff?{foreignAmount:e.original.diff.creditAmount1,localAmount:e.original.diff.localCurrencyCreditAmount1}:void 0})}]},{header:"Debit Account (Secondary)",columns:[{accessorKey:"debitAccount2.name",header:({column:e})=>n.jsxs(q,{variant:"ghost",onClick:()=>e.toggleSorting(e.getIsSorted()==="asc"),children:["Account",e.getIsSorted()&&(e.getIsSorted()==="asc"?n.jsx(we,{className:"ml-2 h-4 w-4"}):n.jsx(Ce,{className:"ml-2 h-4 w-4"}))]}),cell:({row:e})=>n.jsx(Mt,{account:e.original.debitAccount2,diffAccount:e.original.diff?.debitAccount2})},{accessorKey:"localCurrencyDebitAmount2.raw",header:({column:e})=>n.jsxs(q,{variant:"ghost",onClick:()=>e.toggleSorting(e.getIsSorted()==="asc"),children:["Amount",e.getIsSorted()&&(e.getIsSorted()==="asc"?n.jsx(we,{className:"ml-2 h-4 w-4"}):n.jsx(Ce,{className:"ml-2 h-4 w-4"}))]}),cell:({row:e})=>Rt(e,"debitAccount2")?null:n.jsx(Ft,{foreignAmount:e.original.debitAmount2,localAmount:e.original.localCurrencyDebitAmount2,diff:e.original.diff?{foreignAmount:e.original.diff.debitAmount2,localAmount:e.original.diff.localCurrencyDebitAmount2}:void 0})}]},{header:"Credit Account (Secondary)",columns:[{accessorKey:"creditAccount2.name",header:({column:e})=>n.jsxs(q,{variant:"ghost",onClick:()=>e.toggleSorting(e.getIsSorted()==="asc"),children:["Account",e.getIsSorted()&&(e.getIsSorted()==="asc"?n.jsx(we,{className:"ml-2 h-4 w-4"}):n.jsx(Ce,{className:"ml-2 h-4 w-4"}))]}),cell:({row:e})=>n.jsx(Mt,{account:e.original.creditAccount2,diffAccount:e.original.diff?.creditAccount2})},{accessorKey:"localCurrencyCreditAmount2.raw",header:({column:e})=>n.jsxs(q,{variant:"ghost",onClick:()=>e.toggleSorting(e.getIsSorted()==="asc"),children:["Amount",e.getIsSorted()&&(e.getIsSorted()==="asc"?n.jsx(we,{className:"ml-2 h-4 w-4"}):n.jsx(Ce,{className:"ml-2 h-4 w-4"}))]}),cell:({row:e})=>Rt(e,"creditAccount2")?null:n.jsx(Ft,{foreignAmount:e.original.creditAmount2,localAmount:e.original.localCurrencyCreditAmount2,diff:e.original.diff?{foreignAmount:e.original.diff.creditAmount2,localAmount:e.original.diff.localCurrencyCreditAmount2}:void 0})}]},{accessorKey:"description",header:({column:e})=>n.jsxs(q,{variant:"ghost",onClick:()=>e.toggleSorting(e.getIsSorted()==="asc"),children:["Details",e.getIsSorted()&&(e.getIsSorted()==="asc"?n.jsx(we,{className:"ml-2 h-4 w-4"}):n.jsx(Ce,{className:"ml-2 h-4 w-4"}))]}),cell:({row:{original:e}})=>{const t=e.diff&&e.diff.description!==e.description;return n.jsxs("div",{className:"flex flex-col whitespace-normal",children:[n.jsx("p",{className:t?"line-through":"",children:e.description}),t&&n.jsx("div",{className:"border-2 border-yellow-500 rounded-md",children:e.diff?.description})]})}},{accessorKey:"reference",header:({column:e})=>n.jsxs(q,{variant:"ghost",onClick:()=>e.toggleSorting(e.getIsSorted()==="asc"),children:["Reference",e.getIsSorted()&&(e.getIsSorted()==="asc"?n.jsx(we,{className:"ml-2 h-4 w-4"}):n.jsx(Ce,{className:"ml-2 h-4 w-4"}))]}),cell:({row:{original:e}})=>{const t=e.diff&&e.diff.reference!==e.reference;return n.jsxs("div",{className:"flex flex-col whitespace-normal",children:[n.jsx("p",{className:t?"line-through":"",children:e.reference}),t&&n.jsx("div",{className:"border-2 border-yellow-500 rounded-md",children:e.diff?.reference})]})}},{accessorKey:"matchingStatus",header:({column:e})=>n.jsxs(q,{variant:"ghost",onClick:()=>e.toggleSorting(e.getIsSorted()==="asc"),children:["Status",e.getIsSorted()&&(e.getIsSorted()==="asc"?n.jsx(we,{className:"ml-2 h-4 w-4"}):n.jsx(Ce,{className:"ml-2 h-4 w-4"}))]}),cell:({row:{original:{matchingStatus:e}}})=>{if(e){const t=e==="Deleted"?"bg-red-500":e==="Diff"?"bg-yellow-500":"bg-green-500";return n.jsx(Ts,{variant:"default",className:t,children:e})}return null}}];function _f(e){let t="";switch(e){case"New":t="bg-green-100/30";break;case"Deleted":t="bg-red-100/30";break;case"Diff":t="bg-yellow-100/30";break}return t}const Ef=({ledgerRecordsData:e,ledgerDiffData:t,matches:r})=>{const[s,a]=p.useState([]),o=p.useMemo(()=>{const c=e.map(g=>L(rr,g)),l=t?.map(g=>L(rr,g)),d=c.map(g=>{const m=l?.find(x=>x.id===g.id);return{...g,matchingStatus:!r||r?.includes(g.id)?void 0:m?"Diff":"Deleted",diff:m}}),y=l?.filter(g=>g.id===Lo).map(g=>({...g,matchingStatus:"New"}))??[];return d.push(...y),d},[e,t,r]),i=Tn({data:o,columns:ls,getCoreRowModel:$n(),onSortingChange:a,getSortedRowModel:kn(),getPaginationRowModel:Bo(),state:{sorting:s},initialState:{pagination:{pageIndex:0,pageSize:100},sorting:[{id:"invoiceDate",desc:!0}]}});return n.jsxs(n.Fragment,{children:[n.jsxs(tn,{children:[n.jsx(nn,{children:i.getHeaderGroups().map(c=>n.jsx(Ne,{children:c.headers.map(l=>n.jsx(Ae,{className:"text-center",colSpan:l.colSpan,children:l.isPlaceholder?null:rt(l.column.columnDef.header,l.getContext())},l.id))},c.id))}),n.jsx(rn,{children:i.getRowModel().rows?.length?i.getRowModel().rows.map(c=>n.jsx(Ne,{"data-state":c.getIsSelected()&&"selected",className:_f(c.original.matchingStatus),children:c.getVisibleCells().map(l=>n.jsx(xe,{children:rt(l.column.columnDef.cell,l.getContext())},l.id))},c.id)):n.jsx(Ne,{children:n.jsx(xe,{colSpan:ls.length,className:"h-24 text-center",children:"No results."})})})]}),n.jsx("div",{className:"flex items-center justify-end space-x-2 py-4",children:n.jsx(Vo,{currentPageIndex:i.getState().pagination.pageIndex,totalPages:i.getPageCount(),onChange:c=>i.setPageIndex(c)})})]})},Of=({data:e})=>{const t=L($s,e);return t?.errorsLedger?.validate?.errors?.length?n.jsxs(ks,{shadow:"xs",p:"md",children:[n.jsx(Be,{c:"red",children:"Errors:"}),n.jsx(dr,{size:"sm",withPadding:!0,children:t.errorsLedger.validate.errors.map((r,s)=>n.jsx(dr.Item,{children:n.jsx(Be,{c:"red",children:r})},s))})]}):null},Af=({transactionsProps:e,onChange:t})=>{const{transactions:r}=L(Fs,e);return n.jsx(Hs,{transactionsProps:r,onChange:t,enableEdit:!0})},Pf="createDeposit",Nf=()=>{const[{fetching:e},t]=Ee(Uo),r=p.useCallback(async s=>{const a=`Error creating new deposit in currency ${s.currency}`,o=`${Pf}-${s.currency}`;F.loading("Creating deposit",{id:o});try{const i=await t(s),c=Oe(i,a,o);if(c)return F.success("Deposit created",{id:o,description:`Deposit ${c.createDeposit.id} (${c.createDeposit.currency}) created successfully`}),c.createDeposit.id}catch(i){console.error(`${a}: ${i}`),F.error("Error",{id:o,description:a,duration:1e5,closeButton:!0})}return null},[t]);return{creating:e,createDeposit:r}},Tf=({chargeId:e,onChange:t})=>{const[{data:r,fetching:s}]=ke({query:Ko,variables:{chargeId:e}}),[{data:a,fetching:o}]=ke({query:Ho}),{creating:i,createDeposit:c}=Nf(),{assigning:l,assignChargeToDeposit:d}=Si(),[y,g]=p.useState(void 0),[m,x]=p.useState(!1),[f,u]=p.useState("ILS"),j=p.useMemo(()=>(a?.allDeposits??[]).filter(S=>S.isOpen),[a?.allDeposits]),v=p.useCallback(async()=>{const S=await c({currency:f});S&&(await d({chargeId:e,depositId:S}),x(!1),t?.())},[c,d,f,e,t]),b=p.useCallback(async()=>{y&&(await d({chargeId:e,depositId:y}),t?.())},[d,y,e,t]);return s||o||i||l?n.jsx(Mn,{className:"h-10 w-10 animate-spin"}):r?.depositByCharge?n.jsxs("div",{children:[n.jsxs("div",{className:"text-lg font-semibold mb-4",children:['Bank Deposit "',r?.depositByCharge?.id,'" Balance:'," ",r?.depositByCharge?.currentBalance.formatted]}),n.jsx("div",{className:"mb-4",children:n.jsx("span",{className:"text-sm text-gray-500",children:r?.depositByCharge?.isOpen?"Deposit is open":"Deposit is closed"})}),n.jsx(wi,{depositId:r.depositByCharge.id})]}):n.jsxs("div",{className:"space-y-4",children:[n.jsx("div",{className:"text-sm text-gray-500",children:"No bank deposit found for this charge."}),n.jsxs("div",{className:"flex items-center gap-4 flex-wrap",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsxs(sr,{value:y,onValueChange:S=>g(S),children:[n.jsx(ar,{className:"min-w-[220px]",children:n.jsx(or,{placeholder:j.length?"Select open deposit":"No open deposits"})}),n.jsx(ir,{children:j.map(S=>n.jsxs(cr,{value:S.id,children:[S.id," (",S.currency,")"]},S.id))})]}),n.jsx(q,{variant:"secondary",disabled:!y||l,onClick:b,children:l?"Assigning…":"Assign"})]}),n.jsx(q,{variant:"outline",onClick:()=>x(!0),children:"Create New Deposit"})]}),n.jsx(St,{open:m,onOpenChange:x,children:n.jsxs(wt,{children:[n.jsx(Pn,{children:n.jsx(Nn,{children:"Create Bank Deposit"})}),n.jsx("div",{className:"space-y-4",children:n.jsxs("div",{className:"flex flex-col gap-2",children:[n.jsx(Go,{htmlFor:"deposit-currency-select",children:"Currency"}),n.jsxs(sr,{value:f,onValueChange:S=>u(S),children:[n.jsx(ar,{className:"w-40",children:n.jsx(or,{id:"deposit-currency-select"})}),n.jsx(ir,{children:Object.entries(sn).map(([S,O])=>n.jsx(cr,{value:O,children:O},S))})]})]})}),n.jsx(qo,{children:n.jsx(q,{variant:"secondary",disabled:i,onClick:v,children:i?"Creating…":"Create"})})]})})]})};function kf({row:e}){const[t,r]=p.useState(["transactions","documents"]),[{data:s,fetching:a}]=ke({query:Wo,variables:{chargeId:e.original.id??""},pause:!e.original.id}),o=s?.charge.transactions,i=!!o&&o.length>0,c=s?.charge.additionalDocuments,l=!!c&&c.length>0;return n.jsxs(Ei,{type:"multiple",value:t,onValueChange:r,className:"space-y-4",children:[i&&n.jsxs(fr,{value:"transactions",className:"rounded-lg border-2",children:[n.jsx("div",{className:"px-2 bg-gray-600/10 rounded-t-lg",children:n.jsx(pr,{className:"hover:no-underline p-2",disabled:!i,children:n.jsx("h3",{className:"font-semibold text-lg",children:"Transactions"})})}),a?n.jsx(Ot,{children:n.jsx("div",{className:"p-2",children:n.jsx(Wr,{})})}):n.jsx(Ot,{children:o&&n.jsx("div",{className:"p-2",children:n.jsx(Hs,{transactionsProps:o})})})]}),l&&n.jsxs(fr,{value:"documents",className:"rounded-lg border-2",children:[n.jsx("div",{className:"px-2 bg-gray-600/10 rounded-t-lg",children:n.jsx(pr,{className:"hover:no-underline p-2",disabled:!l,children:n.jsx("h3",{className:"font-semibold text-lg",children:"Documents"})})}),a?n.jsx(Ot,{children:n.jsx("div",{className:"p-2",children:n.jsx(Wr,{})})}):n.jsx(Ot,{children:c&&n.jsx("div",{className:"p-2",children:n.jsx(Ms,{documentsProps:c})})})]})]})}const $f=({row:e})=>{const[t,r]=p.useState(!1);return n.jsxs(n.Fragment,{children:[n.jsxs(Ne,{children:[e.getVisibleCells().map(s=>n.jsx(xe,{children:rt(s.column.columnDef.cell,s.getContext())},s.id)),n.jsx(xe,{children:n.jsx(Ks,{toggleExpansion:r,isExpanded:t})})]},e.id),t&&n.jsx(Ne,{children:n.jsx(xe,{colSpan:e.getVisibleCells().length+1,children:n.jsx(kf,{row:e})})},`${e.id}-extensions`)]})},Ff=({business:e})=>e.id?n.jsx(yt,{to:st.BUSINESSES.DETAIL(e.id),target:"_blank",rel:"noreferrer",onClick:t=>t.stopPropagation(),className:"inline-flex items-center font-semibold",children:e.name}):n.jsx("div",{}),Mf=({date:e})=>n.jsx("p",{className:"text-sm font-medium",children:e?.toLocaleDateString(void 0,{timeZone:"UTC"})}),Rf=({tags:e})=>n.jsx(an,{items:e.map(t=>n.jsx(zt,{children:n.jsxs("div",{children:[t.namePath&&n.jsx(Be,{size:"xs",opacity:.65,children:`${t.namePath.join(" > ")} >`}),n.jsx(Be,{size:"sm",children:t.name})]})},t.id))}),zf=({taxCategory:e})=>n.jsx("p",{className:"text-sm font-medium",children:e?.name}),Lf=({type:e})=>{const{text:t,icon:r}=p.useMemo(()=>({text:Rn(e),icon:Ws(e)}),[e]);return n.jsxs(n.Fragment,{children:[n.jsx("div",{children:t}),n.jsx(zn,{radius:"xl",size:"xl",children:r})]})},ds=[{id:"select",cell:({row:e})=>n.jsx(jn,{checked:e.original.isSelected,onCheckedChange:t=>(e.original.selectCharge(t?e.original.id:null),t),"aria-label":"Select charge"}),enableSorting:!1,enableHiding:!1},{accessorKey:"confidenceScore",header:({column:e})=>n.jsx(ze,{column:e,title:"Score"}),cell:({row:e})=>{const t=e.getValue("confidenceScore");return n.jsx(Zd,{value:t*100,size:"sm"})}},{accessorKey:"type",header:({column:e})=>n.jsx(ze,{column:e,title:"Type"}),cell:({row:e})=>n.jsx(Lf,{type:e.getValue("type")})},{accessorKey:"date",header:({column:e})=>n.jsx(ze,{column:e,title:"Date"}),cell:({row:e})=>n.jsx(Mf,{date:e.getValue("date")})},{accessorKey:"amountRaw",header:({column:e})=>n.jsx(ze,{column:e,title:"Amount"}),cell:({row:e})=>{const t=e.original.amountFormatted;return n.jsx("p",{className:"text-sm font-medium",children:t})}},{accessorKey:"vatAmountRaw",header:({column:e})=>n.jsx(ze,{column:e,title:"VAT"}),cell:({row:e})=>{const t=e.original.vatAmountFormatted;return n.jsx("p",{className:"text-sm font-medium",children:t})}},{accessorKey:"businessName",header:({column:e})=>n.jsx(ze,{column:e,title:"Main Business"}),cell:({row:e})=>n.jsx(Ff,{business:{id:e.original.businessId,name:e.original.businessName}})},{accessorKey:"description",header:({column:e})=>n.jsx(ze,{column:e,title:"Description"}),cell:({row:e})=>{const t=e.getValue("description");return n.jsx("p",{className:"text-sm font-medium max-w-100 whitespace-normal",children:t})}},{accessorKey:"tags",header:({column:e})=>n.jsx(ze,{column:e,title:"Tags"}),cell:({row:e})=>n.jsx(Rf,{tags:e.getValue("tags")}),enableSorting:!1},{accessorKey:"taxCategoryName",header:({column:e})=>n.jsx(ze,{column:e,title:"Tax Category"}),cell:({row:e})=>n.jsx(zf,{taxCategory:{id:e.original.taxCategoryId,name:e.original.taxCategoryName}})}];function Bf(e,t,r){const s=L(ei,e),a=s.charge.minDocumentsDate||s.charge.minEventDate||s.charge.minDebitDate||void 0;return{id:s.charge.id,confidenceScore:s.confidenceScore,type:s.charge.__typename,date:a?new Date(a):void 0,amountRaw:s.charge.totalAmount?.raw,amountFormatted:s.charge.totalAmount?.formatted,vatAmountRaw:s.charge.vat?.raw,vatAmountFormatted:s.charge.vat?.formatted,businessId:s.charge.counterparty?.id,businessName:s.charge.counterparty?.name,description:s.charge.userDescription??void 0,tags:s.charge.tags.map(o=>({id:o.id,name:o.name,namePath:o.namePath??void 0})),taxCategoryId:s.charge.taxCategory?.id,taxCategoryName:s.charge.taxCategory?.name,selectCharge:t,isSelected:s.charge.id===r}}const Vf=({originChargeId:e,chargesProps:t,onChange:r})=>{const[s,a]=p.useState([{id:"confidenceScore",desc:!0},{id:"amountRaw",desc:!0}]),[o,i]=p.useState([]),[c,l]=p.useState(null),[d,y]=p.useState([{id:e,onChange:r}]);p.useEffect(()=>{y([e,...c?[c]:[]].map(x=>({id:x,onChange:r})))},[c,r,e]);const g=p.useMemo(()=>t?.map(x=>Bf(x,l,c)).sort((x,f)=>f.confidenceScore-x.confidenceScore)??[],[t,c]),m=Tn({data:g,columns:ds,getCoreRowModel:$n(),onSortingChange:a,getSortedRowModel:kn(),onColumnFiltersChange:i,getFilteredRowModel:Yo(),state:{sorting:s,columnFilters:o}});return n.jsxs("div",{className:"max-w-[90vw]",children:[n.jsxs("div",{className:"flex items-center py-4 gap-4",children:[n.jsx(Hd,{selected:d,resetMerge:()=>l(null)}),n.jsxs(Qo,{children:[n.jsx(Jo,{asChild:!0,className:"ml-auto",children:n.jsxs(q,{variant:"outline",children:["Columns ",n.jsx(Ce,{})]})}),n.jsx(Xo,{align:"end",children:m.getAllColumns().filter(x=>x.getCanHide()).map(x=>n.jsx(Zo,{className:"capitalize",checked:x.getIsVisible(),onCheckedChange:f=>x.toggleVisibility(!!f),children:x.id},x.id))})]})]}),n.jsx("div",{className:"overflow-hidden rounded-md border",children:n.jsxs(tn,{children:[n.jsx(nn,{children:m.getHeaderGroups().map(x=>n.jsxs(Ne,{children:[x.headers.map(f=>n.jsx(Ae,{colSpan:f.colSpan,children:f.isPlaceholder?null:rt(f.column.columnDef.header,f.getContext())},f.id)),n.jsx(Ae,{})]},x.id))}),n.jsx(rn,{children:m.getRowModel().rows?.length?m.getRowModel().rows.map(x=>n.jsx($f,{row:x},x.id)):n.jsx(Ne,{children:n.jsx(xe,{colSpan:ds.length,className:"h-24 text-center",children:"No results."})})})]})})]})},Uf=({chargeId:e,toggleAccordionItem:t,isOpened:r,onChange:s})=>{const[{data:a,fetching:o}]=ke({query:ti,variables:{chargeId:e},pause:!r});return n.jsxs(z.Item,{value:"charges-matches",children:[n.jsx(z.Control,{onClick:()=>t("charges-matches"),children:"Charge Matches"}),n.jsx(z.Panel,{children:o?n.jsx(Mn,{className:"h-10 w-10 animate-spin"}):n.jsx(Vf,{originChargeId:e,chargesProps:a?.findChargeMatches.matches,onChange:s})})]})},Kf=({chargeProps:e})=>{const t=L(Rs,e);if(t.__typename!=="ConversionCharge")return n.jsx(n.Fragment,{});const{eventRate:r,officialRate:s}=t;return n.jsxs(dn,{justify:"center",children:[s&&n.jsx(dn.Col,{span:"content",children:n.jsx(ur,{shadow:"sm",padding:"xs",radius:"md",withBorder:!0,children:n.jsxs(zt,{position:"apart",children:[n.jsx(Be,{weight:500,children:"Official Conversion Rate"}),n.jsx(Cn,{color:"green",variant:"light",children:`${Number(s.rate)} ${nt(s.from)} => ${nt(s.to)}`})]})})}),r&&n.jsx(dn.Col,{span:"content",children:n.jsx(ur,{shadow:"sm",padding:"xs",radius:"md",withBorder:!0,children:n.jsxs(zt,{position:"apart",children:[n.jsx(Be,{weight:500,children:"Bank Conversion Rate"}),n.jsx(Cn,{color:"green",variant:"light",children:`${Number(r.rate)} ${nt(r.from)} => ${nt(r.to)}`})]})})})]})},Hf=({chargeProps:e})=>{const t=L(zs,e),r=p.useMemo(()=>t.__typename==="CreditcardBankCharge"&&t.creditCardTransactions?t.creditCardTransactions.map(s=>L(ni,s)):[],[t]);return r.length?n.jsxs(tn,{children:[n.jsx(nn,{children:n.jsxs(Ne,{children:[n.jsx(Ae,{children:"Event Date"}),n.jsx(Ae,{children:"Debit Date"}),n.jsx(Ae,{children:"Amount"}),n.jsx(Ae,{children:"Account"}),n.jsx(Ae,{children:"Description"}),n.jsx(Ae,{children:"Reference#"}),n.jsx(Ae,{children:"Counterparty"}),n.jsx(Ae,{children:"Charge"})]})}),n.jsx(rn,{children:r.map(s=>{const a={...s,onUpdate:()=>{},editTransaction:()=>{},enableEdit:!1,enableChargeLink:!1};return n.jsxs(Ne,{children:[n.jsx(xe,{children:n.jsx(fi,{transaction:a})}),n.jsx(xe,{children:n.jsx(pi,{transaction:a})}),n.jsx(xe,{children:n.jsx(gi,{transaction:a})}),n.jsx(xe,{children:n.jsx(mi,{transaction:a})}),n.jsx(xe,{children:n.jsx(hi,{transaction:a})}),n.jsx(xe,{children:n.jsx(xi,{transaction:a})}),n.jsx(xe,{children:n.jsx(yi,{transaction:a})}),n.jsx(xe,{children:n.jsx(vi,{chargeId:s.chargeId})})]},s.id)})})]}):null},Gf=({chargeProps:e})=>{const t=L(Ls,e),r=p.useMemo(()=>t.__typename!=="FinancialCharge"?[]:Object.entries(t.exchangeRates??{}).sort((s,a)=>s[0].localeCompare(a[0])),[t]);return t.__typename!=="FinancialCharge"?n.jsx(n.Fragment,{}):n.jsx("div",{className:"flex flex-row flex-wrap gap-2 px-2",children:r.map(([s,a])=>n.jsx(vs,{className:"gap-0 py-2",children:n.jsxs(ri,{className:"flex flex-col px-2",children:[n.jsx(si,{className:"text-xl font-semibold",children:s.toLocaleUpperCase()}),n.jsxs("div",{className:"flex items-center space-x-2",children:[n.jsxs("span",{className:"whitespace-nowrap",children:[nt(s.toLocaleUpperCase()),"1="]}),n.jsxs(Ts,{variant:"default",className:"flex gap-1 rounded-lg text-md",children:[nt(sn.Ils),a]})]})]})},s))})},qf="deleteMiscExpense",Wf=()=>{const[{fetching:e},t]=Ee(ai),r=p.useCallback(async s=>{const a="Error deleting misc expense",o=`${qf}-${s.id}`;F.loading("Deleting misc expense",{id:o});try{const i=await t(s),c=Oe(i,a,o);if(c)return F.success("Success",{id:o,description:"Misc expense was deleted successfully"}),c.deleteMiscExpense}catch(i){console.error(`${a}: ${i}`),F.error("Error",{id:o,description:a,duration:1e5,closeButton:!0})}},[t]);return{fetching:e,deleteMiscExpense:r}};function Yf({miscExpenseId:e,onChange:t}){const{deleteMiscExpense:r}=Wf();async function s(){try{await r({id:e}),t?.()}catch(a){const o="Failed to delete misc expense";console.error(`${o}: ${a}`),F.error("Error",{description:o})}}return n.jsx(en,{onConfirm:s,title:"Are you sure you want to delete this expense?",children:n.jsx(q,{className:"size-7.5 text-red-500",variant:"ghost",children:n.jsx(Fn,{className:"size-5"})})})}const Qf=({miscExpensesData:e,onChange:t})=>{const r=L(Bs,e),{miscExpenses:s}=r;return n.jsxs("table",{className:"w-full h-full",children:[n.jsx("thead",{children:n.jsxs("tr",{children:[n.jsx("th",{children:"Creditor"}),n.jsx("th",{children:"Debtor"}),n.jsx("th",{children:"Amount"}),n.jsx("th",{children:"Invoice Date"}),n.jsx("th",{children:"Value Date"}),n.jsx("th",{children:"Description"}),n.jsx("th",{children:"Actions"})]})}),n.jsx("tbody",{children:s?.map(a=>n.jsxs("tr",{children:[n.jsx("td",{children:n.jsx("div",{children:a.creditor?.name})}),n.jsx("td",{children:n.jsx("div",{children:a.debtor?.name})}),n.jsx("td",{children:n.jsx("div",{children:a.amount?.formatted})}),n.jsx("td",{children:n.jsx("div",{children:a.invoiceDate})}),n.jsx("td",{children:n.jsx("div",{children:a.valueDate&&He(new Date(a.valueDate),"yyyy-MM-dd")})}),n.jsx("td",{children:n.jsx("div",{children:a.description})}),n.jsxs("td",{children:[n.jsx(Gd,{onDone:t,data:a}),n.jsx(Yf,{miscExpenseId:a.id,onChange:t})]})]},a?.id))})]})},Jf=({salaryRecordsProps:e})=>{const t=L(Vs,e);if(t.__typename!=="SalaryCharge")return n.jsx(n.Fragment,{});const{salaryRecords:r}=t;return n.jsxs("table",{className:"w-full h-full",children:[n.jsx("thead",{children:n.jsxs("tr",{children:[n.jsx("th",{children:"Employee"}),n.jsx("th",{children:"Direct Salary"}),n.jsx("th",{children:"Base Salary"}),n.jsx("th",{children:"Pension"}),n.jsx("th",{children:"Training Fund"}),n.jsx("th",{children:"Social Security"}),n.jsx("th",{children:"Tax"})]})}),n.jsx("tbody",{children:r?.map(s=>n.jsxs("tr",{children:[n.jsx("td",{children:n.jsx("div",{children:s.employee?.name??"Missing"})}),n.jsx("td",{children:n.jsx("div",{children:s.directAmount.formatted})}),n.jsx("td",{children:n.jsx("div",{children:s.baseAmount?.formatted})}),n.jsxs("td",{children:[n.jsx("div",{children:s.pensionFund?.name}),n.jsxs("div",{children:["Employee: ",s.pensionEmployeeAmount?.formatted]}),n.jsxs("div",{children:["Employer: ",s.pensionEmployerAmount?.formatted]}),n.jsxs("div",{children:["Compensation: ",s.compensationsAmount?.formatted]})]}),n.jsxs("td",{children:[n.jsx("div",{children:s.trainingFund?.name}),n.jsxs("div",{children:["Employee: ",s.trainingFundEmployeeAmount?.formatted]}),n.jsxs("div",{children:["Employer: ",s.trainingFundEmployerAmount?.formatted]})]}),n.jsxs("td",{children:[n.jsxs("div",{children:["Employee: ",s.socialSecurityEmployeeAmount?.formatted]}),n.jsxs("div",{children:["Employer: ",s.socialSecurityEmployerAmount?.formatted]}),n.jsxs("div",{children:["Health: ",s.healthInsuranceAmount?.formatted]})]}),n.jsx("td",{children:n.jsx("div",{children:s.incomeTaxAmount?.formatted})})]},`${s.employee?.name}-${s.baseAmount}`))})]})};function Xf({chargeID:e,onChange:t=()=>{},fetching:r}){const[s,a]=p.useState([]),[o,i]=p.useState(e),[c,{toggle:l}]=xt(!1),[d,y]=p.useState(void 0),[{data:g,fetching:m},x]=ke({query:Pe,variables:{chargeId:o}}),f=p.useCallback(()=>{x(),t()},[x,t]);p.useEffect(()=>{g?.charge&&y(g.charge)},[g]),p.useEffect(()=>{r&&x()},[r,x]),p.useEffect(()=>{e!==o&&(i(e),x())},[e,o,x]);const u=d?.__typename,j=!!d?.metadata?.ledgerCount,v=!!d?.metadata?.transactionsCount,b=!!d?.metadata?.documentsCount,C=!!d?.metadata?.receiptsCount,S=!!d?.metadata?.invoicesCount,O=u==="SalaryCharge",_=!!d?.miscExpenses?.length,D=d?.metadata?.openDocuments,E=(d?.totalAmount?.raw??0)>0&&!C,M=!(S||C)||!v;p.useEffect(()=>{const B=[];v&&B.push("transactions"),b&&B.push("documents"),j&&B.push("ledger"),O&&B.push("salaries"),_&&B.push("miscExpenses"),a(B)},[v,b,j,O,_,u]);function h(B){s.includes(B)?a(se=>se.filter(me=>me!==B)):a(se=>[...se,B])}const T=De(Pe,Ns,d),Q=De(Pe,lr,d),R=De(Pe,Us,d),V=De(Pe,Fs,d),ue=De(Pe,Bs,d),le=p.useMemo(()=>u==="ConversionCharge"&&De(Pe,Rs,d),[d,u]),ee=p.useMemo(()=>u==="FinancialCharge"&&De(Pe,Ls,d),[d,u]),H=u==="SalaryCharge"&&De(Pe,Vs,d),ye=p.useMemo(()=>u==="CreditcardBankCharge"&&De(Pe,zs,d),[d,u]);return n.jsxs("div",{className:"flex flex-col gap-5",children:[m&&n.jsx(Dt,{className:"flex self-center my-5",color:"dark",size:"xl",variant:"dots"}),De(Pe,$s,d)&&n.jsx(Of,{data:d}),d&&n.jsxs("div",{className:"flex flex-row",children:[n.jsxs(z,{className:"w-full",multiple:!0,value:s,chevron:n.jsx(ws,{size:"1rem"}),styles:{chevron:{"&[data-rotate]":{transform:"rotate(45deg)"}}},children:[u==="ConversionCharge"&&n.jsxs(z.Item,{value:"conversion",children:[n.jsx(z.Control,{disabled:!v,onClick:()=>h("conversion"),children:"Conversion Info"}),n.jsx(z.Panel,{children:le&&n.jsx(Kf,{chargeProps:d})})]}),u==="FinancialCharge"&&n.jsxs(z.Item,{value:"exchangeRates",children:[n.jsx(z.Control,{disabled:!ee,onClick:()=>h("exchangeRates"),children:"Exchange Rates"}),n.jsx(z.Panel,{children:ee&&n.jsx(Gf,{chargeProps:d})})]}),v&&n.jsxs(z.Item,{value:"transactions",children:[n.jsx(z.Control,{disabled:!v,onClick:()=>h("transactions"),children:n.jsxs("div",{className:"flex flex-row items-center gap-2 justify-between w-full",children:["Transactions",E&&n.jsx(bn,{chargeId:d.id})]})}),n.jsx(z.Panel,{children:V&&n.jsx(Af,{transactionsProps:d,onChange:f})})]}),_&&n.jsxs(z.Item,{value:"miscExpenses",children:[n.jsx(z.Control,{disabled:!_,onClick:()=>h("miscExpenses"),children:"Misc Expenses"}),n.jsx(z.Panel,{children:ue&&n.jsx(Qf,{miscExpensesData:d,onChange:f})})]}),b&&n.jsxs(z.Item,{value:"documents",children:[n.jsx(z.Control,{disabled:!b,onClick:()=>h("documents"),children:n.jsxs("div",{className:"flex flex-row items-center gap-2 justify-between w-full",children:[n.jsxs("div",{className:"flex flex-row items-center gap-2 justify-start",children:[b&&n.jsx(Ke,{content:"Documents Gallery",children:n.jsx(q,{onClick:B=>{B.stopPropagation(),l()},variant:"outline",disabled:!T,size:"icon",className:"size-7.5 text-gray-500",children:n.jsx(oi,{className:"size-5"})})}),"Documents"]}),D&&n.jsx(bn,{chargeId:d.id})]})}),n.jsx(z.Panel,{children:Q&&n.jsx(Ms,{documentsProps:L(lr,d)?.additionalDocuments,onChange:f})})]}),u==="SalaryCharge"&&n.jsxs(z.Item,{value:"salaries",children:[n.jsx(z.Control,{disabled:!O,onClick:()=>h("salaries"),children:"Salaries"}),n.jsx(z.Panel,{children:H&&n.jsx(Jf,{salaryRecordsProps:d})})]}),d.__typename==="BusinessTripCharge"&&n.jsxs(z.Item,{value:"businessTrip",children:[n.jsx(z.Control,{onClick:()=>h("businessTrip"),children:"Business Trip"}),n.jsx(z.Panel,{children:n.jsx(Xc,{data:d.businessTrip})})]}),u==="CreditcardBankCharge"&&n.jsxs(z.Item,{value:"creditcard",children:[n.jsx(z.Control,{onClick:()=>h("creditcard"),children:"CreditCard Transactions"}),n.jsx(z.Panel,{children:ye&&n.jsx(Hf,{chargeProps:d})})]}),j&&n.jsxs(z.Item,{value:"ledger",children:[n.jsx(z.Control,{disabled:!j,onClick:B=>{B.stopPropagation(),h("ledger")},children:n.jsxs("div",{className:"flex flex-row items-center gap-2 justify-start w-full",children:[!d.metadata?.isLedgerLocked&&n.jsx(rl,{chargeId:d.id,onChange:f,variant:"outline"}),"Ledger Records"]})}),n.jsx(z.Panel,{children:R&&n.jsx(Zf,{data:d})})]}),u==="BankDepositCharge"&&n.jsxs(z.Item,{value:"bankDeposit",children:[n.jsx(z.Control,{onClick:()=>h("bankDeposit"),children:"Bank Deposit"}),n.jsx(z.Panel,{children:n.jsx(Tf,{chargeId:d.id})})]}),M&&n.jsx(Uf,{chargeId:d.id,onChange:f,toggleAccordionItem:h,isOpened:s.includes("charges-matches")})]}),T&&n.jsx(We,{maw:"1/6",children:n.jsx(Di,{in:c,transitionDuration:500,transitionTimingFunction:"linear",children:n.jsx(If,{chargeProps:d,onChange:f})})})]}),!m&&!d&&n.jsx("p",{children:"Error fetching extended information for this charge"})]})}const Zf=({data:e})=>{const{ledger:t}=L(Us,e);return n.jsx(Ef,{ledgerRecordsData:t.records,ledgerDiffData:t.validate?.differences,matches:t.validate?.matches})},ep=({setEditCharge:e,setInsertDocument:t,setMatchDocuments:r,toggleMergeCharge:s,isSelectedForMerge:a,data:o,isAllOpened:i})=>{const[c,l]=p.useState(!1),[d,y]=p.useState(L(Je,o)),[{data:g,fetching:m},x]=ke({query:ii,pause:!0,variables:{chargeId:o.id}}),f=x;p.useEffect(()=>{const v=g?.charge;v&&y(L(Je,v))},[g]),p.useEffect(()=>{y(L(Je,o))},[o]),p.useEffect(()=>{l(i)},[i]);const u=p.useMemo(()=>!!(d.metadata?.documentsCount||d.metadata?.transactionsCount||d.metadata?.ledgerCount||d.metadata?.miscExpensesCount),[d.metadata?.documentsCount,d.metadata?.transactionsCount,d.metadata?.ledgerCount,d.metadata?.miscExpensesCount]),j=(d?.totalAmount?.raw??0)>0;return n.jsxs(n.Fragment,{children:[n.jsxs("tr",{onClick:()=>{u&&(l(v=>!v),f())},children:[n.jsx(uu,{data:d}),n.jsx(ou,{data:d}),n.jsx(ru,{data:d}),n.jsx(fu,{data:d}),De(Je,bs,d)?n.jsx(au,{data:d}):n.jsx("td",{}),n.jsx(iu,{data:d,onChange:f}),De(Je,Ds,d)?n.jsx(lu,{data:d,onChange:f}):n.jsx("td",{}),De(Je,Ss,d)?n.jsx(du,{data:d}):n.jsx("td",{}),De(Je,js,d)?n.jsx(su,{data:d}):n.jsx("td",{}),n.jsx(cu,{data:d}),n.jsx(nu,{data:d,onChange:f}),n.jsx("td",{children:n.jsxs("div",{className:"flex flex-col gap-2",children:[e&&n.jsx(ci,{onClick:v=>{v.stopPropagation(),e(f)},tooltip:"Edit Charge"}),s&&n.jsx(sl,{toggleMergeSelected:()=>s(f),mergeSelected:a})]})}),n.jsx("td",{children:n.jsxs("div",{className:"flex flex-col gap-2",children:[n.jsx(Du,{chargeId:d.id,chargeType:d.__typename,setInsertDocument:t?()=>t(f):void 0,setMatchDocuments:r,onChange:f,isIncome:j}),u&&n.jsx(Ks,{toggleExpansion:l,isExpanded:c,onClickAction:()=>f()})]})})]}),u&&c&&n.jsx("tr",{children:n.jsx("td",{colSpan:13,children:n.jsx(ks,{style:{width:"100%"},withBorder:!0,shadow:"lg",children:n.jsx(Xf,{chargeID:d.id,onChange:f,fetching:m})})})})]})},up=({setEditChargeId:e,setInsertDocument:t,setMatchDocuments:r,toggleMergeCharge:s,mergeSelectedCharges:a,data:o,isAllOpened:i})=>{const c=o?.map(l=>L(li,l))??[];return n.jsxs(Gs,{striped:!0,highlightOnHover:!0,children:[n.jsx("thead",{className:"sticky top-0 z-20",children:n.jsxs("tr",{className:"px-10 py-10 title-font tracking-wider font-medium text-gray-900 text-sm bg-gray-100 rounded-tl rounded-bl",children:[n.jsx("th",{children:"Type"}),n.jsx("th",{children:"Date"}),n.jsx("th",{children:"Amount"}),n.jsx("th",{children:"Vat"}),n.jsx("th",{children:"Counterparty"}),n.jsx("th",{children:"Description"}),n.jsx("th",{children:"Tags"}),n.jsx("th",{children:"Tax Category"}),n.jsx("th",{children:"Business Trip"}),n.jsx("th",{children:"More Info"}),n.jsx("th",{children:"Accountant Approval"}),n.jsx("th",{children:"Edit"}),n.jsx("th",{children:"More Info"})]})}),n.jsx("tbody",{children:c?.map(l=>n.jsx(ep,{data:l,setEditCharge:e?d=>e({id:l.id,onChange:d}):void 0,setInsertDocument:t?d=>t({id:l.id,onChange:d}):void 0,setMatchDocuments:r?()=>r({id:l.id,ownerId:l.owner.id}):void 0,toggleMergeCharge:s?d=>s(l.id,d):void 0,isSelectedForMerge:a?.has(l.id)??!1,isAllOpened:i},l.id))})]})};export{up as C,Ef as L,Hd as M,Qd as S,zn as T,Qi as W,sl as a,Xf as b,la as c,_a as d,qs as e,tu as u};
|