@accounter/client 0.0.8-alpha-20251030162201-d2f279aafe537912ec3546af855cbd3a38ac0f5c → 0.0.8-alpha-20251030162303-87017b2c2addf0e61478260aac336b9343f15c98

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (116) hide show
  1. package/CHANGELOG.md +1 -16
  2. package/dist/assets/{Checkbox-qEdmT4HE.js → Checkbox-CLE7WylX.js} +2 -2
  3. package/dist/assets/{MultiSelect-Dm9mO7pJ.js → MultiSelect-SsgUtHuW.js} +1 -1
  4. package/dist/assets/{Progress-kr0gnfBa.js → Progress-D7j8SJRp.js} +1 -1
  5. package/dist/assets/{Table-DnHfGe-y.js → Table-DpZKU9e6.js} +1 -1
  6. package/dist/assets/{Typography-Cu3puAUK.js → Typography-DOCvIzjw.js} +1 -1
  7. package/dist/assets/{YearPickerInput-oa86GF4P.js → YearPickerInput-BbyQMsmW.js} +1 -1
  8. package/dist/assets/{accordion-DLtMSqIv.js → accordion-KRd9M_7N.js} +1 -1
  9. package/dist/assets/{accountant-approvals-DsL0uiBa.js → accountant-approvals-BWkXiUJx.js} +1 -1
  10. package/dist/assets/{accounter-table-BL_yrGIl.js → accounter-table-BvOYdMv2.js} +1 -1
  11. package/dist/assets/{addDays-DqZEDZy3.js → addDays-HTdY9JyJ.js} +1 -1
  12. package/dist/assets/{all-charges-D3Xf-pEY.js → all-charges-uOrXkSoe.js} +1 -1
  13. package/dist/assets/{arrow-up-down-DchtBEG4.js → arrow-up-down-D0e6luFS.js} +1 -1
  14. package/dist/assets/{building-2-ZTKteVvf.js → building-2-BScQAy2y.js} +1 -1
  15. package/dist/assets/{business-extended-info-1mzdXJbs.js → business-extended-info-BPdDug4k.js} +4 -4
  16. package/dist/assets/{business-header-CJqfKV4d.js → business-header-ScM944FH.js} +1 -1
  17. package/dist/assets/{business-ledger-filters-BRB1r_DP.js → business-ledger-filters-C6zdPVNQ.js} +1 -1
  18. package/dist/assets/{business-ledger-single-C8FIQJ8V.js → business-ledger-single-D_gxQY7c.js} +1 -1
  19. package/dist/assets/business-qHY5sNtm.js +37 -0
  20. package/dist/assets/business-trip-BD6qMULS.js +1 -0
  21. package/dist/assets/{charge-Df3lWZH-.js → charge-CXgCTI2e.js} +1 -1
  22. package/dist/assets/charges-filters-DhYogrgu.js +1 -0
  23. package/dist/assets/{charges-ledger-validation-CtCBR3C-.js → charges-ledger-validation-K96Gpr99.js} +1 -1
  24. package/dist/assets/{charges-table-CWbe3t13.js → charges-table-Cff0tibm.js} +7 -7
  25. package/dist/assets/{chart-Cmm-jp0c.js → chart-Rag7RVt5.js} +1 -1
  26. package/dist/assets/contracts-C26gq1yS.js +16 -0
  27. package/dist/assets/{data-table-pagination-fdOZTf64.js → data-table-pagination-BenxjRXY.js} +2 -2
  28. package/dist/assets/{download-csv-button-CwK31swX.js → download-csv-button-8ow10rSS.js} +1 -1
  29. package/dist/assets/edit-issue-document-modal-2d_PTbvO.js +1 -0
  30. package/dist/assets/{editable-business-trip-Bjxkm9xV.js → editable-business-trip-BFJ_Mqji.js} +2 -2
  31. package/dist/assets/eye-off-BNMLF-BO.js +6 -0
  32. package/dist/assets/{funnel-CMG4QvaK.js → funnel-DW3_rS_8.js} +1 -1
  33. package/dist/assets/{index-BZVrGMgV.js → index-1iKxq5ag.js} +2 -2
  34. package/dist/assets/{index-C_ZNQ0Zr.js → index-2unHvdGT.js} +1 -1
  35. package/dist/assets/{index-DInU4RP4.js → index-4ufIi3AX.js} +2 -2
  36. package/dist/assets/index-B0Je179L.js +1 -0
  37. package/dist/assets/index-B2VI47XT.js +1 -0
  38. package/dist/assets/index-B86FoQmY.js +1 -0
  39. package/dist/assets/{index-CgokSIpu.js → index-BCiHeRl-.js} +1 -1
  40. package/dist/assets/{index-6G62OvEh.js → index-BDUyPP2c.js} +1 -1
  41. package/dist/assets/index-BHA96r33.js +1 -0
  42. package/dist/assets/{index-CjC_SXIA.js → index-BPS5RB7_.js} +1 -1
  43. package/dist/assets/{index-B9CbQIGq.js → index-BQyZXdTq.js} +2 -2
  44. package/dist/assets/index-BZLSFBEt.js +1 -0
  45. package/dist/assets/{index-Cw_aKL-8.js → index-Bd-SKdyy.js} +178 -173
  46. package/dist/assets/{index-C7oYbGGm.js → index-Bo2SK7RM.js} +1 -1
  47. package/dist/assets/{index-jCPWIpdP.js → index-Bp6IHcih.js} +1 -1
  48. package/dist/assets/index-BrSZxw1u.css +1 -0
  49. package/dist/assets/{index-DFW4nqx8.js → index-CEiIgRJ2.js} +7 -7
  50. package/dist/assets/{index-CTatkdRy.js → index-CKNxDyu9.js} +2 -2
  51. package/dist/assets/index-CqIav7Xr.js +1 -0
  52. package/dist/assets/index-Dp9F68vS.js +1 -0
  53. package/dist/assets/{index-CriBDqbK.js → index-DvvRs9Ha.js} +1 -1
  54. package/dist/assets/{index-DLwMwjDQ.js → index-DyLWk3js.js} +1 -1
  55. package/dist/assets/index-NdA_oCxx.js +1 -0
  56. package/dist/assets/{index-BEahR51x.js → index-VD71ra9C.js} +2 -2
  57. package/dist/assets/{index-xxe8M91O.js → index-lMXNkFuw.js} +2 -2
  58. package/dist/assets/index-q3ev6JER.js +1 -0
  59. package/dist/assets/{index.es-B_Bf6nNm.js → index.es-C9I2aTP4.js} +1 -1
  60. package/dist/assets/{insert-business-trip-modal-Ds3RIlmF.js → insert-business-trip-modal-DVcWpJHr.js} +2 -2
  61. package/dist/assets/issue-document-BxTTlJ1T.js +1 -0
  62. package/dist/assets/{list-plus-B3EB-dKe.js → list-plus-B7wBrICK.js} +1 -1
  63. package/dist/assets/login-page-BpgscuKm.js +1 -0
  64. package/dist/assets/{match-document-modal-Bo9pBr8W.js → match-document-modal-CqP2SE2c.js} +4 -4
  65. package/dist/assets/{missing-info-charges-BQYXI7bj.js → missing-info-charges-CIs_kE3P.js} +1 -1
  66. package/dist/assets/{modal-Pj_6bAFk.js → modal-CwuHXtxz.js} +1 -1
  67. package/dist/assets/modify-contract-dialog-BoeamC68.js +1 -0
  68. package/dist/assets/{page-layout-CVTeUSZp.js → page-layout-XgNPsCmr.js} +1 -1
  69. package/dist/assets/{page-not-found-TvTAiAs4.js → page-not-found-CrFJMQNO.js} +1 -1
  70. package/dist/assets/{panel-top-open-DzBY_TuM.js → panel-top-open-DU7alj-S.js} +1 -1
  71. package/dist/assets/{pencil-BBmFhuZN.js → pencil-9DTTP5vx.js} +1 -1
  72. package/dist/assets/{report-commentary-row-Dqw62LLo.js → report-commentary-row-BdS3qqMS.js} +1 -1
  73. package/dist/assets/{save-BW18gNVs.js → save-i8sPy_OW.js} +1 -1
  74. package/dist/assets/similar-transactions-modal-CZAOYt-d.js +1 -0
  75. package/dist/assets/sub-BL9nfaPD.js +1 -0
  76. package/dist/assets/subMonths-DHPWOZP6.js +1 -0
  77. package/dist/assets/{summary-Bbsq64IN.js → summary-Dfiju7xJ.js} +1 -1
  78. package/dist/assets/{toggle-expansion-button-BrKkZtGj.js → toggle-expansion-button-BbVh8z6s.js} +1 -1
  79. package/dist/assets/tooltip-C-fd9L1l.js +1 -0
  80. package/dist/assets/{use-url-query-C0mVgO2i.js → use-url-query-5TFyEk1x.js} +1 -1
  81. package/dist/index.html +2 -2
  82. package/package.json +1 -1
  83. package/src/components/business/admin-business-section.tsx +103 -282
  84. package/src/components/clients/contracts/modify-contract-dialog.tsx +341 -253
  85. package/src/components/contracts/cells/client.tsx +24 -0
  86. package/src/components/contracts/cells/date.tsx +10 -0
  87. package/src/components/contracts/cells/index.ts +2 -0
  88. package/src/components/contracts/columns.tsx +182 -0
  89. package/src/components/contracts/contracts-filter.tsx +160 -0
  90. package/src/components/contracts/index.tsx +264 -0
  91. package/src/components/contracts/issue-documents-modal.tsx +234 -0
  92. package/src/components/layout/sidelinks.tsx +7 -0
  93. package/src/components/screens/businesses/clients/contracts/contracts.tsx +56 -0
  94. package/src/gql/gql.ts +27 -3
  95. package/src/gql/graphql.ts +73 -52
  96. package/src/router/config.tsx +13 -0
  97. package/src/router/routes.ts +1 -0
  98. package/dist/assets/business-CAcKSrnu.js +0 -37
  99. package/dist/assets/business-trip-DkTEY8b1.js +0 -1
  100. package/dist/assets/charges-filters-DUuY-N0H.js +0 -1
  101. package/dist/assets/index-BD4s2ucv.css +0 -1
  102. package/dist/assets/index-BFwWHKS1.js +0 -1
  103. package/dist/assets/index-BI0XToIk.js +0 -1
  104. package/dist/assets/index-BQb_C-JL.js +0 -1
  105. package/dist/assets/index-CJQlHnFs.js +0 -1
  106. package/dist/assets/index-Cm6Blkgf.js +0 -1
  107. package/dist/assets/index-DJLQkpmI.js +0 -6
  108. package/dist/assets/index-DcwGbXWr.js +0 -1
  109. package/dist/assets/index-Dlj3jpuW.js +0 -1
  110. package/dist/assets/index-iya2tfvn.js +0 -1
  111. package/dist/assets/issue-document-_iHCFO9h.js +0 -1
  112. package/dist/assets/login-page-BtT_TCEJ.js +0 -1
  113. package/dist/assets/similar-transactions-modal-B39q1NLa.js +0 -1
  114. package/dist/assets/sub-DOjETdwl.js +0 -1
  115. package/dist/assets/subMonths-DqeFZ4O6.js +0 -1
  116. package/dist/assets/tooltip-CbnJYNc4.js +0 -1
@@ -1,4 +1,4 @@
1
- import{v as Oe,j as r,er as vo,es as jo,et as bo,aH as Co,bC as Ve,bF as $,bD as we,eu as Do,r as g,bE as Ue,ai as T,bG as He,ev as Br,ew as So,ex as wo,el as _o,ey as Io,em as Wt,bn as Xe,ez as Vr,eA as Eo,d as jt,bO as Ur,J as L,eB as Oo,g as Pe,eC as Po,t as F,i as Ae,eD as Ao,bT as Gt,T as Le,B as X,m as Hr,eE as To,eF as No,G as xn,X as $o,eG as Fo,eH as ko,eI as nt,eJ as rt,eK as Mn,eL as zn,dy as Ro,eM as Kr,eN as Mo,l as gt,eO as zo,eP as Lo,D as yn,aS as Bo,bX as Gr,z as vn,eQ as Vo,eR as Uo,cT as qr,d6 as Wr,d8 as Yr,aT as Ho,aU as Ko,N as Xr,cW as jn,cX as bn,cY as Ye,cZ as Ne,c_ as Pt,c$ as Cn,d0 as Ie,p as Ln,x as Be,u as Qe,eS as Go,E as qo,c as Wo,eT as Yo,dW as Xo,eU as Jo,br as Re,eV as Qo,bV as At,R as mt,eW as Jr,eX as Qr,eY as ze,eZ as Zo,e_ as Zr,e$ as ea,f0 as ta,f1 as es,f2 as an,f3 as ts,f4 as na,f5 as ra,aR as Dn,f6 as sa,a4 as ns,f7 as rs,n as ft,bt as $e,bu as ss,bv as os,bN as as,bw as Tt,f8 as oa,f9 as aa,bU as Sn,e as ia,fa as ca,aa as la,fb as da,L as is,fc as ua,fd as fa,cU as pa,fe as cn,ff as cs,fg as ls,fh as ga,fi as Yt,fj as Bn,fk as ds,cV as ma,fl as ha,dq as De,dr as Se,aB as us,fm as Vn,e9 as xa,d7 as ya,P as va,dX as fs,fn as ps,fo as gs,fp as ja,cP as tt,fq as ms,fr as ba,fs as hs,Y as Ca,V as Da,ft as xs,fu as Sa,fv as ys,fw as vs,fx as _e,fy as je,fz as Un,fA as js,fB as wa,fC as _a,fD as qe,fE as Ia,fF as Ea,fG as Oa}from"./index-Cw_aKL-8.js";import{T as Pa}from"./toggle-expansion-button-BrKkZtGj.js";import{M as Aa,P as W,I as Ta,T as bs,a as Na,D as $a,A as Fa,b as ka,c as Ra,S as Ma,C as za,d as La}from"./index-xxe8M91O.js";import{T as Cs}from"./Table-DnHfGe-y.js";import{R as Ba,S as Va,M as oe,B as Ua,L as Hn,G as Xt,C as Kn,A as U,a as Ha}from"./summary-Bbsq64IN.js";import{L as Jt}from"./list-plus-B3EB-dKe.js";/**
1
+ import{v as Oe,j as r,ev as vo,ew as jo,ex as bo,aB as Co,c5 as Ve,c8 as $,c6 as we,ey as Do,r as g,c7 as Ue,aa as N,c9 as He,ez as Br,eA as So,eB as wo,ep as _o,eC as Io,eq as Wt,ba as Qe,eD as Vr,eE as Eo,d as jt,ch as Ur,G as L,eF as Oo,g as Pe,eG as Po,t as F,i as Ae,eH as Ao,bI as Gt,T as Le,B as Q,m as Hr,eI as No,eJ as To,y as xn,Q as $o,eK as Fo,eL as ko,eM as nt,eN as rt,eO as Mn,eP as zn,dF as Ro,eQ as Kr,eR as Mo,l as gt,eS as zo,eT as Lo,D as yn,aU as Bo,bX as Gr,x as vn,eU as Vo,eV as Uo,bJ as qr,bP as Wr,bQ as Yr,aV as Ho,aW as Ko,H as Qr,bz as jn,bA as bn,bB as Ye,bC as Te,bM as Pt,bD as Cn,bE as Ie,p as Ln,w as Be,u as Xe,eW as Go,E as qo,c as Wo,eX as Yo,d_ as Qo,eY as Jo,bf as Re,eZ as Xo,bm as At,R as mt,e_ as Jr,e$ as Xr,f0 as ze,f1 as Zo,f2 as Zr,f3 as ea,f4 as ta,f5 as es,f6 as an,f7 as ts,f8 as na,f9 as ra,bb as Dn,fa as sa,at as ns,fb as rs,n as ft,bh as $e,bi as ss,bj as os,cg as as,bk as Nt,fc as oa,fd as aa,cm as Sn,e as ia,fe as ca,a4 as la,ff as da,L as is,fg as ua,fh as fa,di as pa,fi as cn,fj as cs,fk as ls,fl as ga,fm as Yt,fn as Bn,fo as ds,dj as ma,fp as ha,dy as De,bK as Se,au as us,fq as Vn,ed as xa,bO as ya,P as va,d$ as fs,fr as ps,fs as gs,ft as ja,de as tt,fu as ms,fv as ba,fw as hs,V as Ca,N as Da,fx as xs,fy as Sa,fz as ys,fA as vs,fB as _e,fC as je,fD as Un,fE as js,fF as wa,fG as _a,fH as qe,fI as Ia,fJ as Ea,fK as Oa}from"./index-Bd-SKdyy.js";import{T as Pa}from"./toggle-expansion-button-BbVh8z6s.js";import{M as Aa,P as W,I as Na,T as bs,a as Ta,D as $a,A as Fa,b as ka,c as Ra,S as Ma,C as za,d as La}from"./index-lMXNkFuw.js";import{T as Cs}from"./Table-DpZKU9e6.js";import{R as Ba,S as Va,M as oe,B as Ua,L as Hn,G as Qt,C as Kn,A as U,a as Ha}from"./summary-Dfiju7xJ.js";import{L as Jt}from"./list-plus-B7wBrICK.js";/**
2
2
  * @license lucide-react v0.548.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -18,12 +18,12 @@ import{v as Oe,j as r,er as vo,es as jo,et as bo,aH as Co,bC as Ve,bF as $,bD as
18
18
  *
19
19
  * This source code is licensed under the ISC license.
20
20
  * See the LICENSE file in the root directory of this source tree.
21
- */const Xa=[["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"}]],Ja=Oe("combine",Xa);/**
21
+ */const Qa=[["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"}]],Ja=Oe("combine",Qa);/**
22
22
  * @license lucide-react v0.548.0 - ISC
23
23
  *
24
24
  * This source code is licensed under the ISC license.
25
25
  * See the LICENSE file in the root directory of this source tree.
26
- */const Qa=[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4",key:"1pf5j1"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M3 15h6",key:"4e2qda"}],["path",{d:"M6 12v6",key:"1u72j0"}]],Gn=Oe("file-plus-2",Qa);/**
26
+ */const Xa=[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4",key:"1pf5j1"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M3 15h6",key:"4e2qda"}],["path",{d:"M6 12v6",key:"1u72j0"}]],Gn=Oe("file-plus-2",Xa);/**
27
27
  * @license lucide-react v0.548.0 - ISC
28
28
  *
29
29
  * This source code is licensed under the ISC license.
@@ -53,10 +53,10 @@ import{v as Oe,j as r,er as vo,es as jo,et as bo,aH as Co,bC as Ve,bF as $,bD as
53
53
  *
54
54
  * This source code is licensed under the ISC license.
55
55
  * See the LICENSE file in the root directory of this source tree.
56
- */const li=[["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"}]],di=Oe("wallet",li),ui={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"},Ss=e=>ui[e]??"Unknown",fi={CommonCharge:r.jsx(Ds,{}),BusinessTripCharge:r.jsx(si,{}),DividendCharge:r.jsx(ei,{}),ConversionCharge:r.jsx(Co,{}),SalaryCharge:r.jsx(di,{}),InternalTransferCharge:r.jsx(Wa,{}),MonthlyVatCharge:r.jsx(bo,{}),BankDepositCharge:r.jsx(ni,{}),ForeignSecuritiesCharge:r.jsx(ci,{}),CreditcardBankCharge:r.jsx(jo,{}),FinancialCharge:r.jsx(vo,{})},pi=e=>fi[e]??r.jsx(Ds,{});function qn(e){return typeof e!="string"?"":e.charAt(0).toUpperCase()+e.slice(1)}var gi=Object.defineProperty,mi=Object.defineProperties,hi=Object.getOwnPropertyDescriptors,Wn=Object.getOwnPropertySymbols,xi=Object.prototype.hasOwnProperty,yi=Object.prototype.propertyIsEnumerable,Yn=(e,t,n)=>t in e?gi(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Qt=(e,t)=>{for(var n in t||(t={}))xi.call(t,n)&&Yn(e,n,t[n]);if(Wn)for(var n of Wn(t))yi.call(t,n)&&Yn(e,n,t[n]);return e},vi=(e,t)=>mi(e,hi(t));const ji=["light","filled","outline","dot","gradient"],Zt={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)}},bi={xs:$(4),sm:$(4),md:$(6),lg:$(8),xl:$(10)};function Ci({theme:e,variant:t,color:n,size:s,gradient:o}){if(!ji.includes(t))return null;if(t==="dot"){const i=we({size:s,sizes:bi});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(${we({size:s,sizes:e.spacing})} / 1.5 - ${i} / 2)`,"&::before":{content:'""',display:"block",width:i,height:i,borderRadius:i,backgroundColor:e.fn.themeColor(n,e.colorScheme==="dark"?4:e.fn.primaryShade("light"),!0),marginRight:i}}}const a=e.fn.variant({color:n,variant:t,gradient:o});return{background:a.background,color:a.color,border:`${$(t==="gradient"?0:1)} solid ${a.border}`}}var Di=Ve((e,{color:t,radius:n,gradient:s,fullWidth:o},{variant:a,size:i})=>{const{fontSize:l,height:c}=i in Zt?Zt[i]:Zt.md;return{leftSection:{marginRight:`calc(${e.spacing.xs} / 2)`},rightSection:{marginLeft:`calc(${e.spacing.xs} / 2)`},inner:{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},root:Qt(vi(Qt(Qt({},e.fn.focusStyles()),e.fn.fontStyles()),{fontSize:l,height:c,WebkitTapHighlightColor:"transparent",lineHeight:`calc(${c} - ${$(2)})`,textDecoration:"none",padding:`0 calc(${we({size:i,sizes:e.spacing})} / 1.5)`,boxSizing:"border-box",display:o?"flex":"inline-flex",alignItems:"center",justifyContent:"center",width:o?"100%":"auto",textTransform:"uppercase",borderRadius:e.fn.radius(n),fontWeight:700,letterSpacing:$(.25),cursor:"inherit",textOverflow:"ellipsis",overflow:"hidden"}),Ci({theme:e,variant:a,color:t,size:i,gradient:s}))}}),Si=Object.defineProperty,Nt=Object.getOwnPropertySymbols,ws=Object.prototype.hasOwnProperty,_s=Object.prototype.propertyIsEnumerable,Xn=(e,t,n)=>t in e?Si(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,wi=(e,t)=>{for(var n in t||(t={}))ws.call(t,n)&&Xn(e,n,t[n]);if(Nt)for(var n of Nt(t))_s.call(t,n)&&Xn(e,n,t[n]);return e},_i=(e,t)=>{var n={};for(var s in e)ws.call(e,s)&&t.indexOf(s)<0&&(n[s]=e[s]);if(e!=null&&Nt)for(var s of Nt(e))t.indexOf(s)<0&&_s.call(e,s)&&(n[s]=e[s]);return n};const Ii={variant:"light",size:"md",radius:"xl"},Is=g.forwardRef((e,t)=>{const n=Ue("Badge",Ii,e),{className:s,color:o,variant:a,fullWidth:i,children:l,size:c,leftSection:d,rightSection:x,radius:f,gradient:m,classNames:y,styles:p,unstyled:u}=n,v=_i(n,["className","color","variant","fullWidth","children","size","leftSection","rightSection","radius","gradient","classNames","styles","unstyled"]),{classes:h,cx:j}=Di({fullWidth:i,color:o,radius:f,gradient:m},{classNames:y,styles:p,name:"Badge",unstyled:u,variant:a,size:c});return T.createElement(He,wi({className:j(h.root,s),ref:t},v),d&&T.createElement("span",{className:h.leftSection},d),T.createElement("span",{className:h.inner},l),x&&T.createElement("span",{className:h.rightSection},x))});Is.displayName="@mantine/core/Badge";const ln=Do(Is);var Ei=Object.defineProperty,$t=Object.getOwnPropertySymbols,Es=Object.prototype.hasOwnProperty,Os=Object.prototype.propertyIsEnumerable,Jn=(e,t,n)=>t in e?Ei(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Qn=(e,t)=>{for(var n in t||(t={}))Es.call(t,n)&&Jn(e,n,t[n]);if($t)for(var n of $t(t))Os.call(t,n)&&Jn(e,n,t[n]);return e},Oi=(e,t)=>{var n={};for(var s in e)Es.call(e,s)&&t.indexOf(s)<0&&(n[s]=e[s]);if(e!=null&&$t)for(var s of $t(e))t.indexOf(s)<0&&Os.call(e,s)&&(n[s]=e[s]);return n};const Pi={multiple:!1},Ps=g.forwardRef((e,t)=>{const n=Ue("FileButton",Pi,e),{onChange:s,children:o,multiple:a,accept:i,name:l,form:c,resetRef:d,disabled:x,capture:f,inputProps:m}=n,y=Oi(n,["onChange","children","multiple","accept","name","form","resetRef","disabled","capture","inputProps"]),p=g.useRef(),u=()=>{!x&&p.current.click()},v=j=>{s(a?Array.from(j.currentTarget.files):j.currentTarget.files[0]||null)};return Br(d,()=>{p.current.value=""}),T.createElement(T.Fragment,null,o(Qn({onClick:u},y)),T.createElement("input",Qn({style:{display:"none"},type:"file",accept:i,multiple:a,onChange:v,ref:So(t,p),name:l,form:c,capture:f},m)))});Ps.displayName="@mantine/core/FileButton";var Ai=Ve(()=>({placeholder:{},input:{cursor:"pointer"}})),Ti=Object.defineProperty,Ni=Object.defineProperties,$i=Object.getOwnPropertyDescriptors,Ft=Object.getOwnPropertySymbols,As=Object.prototype.hasOwnProperty,Ts=Object.prototype.propertyIsEnumerable,Zn=(e,t,n)=>t in e?Ti(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,et=(e,t)=>{for(var n in t||(t={}))As.call(t,n)&&Zn(e,n,t[n]);if(Ft)for(var n of Ft(t))Ts.call(t,n)&&Zn(e,n,t[n]);return e},St=(e,t)=>Ni(e,$i(t)),Fi=(e,t)=>{var n={};for(var s in e)As.call(e,s)&&t.indexOf(s)<0&&(n[s]=e[s]);if(e!=null&&Ft)for(var s of Ft(e))t.indexOf(s)<0&&Ts.call(e,s)&&(n[s]=e[s]);return n};const ki=({value:e})=>T.createElement(Xe,{sx:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}},Array.isArray(e)?e.map(t=>t.name).join(", "):e?.name),Ri={size:"sm",valueComponent:ki},Ns=g.forwardRef((e,t)=>{const n=wo("FileInput",Ri,e),{inputProps:s,wrapperProps:o,placeholder:a,value:i,defaultValue:l,onChange:c,multiple:d,accept:x,name:f,form:m,classNames:y,styles:p,unstyled:u,valueComponent:v,rightSection:h,clearable:j,clearButtonProps:C,readOnly:I,capture:O,fileInputProps:_}=n,b=Fi(n,["inputProps","wrapperProps","placeholder","value","defaultValue","onChange","multiple","accept","name","form","classNames","styles","unstyled","valueComponent","rightSection","clearable","clearButtonProps","readOnly","capture","fileInputProps"]),w=g.useRef(),{classes:A,cx:k}=Ai(null,{name:"FileInput",classNames:y,styles:p,unstyled:u}),[N,G]=_o({value:i,defaultValue:l,onChange:c,finalValue:d?[]:null}),Y=Array.isArray(N)?N.length!==0:N!==null,R=h||(j&&Y&&!I?T.createElement(Io,St(et({},C),{variant:"transparent",onClick:()=>G(d?[]:null),size:s.size,unstyled:u})):null);return g.useEffect(()=>{(Array.isArray(N)&&N.length===0||N===null)&&w.current()},[N]),T.createElement(Wt.Wrapper,St(et({},o),{__staticSelector:"FileInput"}),T.createElement(Ps,{onChange:G,multiple:d,accept:x,name:f,form:m,resetRef:w,disabled:I,capture:O,inputProps:_},z=>T.createElement(Wt,St(et(et(et({multiline:!0},z),s),b),{component:"button",type:"button",ref:t,__staticSelector:"FileInput",rightSection:R,classNames:St(et({},y),{input:k(A.input,y?.input)})}),Y?T.createElement(v,{value:N}):T.createElement(Wt.Placeholder,{className:A.placeholder},a))))});Ns.displayName="@mantine/core/FileInput";const Mi=Ns;var zi=Object.defineProperty,Li=Object.defineProperties,Bi=Object.getOwnPropertyDescriptors,er=Object.getOwnPropertySymbols,Vi=Object.prototype.hasOwnProperty,Ui=Object.prototype.propertyIsEnumerable,tr=(e,t,n)=>t in e?zi(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Hi=(e,t)=>{for(var n in t||(t={}))Vi.call(t,n)&&tr(e,n,t[n]);if(er)for(var n of er(t))Ui.call(t,n)&&tr(e,n,t[n]);return e},Ki=(e,t)=>Li(e,Bi(t)),Gi=Ve(e=>({root:Ki(Hi({},e.fn.cover()),{display:"flex",alignItems:"center",justifyContent:"center",overflow:"hidden"})})),qi=Object.defineProperty,Wi=Object.defineProperties,Yi=Object.getOwnPropertyDescriptors,kt=Object.getOwnPropertySymbols,$s=Object.prototype.hasOwnProperty,Fs=Object.prototype.propertyIsEnumerable,nr=(e,t,n)=>t in e?qi(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,wt=(e,t)=>{for(var n in t||(t={}))$s.call(t,n)&&nr(e,n,t[n]);if(kt)for(var n of kt(t))Fs.call(t,n)&&nr(e,n,t[n]);return e},Xi=(e,t)=>Wi(e,Yi(t)),Ji=(e,t)=>{var n={};for(var s in e)$s.call(e,s)&&t.indexOf(s)<0&&(n[s]=e[s]);if(e!=null&&kt)for(var s of kt(e))t.indexOf(s)<0&&Fs.call(e,s)&&(n[s]=e[s]);return n};const Qi={overlayOpacity:.75,transitionDuration:0,radius:0,zIndex:Vr("overlay")},ks=g.forwardRef((e,t)=>{const n=Ue("LoadingOverlay",Qi,e),{className:s,visible:o,loaderProps:a,overlayOpacity:i,overlayColor:l,transitionDuration:c,exitTransitionDuration:d,zIndex:x,style:f,loader:m,radius:y,overlayBlur:p,unstyled:u,variant:v,keepMounted:h}=n,j=Ji(n,["className","visible","loaderProps","overlayOpacity","overlayColor","transitionDuration","exitTransitionDuration","zIndex","style","loader","radius","overlayBlur","unstyled","variant","keepMounted"]),{classes:C,cx:I,theme:O}=Gi(null,{name:"LoadingOverlay",unstyled:u,variant:v}),_=`calc(${x} + 1)`;return T.createElement(Eo,{keepMounted:h,duration:c,exitDuration:d,mounted:o,transition:"fade"},b=>T.createElement(He,wt({className:I(C.root,s),style:Xi(wt(wt({},b),f),{zIndex:x}),ref:t},j),m?T.createElement("div",{style:{zIndex:_}},m):T.createElement(jt,wt({style:{zIndex:_}},a)),T.createElement(Ur,{opacity:i,zIndex:x,radius:y,blur:p,unstyled:u,color:l||(O.colorScheme==="dark"?O.colors.dark[5]:O.white)})))});ks.displayName="@mantine/core/LoadingOverlay";var Zi=Object.defineProperty,ec=Object.defineProperties,tc=Object.getOwnPropertyDescriptors,rr=Object.getOwnPropertySymbols,nc=Object.prototype.hasOwnProperty,rc=Object.prototype.propertyIsEnumerable,sr=(e,t,n)=>t in e?Zi(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,or=(e,t)=>{for(var n in t||(t={}))nc.call(t,n)&&sr(e,n,t[n]);if(rr)for(var n of rr(t))rc.call(t,n)&&sr(e,n,t[n]);return e},sc=(e,t)=>ec(e,tc(t));const oc={xs:$(16),sm:$(20),md:$(26),lg:$(32),xl:$(40)},ac=["filled","light","gradient","outline","default"];function ic({theme:e,variant:t,color:n,gradient:s}){if(!ac.includes(t))return null;const o=e.fn.variant({variant:t,color:n||e.primaryColor,gradient:s,primaryFallback:!1});return{backgroundColor:o.background,color:o.color,backgroundImage:t==="gradient"?o.background:void 0,border:`${$(t==="gradient"?0:1)} solid ${o.border}`}}var cc=Ve((e,{color:t,radius:n,gradient:s},{variant:o,size:a})=>{const i=we({size:a,sizes:oc});return{root:or(sc(or({},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(n)}),ic({theme:e,variant:o,gradient:s,color:t}))}}),lc=Object.defineProperty,Rt=Object.getOwnPropertySymbols,Rs=Object.prototype.hasOwnProperty,Ms=Object.prototype.propertyIsEnumerable,ar=(e,t,n)=>t in e?lc(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,dc=(e,t)=>{for(var n in t||(t={}))Rs.call(t,n)&&ar(e,n,t[n]);if(Rt)for(var n of Rt(t))Ms.call(t,n)&&ar(e,n,t[n]);return e},uc=(e,t)=>{var n={};for(var s in e)Rs.call(e,s)&&t.indexOf(s)<0&&(n[s]=e[s]);if(e!=null&&Rt)for(var s of Rt(e))t.indexOf(s)<0&&Ms.call(e,s)&&(n[s]=e[s]);return n};const fc={size:"md",variant:"filled"},zs=g.forwardRef((e,t)=>{const n=Ue("ThemeIcon",fc,e),{className:s,size:o,radius:a,variant:i,color:l,children:c,gradient:d,unstyled:x}=n,f=uc(n,["className","size","radius","variant","color","children","gradient","unstyled"]),{classes:m,cx:y}=cc({variant:i,radius:a,color:l,gradient:d},{name:"ThemeIcon",unstyled:x,variant:i,size:o});return T.createElement(He,dc({className:y(m.root,s),ref:t},f),c)});zs.displayName="@mantine/core/ThemeIcon";const pc=({data:e})=>{const t=L(Oo,e);return r.jsxs(r.Fragment,{children:[r.jsx(Ba,{data:t,onChange:()=>{}}),r.jsx(Va,{data:t})]})},gc="deleteCharge",mc=()=>{const[{fetching:e},t]=Pe(Po),n=g.useCallback(async s=>{const o=`Error deleting charge ID [${s.chargeId}]`,a=`${gc}-${s.chargeId}`;F.loading("Deleting charge",{id:a});try{const i=await t(s),l=Ae(i,o,a);if(l){if(l.deleteCharge===!1)throw new Error("Unsuccessful deletion");return F.success("Success",{id:a,description:"Charge was deleted"}),l.deleteCharge}}catch(i){console.error(`${o}: ${i}`),F.error("Error",{id:a,description:o,duration:1e5,closeButton:!0})}return!1},[t]);return{fetching:e,deleteCharge:n}},hc="regenerateLedgerRecords",xc=()=>{const[{fetching:e},t]=Pe(Ao),n=g.useCallback(async s=>{const o="Error regenerating ledger",a=`${hc}-${s.chargeId}`;F.loading("Regenerating Ledger",{id:a});try{const i=await t(s),l=Ae(i,o,a,"regenerateLedgerRecords");if(l)return F.success("Success",{id:a,description:"Ledger records were regenerated"}),l.regenerateLedgerRecords}catch(i){console.error(`${o}: ${i}`),F.error("Error",{id:a,description:o,duration:1e5,closeButton:!0})}},[t]);return{fetching:e,regenerateLedgerRecords:n}};function yc({chargeId:e,onChange:t,...n}){const{regenerateLedgerRecords:s}=xc();function o(){s({chargeId:e}).then(t)}return r.jsx(Gt,{onConfirm:o,title:"Are you sure you want to regenerate ledger records?",children:r.jsx(Le,{label:"Regenerate Ledger",children:r.jsx(X,{variant:"outline",size:"icon",...n,className:Hr("size-7.5",n.className),children:r.jsx(ai,{className:"size-5"})})})})}function vc(e){const{mergeSelected:t,toggleMergeSelected:n}=e,[s,o]=g.useState(t?"default":"ghost");return g.useEffect(()=>{o(t?"default":"ghost")},[t]),r.jsx(Le,{label:"Select for merge",children:r.jsx(X,{onClick:a=>{a.stopPropagation(),n()},variant:s,className:Hr("size-7.5",t?"bg-blue-500 hover:bg-blue-500/90":""),children:r.jsx(Ja,{className:"size-5"})})})}const jc="updateCharge",Ls=()=>{const[{fetching:e},t]=Pe(To),n=g.useCallback(async s=>{const o=`Error updating charge ID [${s.chargeId}]`,a=`${jc}-${s.chargeId}`;F.loading("Updating charge",{id:a});try{const i=await t(s),l=Ae(i,o,a,"updateCharge");if(l)return F.success("Success",{id:a,description:"Charge updated"}),l.updateCharge.charge}catch(i){console.error(`${o}: ${i}`),F.error("Error",{id:a,description:o,duration:1e5,closeButton:!0})}},[t]);return{fetching:e,updateCharge:n}},bc="updateMiscExpense",Cc=()=>{const[{fetching:e},t]=Pe(No),n=g.useCallback(async s=>{const o=`Error updating misc expense ID [${s.id}]`,a=`${bc}-${s.id}`;F.loading("Update Misc Expense",{id:a});try{const i=await t(s),l=Ae(i,o,a,"updateMiscExpense");if(l)return F.success("Success",{id:a,description:"Misc expense was updated"}),l.updateMiscExpense}catch(i){console.error(`${o}: ${i}`),F.error("Error",{id:a,description:o,duration:1e5,closeButton:!0})}},[t]);return{fetching:e,updateMiscExpense:n}},Dc=({onDone:e,data:t})=>{const[n,s]=g.useState(!1),o=L(Fo,t),a=xn({defaultValues:{amount:o.amount.raw,currency:o.amount.currency,description:o.description,valueDate:new Date(o.valueDate),invoiceDate:o.invoiceDate,creditorId:o.creditor.id,debtorId:o.debtor.id}}),{handleSubmit:i,formState:{dirtyFields:l}}=a,{updateMiscExpense:c,fetching:d}=Cc(),x=g.useCallback(async m=>{s(!0),await c({id:o.id,fields:m}),e(),s(!1)},[c,e,o.id]),f=m=>{m&&Object.keys(m).length>0&&x({...m})};return n?r.jsx(jt,{className:"flex self-center my-5",color:"dark",size:"xl",variant:"dots"}):r.jsx($o,{...a,children:r.jsx("form",{onSubmit:i(f),noValidate:!0,children:r.jsxs("div",{className:"px-5 flex flex-col gap-5",children:[r.jsx(Aa,{formManager:a,isInsert:!1}),r.jsx("div",{className:"flex justify-right gap-5 mt-5",children:r.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(l).length===0,children:"Accept"})})]})})})},Sc="insertSalaryRecordsFromFile",wc=()=>{const[{fetching:e},t]=Pe(ko),n=g.useCallback(async s=>{const o=`Error uploading payroll file to charge ID [${s.chargeId}]`,a=`${Sc}-${s.chargeId}`;F.loading("Uploading payroll file",{id:a});try{const i=await t(s),l=Ae(i,o,a,"insertSalaryRecordsFromFile");if(l)return F.success("Success",{id:a,description:"Payroll file added"}),l.insertSalaryRecordsFromFile}catch(i){console.error(`${o}: ${i}`),F.error("Error",{id:a,description:o,duration:1e5,closeButton:!0})}return!1},[t]);return{fetching:e,uploadPayrollFile:n}},_c=({chargeId:e,onDone:t})=>{const{fetching:n,uploadPayrollFile:s}=wc(),[o,a]=g.useState(null),i=g.useCallback(async()=>{o&&s({file:o,chargeId:e}).then(t)},[s,t,o,e]);return r.jsxs("div",{className:"px-5 w-max h-max justify-items-center",children:[r.jsx(Mi,{icon:n&&r.jsx(jt,{}),value:o,onChange:a,clearable:!0,label:"File Upload"}),r.jsx("div",{className:"flex justify-center gap-5 mt-5",children:r.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:n||!o,onClick:i,children:"Accept"})})]})};var Ic=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 bt(e,t){var n=Ec(e);if(typeof n.path!="string"){var s=e.webkitRelativePath;Object.defineProperty(n,"path",{value:typeof t=="string"?t:typeof s=="string"&&s.length>0?s:e.name,writable:!1,configurable:!1,enumerable:!0})}return n}function Ec(e){var t=e.name,n=t&&t.lastIndexOf(".")!==-1;if(n&&!e.type){var s=t.split(".").pop().toLowerCase(),o=Ic.get(s);o&&Object.defineProperty(e,"type",{value:o,writable:!1,configurable:!1,enumerable:!0})}return e}var Oc=[".DS_Store","Thumbs.db"];function Pc(e){return nt(this,void 0,void 0,function(){return rt(this,function(t){return Mt(e)&&Ac(e.dataTransfer)?[2,Fc(e.dataTransfer,e.type)]:Tc(e)?[2,Nc(e)]:Array.isArray(e)&&e.every(function(n){return"getFile"in n&&typeof n.getFile=="function"})?[2,$c(e)]:[2,[]]})})}function Ac(e){return Mt(e)}function Tc(e){return Mt(e)&&Mt(e.target)}function Mt(e){return typeof e=="object"&&e!==null}function Nc(e){return dn(e.target.files).map(function(t){return bt(t)})}function $c(e){return nt(this,void 0,void 0,function(){var t;return rt(this,function(n){switch(n.label){case 0:return[4,Promise.all(e.map(function(s){return s.getFile()}))];case 1:return t=n.sent(),[2,t.map(function(s){return bt(s)})]}})})}function Fc(e,t){return nt(this,void 0,void 0,function(){var n,s;return rt(this,function(o){switch(o.label){case 0:return e.items?(n=dn(e.items).filter(function(a){return a.kind==="file"}),t!=="drop"?[2,n]:[4,Promise.all(n.map(kc))]):[3,2];case 1:return s=o.sent(),[2,ir(Bs(s))];case 2:return[2,ir(dn(e.files).map(function(a){return bt(a)}))]}})})}function ir(e){return e.filter(function(t){return Oc.indexOf(t.name)===-1})}function dn(e){if(e===null)return[];for(var t=[],n=0;n<e.length;n++){var s=e[n];t.push(s)}return t}function kc(e){if(typeof e.webkitGetAsEntry!="function")return cr(e);var t=e.webkitGetAsEntry();return t&&t.isDirectory?Vs(t):cr(e)}function Bs(e){return e.reduce(function(t,n){return Mn(Mn([],zn(t),!1),zn(Array.isArray(n)?Bs(n):[n]),!1)},[])}function cr(e){var t=e.getAsFile();if(!t)return Promise.reject("".concat(e," is not a File"));var n=bt(t);return Promise.resolve(n)}function Rc(e){return nt(this,void 0,void 0,function(){return rt(this,function(t){return[2,e.isDirectory?Vs(e):Mc(e)]})})}function Vs(e){var t=e.createReader();return new Promise(function(n,s){var o=[];function a(){var i=this;t.readEntries(function(l){return nt(i,void 0,void 0,function(){var c,d,x;return rt(this,function(f){switch(f.label){case 0:if(l.length)return[3,5];f.label=1;case 1:return f.trys.push([1,3,,4]),[4,Promise.all(o)];case 2:return c=f.sent(),n(c),[3,4];case 3:return d=f.sent(),s(d),[3,4];case 4:return[3,6];case 5:x=Promise.all(l.map(Rc)),o.push(x),a(),f.label=6;case 6:return[2]}})})},function(l){s(l)})}a()})}function Mc(e){return nt(this,void 0,void 0,function(){return rt(this,function(t){return[2,new Promise(function(n,s){e.file(function(o){var a=bt(o,e.fullPath);n(a)},function(o){s(o)})})]})})}var _t={},lr;function zc(){return lr||(lr=1,_t.__esModule=!0,_t.default=function(e,t){if(e&&t){var n=Array.isArray(t)?t:t.split(",");if(n.length===0)return!0;var s=e.name||"",o=(e.type||"").toLowerCase(),a=o.replace(/\/.*$/,"");return n.some(function(i){var l=i.trim().toLowerCase();return l.charAt(0)==="."?s.toLowerCase().endsWith(l):l.endsWith("/*")?a===l.replace(/\/.*$/,""):o===l})}return!0}),_t}var Lc=zc();const Bc=Ro(Lc);function dr(e){return Hc(e)||Uc(e)||Hs(e)||Vc()}function Vc(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
56
+ */const li=[["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"}]],di=Oe("wallet",li),ui={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"},Ss=e=>ui[e]??"Unknown",fi={CommonCharge:r.jsx(Ds,{}),BusinessTripCharge:r.jsx(si,{}),DividendCharge:r.jsx(ei,{}),ConversionCharge:r.jsx(Co,{}),SalaryCharge:r.jsx(di,{}),InternalTransferCharge:r.jsx(Wa,{}),MonthlyVatCharge:r.jsx(bo,{}),BankDepositCharge:r.jsx(ni,{}),ForeignSecuritiesCharge:r.jsx(ci,{}),CreditcardBankCharge:r.jsx(jo,{}),FinancialCharge:r.jsx(vo,{})},pi=e=>fi[e]??r.jsx(Ds,{});function qn(e){return typeof e!="string"?"":e.charAt(0).toUpperCase()+e.slice(1)}var gi=Object.defineProperty,mi=Object.defineProperties,hi=Object.getOwnPropertyDescriptors,Wn=Object.getOwnPropertySymbols,xi=Object.prototype.hasOwnProperty,yi=Object.prototype.propertyIsEnumerable,Yn=(e,t,n)=>t in e?gi(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Xt=(e,t)=>{for(var n in t||(t={}))xi.call(t,n)&&Yn(e,n,t[n]);if(Wn)for(var n of Wn(t))yi.call(t,n)&&Yn(e,n,t[n]);return e},vi=(e,t)=>mi(e,hi(t));const ji=["light","filled","outline","dot","gradient"],Zt={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)}},bi={xs:$(4),sm:$(4),md:$(6),lg:$(8),xl:$(10)};function Ci({theme:e,variant:t,color:n,size:s,gradient:o}){if(!ji.includes(t))return null;if(t==="dot"){const i=we({size:s,sizes:bi});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(${we({size:s,sizes:e.spacing})} / 1.5 - ${i} / 2)`,"&::before":{content:'""',display:"block",width:i,height:i,borderRadius:i,backgroundColor:e.fn.themeColor(n,e.colorScheme==="dark"?4:e.fn.primaryShade("light"),!0),marginRight:i}}}const a=e.fn.variant({color:n,variant:t,gradient:o});return{background:a.background,color:a.color,border:`${$(t==="gradient"?0:1)} solid ${a.border}`}}var Di=Ve((e,{color:t,radius:n,gradient:s,fullWidth:o},{variant:a,size:i})=>{const{fontSize:l,height:c}=i in Zt?Zt[i]:Zt.md;return{leftSection:{marginRight:`calc(${e.spacing.xs} / 2)`},rightSection:{marginLeft:`calc(${e.spacing.xs} / 2)`},inner:{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},root:Xt(vi(Xt(Xt({},e.fn.focusStyles()),e.fn.fontStyles()),{fontSize:l,height:c,WebkitTapHighlightColor:"transparent",lineHeight:`calc(${c} - ${$(2)})`,textDecoration:"none",padding:`0 calc(${we({size:i,sizes:e.spacing})} / 1.5)`,boxSizing:"border-box",display:o?"flex":"inline-flex",alignItems:"center",justifyContent:"center",width:o?"100%":"auto",textTransform:"uppercase",borderRadius:e.fn.radius(n),fontWeight:700,letterSpacing:$(.25),cursor:"inherit",textOverflow:"ellipsis",overflow:"hidden"}),Ci({theme:e,variant:a,color:t,size:i,gradient:s}))}}),Si=Object.defineProperty,Tt=Object.getOwnPropertySymbols,ws=Object.prototype.hasOwnProperty,_s=Object.prototype.propertyIsEnumerable,Qn=(e,t,n)=>t in e?Si(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,wi=(e,t)=>{for(var n in t||(t={}))ws.call(t,n)&&Qn(e,n,t[n]);if(Tt)for(var n of Tt(t))_s.call(t,n)&&Qn(e,n,t[n]);return e},_i=(e,t)=>{var n={};for(var s in e)ws.call(e,s)&&t.indexOf(s)<0&&(n[s]=e[s]);if(e!=null&&Tt)for(var s of Tt(e))t.indexOf(s)<0&&_s.call(e,s)&&(n[s]=e[s]);return n};const Ii={variant:"light",size:"md",radius:"xl"},Is=g.forwardRef((e,t)=>{const n=Ue("Badge",Ii,e),{className:s,color:o,variant:a,fullWidth:i,children:l,size:c,leftSection:d,rightSection:x,radius:f,gradient:m,classNames:y,styles:p,unstyled:u}=n,v=_i(n,["className","color","variant","fullWidth","children","size","leftSection","rightSection","radius","gradient","classNames","styles","unstyled"]),{classes:h,cx:j}=Di({fullWidth:i,color:o,radius:f,gradient:m},{classNames:y,styles:p,name:"Badge",unstyled:u,variant:a,size:c});return N.createElement(He,wi({className:j(h.root,s),ref:t},v),d&&N.createElement("span",{className:h.leftSection},d),N.createElement("span",{className:h.inner},l),x&&N.createElement("span",{className:h.rightSection},x))});Is.displayName="@mantine/core/Badge";const ln=Do(Is);var Ei=Object.defineProperty,$t=Object.getOwnPropertySymbols,Es=Object.prototype.hasOwnProperty,Os=Object.prototype.propertyIsEnumerable,Jn=(e,t,n)=>t in e?Ei(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Xn=(e,t)=>{for(var n in t||(t={}))Es.call(t,n)&&Jn(e,n,t[n]);if($t)for(var n of $t(t))Os.call(t,n)&&Jn(e,n,t[n]);return e},Oi=(e,t)=>{var n={};for(var s in e)Es.call(e,s)&&t.indexOf(s)<0&&(n[s]=e[s]);if(e!=null&&$t)for(var s of $t(e))t.indexOf(s)<0&&Os.call(e,s)&&(n[s]=e[s]);return n};const Pi={multiple:!1},Ps=g.forwardRef((e,t)=>{const n=Ue("FileButton",Pi,e),{onChange:s,children:o,multiple:a,accept:i,name:l,form:c,resetRef:d,disabled:x,capture:f,inputProps:m}=n,y=Oi(n,["onChange","children","multiple","accept","name","form","resetRef","disabled","capture","inputProps"]),p=g.useRef(),u=()=>{!x&&p.current.click()},v=j=>{s(a?Array.from(j.currentTarget.files):j.currentTarget.files[0]||null)};return Br(d,()=>{p.current.value=""}),N.createElement(N.Fragment,null,o(Xn({onClick:u},y)),N.createElement("input",Xn({style:{display:"none"},type:"file",accept:i,multiple:a,onChange:v,ref:So(t,p),name:l,form:c,capture:f},m)))});Ps.displayName="@mantine/core/FileButton";var Ai=Ve(()=>({placeholder:{},input:{cursor:"pointer"}})),Ni=Object.defineProperty,Ti=Object.defineProperties,$i=Object.getOwnPropertyDescriptors,Ft=Object.getOwnPropertySymbols,As=Object.prototype.hasOwnProperty,Ns=Object.prototype.propertyIsEnumerable,Zn=(e,t,n)=>t in e?Ni(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,et=(e,t)=>{for(var n in t||(t={}))As.call(t,n)&&Zn(e,n,t[n]);if(Ft)for(var n of Ft(t))Ns.call(t,n)&&Zn(e,n,t[n]);return e},St=(e,t)=>Ti(e,$i(t)),Fi=(e,t)=>{var n={};for(var s in e)As.call(e,s)&&t.indexOf(s)<0&&(n[s]=e[s]);if(e!=null&&Ft)for(var s of Ft(e))t.indexOf(s)<0&&Ns.call(e,s)&&(n[s]=e[s]);return n};const ki=({value:e})=>N.createElement(Qe,{sx:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}},Array.isArray(e)?e.map(t=>t.name).join(", "):e?.name),Ri={size:"sm",valueComponent:ki},Ts=g.forwardRef((e,t)=>{const n=wo("FileInput",Ri,e),{inputProps:s,wrapperProps:o,placeholder:a,value:i,defaultValue:l,onChange:c,multiple:d,accept:x,name:f,form:m,classNames:y,styles:p,unstyled:u,valueComponent:v,rightSection:h,clearable:j,clearButtonProps:C,readOnly:I,capture:O,fileInputProps:_}=n,b=Fi(n,["inputProps","wrapperProps","placeholder","value","defaultValue","onChange","multiple","accept","name","form","classNames","styles","unstyled","valueComponent","rightSection","clearable","clearButtonProps","readOnly","capture","fileInputProps"]),w=g.useRef(),{classes:A,cx:k}=Ai(null,{name:"FileInput",classNames:y,styles:p,unstyled:u}),[T,G]=_o({value:i,defaultValue:l,onChange:c,finalValue:d?[]:null}),Y=Array.isArray(T)?T.length!==0:T!==null,R=h||(j&&Y&&!I?N.createElement(Io,St(et({},C),{variant:"transparent",onClick:()=>G(d?[]:null),size:s.size,unstyled:u})):null);return g.useEffect(()=>{(Array.isArray(T)&&T.length===0||T===null)&&w.current()},[T]),N.createElement(Wt.Wrapper,St(et({},o),{__staticSelector:"FileInput"}),N.createElement(Ps,{onChange:G,multiple:d,accept:x,name:f,form:m,resetRef:w,disabled:I,capture:O,inputProps:_},z=>N.createElement(Wt,St(et(et(et({multiline:!0},z),s),b),{component:"button",type:"button",ref:t,__staticSelector:"FileInput",rightSection:R,classNames:St(et({},y),{input:k(A.input,y?.input)})}),Y?N.createElement(v,{value:T}):N.createElement(Wt.Placeholder,{className:A.placeholder},a))))});Ts.displayName="@mantine/core/FileInput";const Mi=Ts;var zi=Object.defineProperty,Li=Object.defineProperties,Bi=Object.getOwnPropertyDescriptors,er=Object.getOwnPropertySymbols,Vi=Object.prototype.hasOwnProperty,Ui=Object.prototype.propertyIsEnumerable,tr=(e,t,n)=>t in e?zi(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Hi=(e,t)=>{for(var n in t||(t={}))Vi.call(t,n)&&tr(e,n,t[n]);if(er)for(var n of er(t))Ui.call(t,n)&&tr(e,n,t[n]);return e},Ki=(e,t)=>Li(e,Bi(t)),Gi=Ve(e=>({root:Ki(Hi({},e.fn.cover()),{display:"flex",alignItems:"center",justifyContent:"center",overflow:"hidden"})})),qi=Object.defineProperty,Wi=Object.defineProperties,Yi=Object.getOwnPropertyDescriptors,kt=Object.getOwnPropertySymbols,$s=Object.prototype.hasOwnProperty,Fs=Object.prototype.propertyIsEnumerable,nr=(e,t,n)=>t in e?qi(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,wt=(e,t)=>{for(var n in t||(t={}))$s.call(t,n)&&nr(e,n,t[n]);if(kt)for(var n of kt(t))Fs.call(t,n)&&nr(e,n,t[n]);return e},Qi=(e,t)=>Wi(e,Yi(t)),Ji=(e,t)=>{var n={};for(var s in e)$s.call(e,s)&&t.indexOf(s)<0&&(n[s]=e[s]);if(e!=null&&kt)for(var s of kt(e))t.indexOf(s)<0&&Fs.call(e,s)&&(n[s]=e[s]);return n};const Xi={overlayOpacity:.75,transitionDuration:0,radius:0,zIndex:Vr("overlay")},ks=g.forwardRef((e,t)=>{const n=Ue("LoadingOverlay",Xi,e),{className:s,visible:o,loaderProps:a,overlayOpacity:i,overlayColor:l,transitionDuration:c,exitTransitionDuration:d,zIndex:x,style:f,loader:m,radius:y,overlayBlur:p,unstyled:u,variant:v,keepMounted:h}=n,j=Ji(n,["className","visible","loaderProps","overlayOpacity","overlayColor","transitionDuration","exitTransitionDuration","zIndex","style","loader","radius","overlayBlur","unstyled","variant","keepMounted"]),{classes:C,cx:I,theme:O}=Gi(null,{name:"LoadingOverlay",unstyled:u,variant:v}),_=`calc(${x} + 1)`;return N.createElement(Eo,{keepMounted:h,duration:c,exitDuration:d,mounted:o,transition:"fade"},b=>N.createElement(He,wt({className:I(C.root,s),style:Qi(wt(wt({},b),f),{zIndex:x}),ref:t},j),m?N.createElement("div",{style:{zIndex:_}},m):N.createElement(jt,wt({style:{zIndex:_}},a)),N.createElement(Ur,{opacity:i,zIndex:x,radius:y,blur:p,unstyled:u,color:l||(O.colorScheme==="dark"?O.colors.dark[5]:O.white)})))});ks.displayName="@mantine/core/LoadingOverlay";var Zi=Object.defineProperty,ec=Object.defineProperties,tc=Object.getOwnPropertyDescriptors,rr=Object.getOwnPropertySymbols,nc=Object.prototype.hasOwnProperty,rc=Object.prototype.propertyIsEnumerable,sr=(e,t,n)=>t in e?Zi(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,or=(e,t)=>{for(var n in t||(t={}))nc.call(t,n)&&sr(e,n,t[n]);if(rr)for(var n of rr(t))rc.call(t,n)&&sr(e,n,t[n]);return e},sc=(e,t)=>ec(e,tc(t));const oc={xs:$(16),sm:$(20),md:$(26),lg:$(32),xl:$(40)},ac=["filled","light","gradient","outline","default"];function ic({theme:e,variant:t,color:n,gradient:s}){if(!ac.includes(t))return null;const o=e.fn.variant({variant:t,color:n||e.primaryColor,gradient:s,primaryFallback:!1});return{backgroundColor:o.background,color:o.color,backgroundImage:t==="gradient"?o.background:void 0,border:`${$(t==="gradient"?0:1)} solid ${o.border}`}}var cc=Ve((e,{color:t,radius:n,gradient:s},{variant:o,size:a})=>{const i=we({size:a,sizes:oc});return{root:or(sc(or({},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(n)}),ic({theme:e,variant:o,gradient:s,color:t}))}}),lc=Object.defineProperty,Rt=Object.getOwnPropertySymbols,Rs=Object.prototype.hasOwnProperty,Ms=Object.prototype.propertyIsEnumerable,ar=(e,t,n)=>t in e?lc(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,dc=(e,t)=>{for(var n in t||(t={}))Rs.call(t,n)&&ar(e,n,t[n]);if(Rt)for(var n of Rt(t))Ms.call(t,n)&&ar(e,n,t[n]);return e},uc=(e,t)=>{var n={};for(var s in e)Rs.call(e,s)&&t.indexOf(s)<0&&(n[s]=e[s]);if(e!=null&&Rt)for(var s of Rt(e))t.indexOf(s)<0&&Ms.call(e,s)&&(n[s]=e[s]);return n};const fc={size:"md",variant:"filled"},zs=g.forwardRef((e,t)=>{const n=Ue("ThemeIcon",fc,e),{className:s,size:o,radius:a,variant:i,color:l,children:c,gradient:d,unstyled:x}=n,f=uc(n,["className","size","radius","variant","color","children","gradient","unstyled"]),{classes:m,cx:y}=cc({variant:i,radius:a,color:l,gradient:d},{name:"ThemeIcon",unstyled:x,variant:i,size:o});return N.createElement(He,dc({className:y(m.root,s),ref:t},f),c)});zs.displayName="@mantine/core/ThemeIcon";const pc=({data:e})=>{const t=L(Oo,e);return r.jsxs(r.Fragment,{children:[r.jsx(Ba,{data:t,onChange:()=>{}}),r.jsx(Va,{data:t})]})},gc="deleteCharge",mc=()=>{const[{fetching:e},t]=Pe(Po),n=g.useCallback(async s=>{const o=`Error deleting charge ID [${s.chargeId}]`,a=`${gc}-${s.chargeId}`;F.loading("Deleting charge",{id:a});try{const i=await t(s),l=Ae(i,o,a);if(l){if(l.deleteCharge===!1)throw new Error("Unsuccessful deletion");return F.success("Success",{id:a,description:"Charge was deleted"}),l.deleteCharge}}catch(i){console.error(`${o}: ${i}`),F.error("Error",{id:a,description:o,duration:1e5,closeButton:!0})}return!1},[t]);return{fetching:e,deleteCharge:n}},hc="regenerateLedgerRecords",xc=()=>{const[{fetching:e},t]=Pe(Ao),n=g.useCallback(async s=>{const o="Error regenerating ledger",a=`${hc}-${s.chargeId}`;F.loading("Regenerating Ledger",{id:a});try{const i=await t(s),l=Ae(i,o,a,"regenerateLedgerRecords");if(l)return F.success("Success",{id:a,description:"Ledger records were regenerated"}),l.regenerateLedgerRecords}catch(i){console.error(`${o}: ${i}`),F.error("Error",{id:a,description:o,duration:1e5,closeButton:!0})}},[t]);return{fetching:e,regenerateLedgerRecords:n}};function yc({chargeId:e,onChange:t,...n}){const{regenerateLedgerRecords:s}=xc();function o(){s({chargeId:e}).then(t)}return r.jsx(Gt,{onConfirm:o,title:"Are you sure you want to regenerate ledger records?",children:r.jsx(Le,{label:"Regenerate Ledger",children:r.jsx(Q,{variant:"outline",size:"icon",...n,className:Hr("size-7.5",n.className),children:r.jsx(ai,{className:"size-5"})})})})}function vc(e){const{mergeSelected:t,toggleMergeSelected:n}=e,[s,o]=g.useState(t?"default":"ghost");return g.useEffect(()=>{o(t?"default":"ghost")},[t]),r.jsx(Le,{label:"Select for merge",children:r.jsx(Q,{onClick:a=>{a.stopPropagation(),n()},variant:s,className:Hr("size-7.5",t?"bg-blue-500 hover:bg-blue-500/90":""),children:r.jsx(Ja,{className:"size-5"})})})}const jc="updateCharge",Ls=()=>{const[{fetching:e},t]=Pe(No),n=g.useCallback(async s=>{const o=`Error updating charge ID [${s.chargeId}]`,a=`${jc}-${s.chargeId}`;F.loading("Updating charge",{id:a});try{const i=await t(s),l=Ae(i,o,a,"updateCharge");if(l)return F.success("Success",{id:a,description:"Charge updated"}),l.updateCharge.charge}catch(i){console.error(`${o}: ${i}`),F.error("Error",{id:a,description:o,duration:1e5,closeButton:!0})}},[t]);return{fetching:e,updateCharge:n}},bc="updateMiscExpense",Cc=()=>{const[{fetching:e},t]=Pe(To),n=g.useCallback(async s=>{const o=`Error updating misc expense ID [${s.id}]`,a=`${bc}-${s.id}`;F.loading("Update Misc Expense",{id:a});try{const i=await t(s),l=Ae(i,o,a,"updateMiscExpense");if(l)return F.success("Success",{id:a,description:"Misc expense was updated"}),l.updateMiscExpense}catch(i){console.error(`${o}: ${i}`),F.error("Error",{id:a,description:o,duration:1e5,closeButton:!0})}},[t]);return{fetching:e,updateMiscExpense:n}},Dc=({onDone:e,data:t})=>{const[n,s]=g.useState(!1),o=L(Fo,t),a=xn({defaultValues:{amount:o.amount.raw,currency:o.amount.currency,description:o.description,valueDate:new Date(o.valueDate),invoiceDate:o.invoiceDate,creditorId:o.creditor.id,debtorId:o.debtor.id}}),{handleSubmit:i,formState:{dirtyFields:l}}=a,{updateMiscExpense:c,fetching:d}=Cc(),x=g.useCallback(async m=>{s(!0),await c({id:o.id,fields:m}),e(),s(!1)},[c,e,o.id]),f=m=>{m&&Object.keys(m).length>0&&x({...m})};return n?r.jsx(jt,{className:"flex self-center my-5",color:"dark",size:"xl",variant:"dots"}):r.jsx($o,{...a,children:r.jsx("form",{onSubmit:i(f),noValidate:!0,children:r.jsxs("div",{className:"px-5 flex flex-col gap-5",children:[r.jsx(Aa,{formManager:a,isInsert:!1}),r.jsx("div",{className:"flex justify-right gap-5 mt-5",children:r.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(l).length===0,children:"Accept"})})]})})})},Sc="insertSalaryRecordsFromFile",wc=()=>{const[{fetching:e},t]=Pe(ko),n=g.useCallback(async s=>{const o=`Error uploading payroll file to charge ID [${s.chargeId}]`,a=`${Sc}-${s.chargeId}`;F.loading("Uploading payroll file",{id:a});try{const i=await t(s),l=Ae(i,o,a,"insertSalaryRecordsFromFile");if(l)return F.success("Success",{id:a,description:"Payroll file added"}),l.insertSalaryRecordsFromFile}catch(i){console.error(`${o}: ${i}`),F.error("Error",{id:a,description:o,duration:1e5,closeButton:!0})}return!1},[t]);return{fetching:e,uploadPayrollFile:n}},_c=({chargeId:e,onDone:t})=>{const{fetching:n,uploadPayrollFile:s}=wc(),[o,a]=g.useState(null),i=g.useCallback(async()=>{o&&s({file:o,chargeId:e}).then(t)},[s,t,o,e]);return r.jsxs("div",{className:"px-5 w-max h-max justify-items-center",children:[r.jsx(Mi,{icon:n&&r.jsx(jt,{}),value:o,onChange:a,clearable:!0,label:"File Upload"}),r.jsx("div",{className:"flex justify-center gap-5 mt-5",children:r.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:n||!o,onClick:i,children:"Accept"})})]})};var Ic=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 bt(e,t){var n=Ec(e);if(typeof n.path!="string"){var s=e.webkitRelativePath;Object.defineProperty(n,"path",{value:typeof t=="string"?t:typeof s=="string"&&s.length>0?s:e.name,writable:!1,configurable:!1,enumerable:!0})}return n}function Ec(e){var t=e.name,n=t&&t.lastIndexOf(".")!==-1;if(n&&!e.type){var s=t.split(".").pop().toLowerCase(),o=Ic.get(s);o&&Object.defineProperty(e,"type",{value:o,writable:!1,configurable:!1,enumerable:!0})}return e}var Oc=[".DS_Store","Thumbs.db"];function Pc(e){return nt(this,void 0,void 0,function(){return rt(this,function(t){return Mt(e)&&Ac(e.dataTransfer)?[2,Fc(e.dataTransfer,e.type)]:Nc(e)?[2,Tc(e)]:Array.isArray(e)&&e.every(function(n){return"getFile"in n&&typeof n.getFile=="function"})?[2,$c(e)]:[2,[]]})})}function Ac(e){return Mt(e)}function Nc(e){return Mt(e)&&Mt(e.target)}function Mt(e){return typeof e=="object"&&e!==null}function Tc(e){return dn(e.target.files).map(function(t){return bt(t)})}function $c(e){return nt(this,void 0,void 0,function(){var t;return rt(this,function(n){switch(n.label){case 0:return[4,Promise.all(e.map(function(s){return s.getFile()}))];case 1:return t=n.sent(),[2,t.map(function(s){return bt(s)})]}})})}function Fc(e,t){return nt(this,void 0,void 0,function(){var n,s;return rt(this,function(o){switch(o.label){case 0:return e.items?(n=dn(e.items).filter(function(a){return a.kind==="file"}),t!=="drop"?[2,n]:[4,Promise.all(n.map(kc))]):[3,2];case 1:return s=o.sent(),[2,ir(Bs(s))];case 2:return[2,ir(dn(e.files).map(function(a){return bt(a)}))]}})})}function ir(e){return e.filter(function(t){return Oc.indexOf(t.name)===-1})}function dn(e){if(e===null)return[];for(var t=[],n=0;n<e.length;n++){var s=e[n];t.push(s)}return t}function kc(e){if(typeof e.webkitGetAsEntry!="function")return cr(e);var t=e.webkitGetAsEntry();return t&&t.isDirectory?Vs(t):cr(e)}function Bs(e){return e.reduce(function(t,n){return Mn(Mn([],zn(t),!1),zn(Array.isArray(n)?Bs(n):[n]),!1)},[])}function cr(e){var t=e.getAsFile();if(!t)return Promise.reject("".concat(e," is not a File"));var n=bt(t);return Promise.resolve(n)}function Rc(e){return nt(this,void 0,void 0,function(){return rt(this,function(t){return[2,e.isDirectory?Vs(e):Mc(e)]})})}function Vs(e){var t=e.createReader();return new Promise(function(n,s){var o=[];function a(){var i=this;t.readEntries(function(l){return nt(i,void 0,void 0,function(){var c,d,x;return rt(this,function(f){switch(f.label){case 0:if(l.length)return[3,5];f.label=1;case 1:return f.trys.push([1,3,,4]),[4,Promise.all(o)];case 2:return c=f.sent(),n(c),[3,4];case 3:return d=f.sent(),s(d),[3,4];case 4:return[3,6];case 5:x=Promise.all(l.map(Rc)),o.push(x),a(),f.label=6;case 6:return[2]}})})},function(l){s(l)})}a()})}function Mc(e){return nt(this,void 0,void 0,function(){return rt(this,function(t){return[2,new Promise(function(n,s){e.file(function(o){var a=bt(o,e.fullPath);n(a)},function(o){s(o)})})]})})}var _t={},lr;function zc(){return lr||(lr=1,_t.__esModule=!0,_t.default=function(e,t){if(e&&t){var n=Array.isArray(t)?t:t.split(",");if(n.length===0)return!0;var s=e.name||"",o=(e.type||"").toLowerCase(),a=o.replace(/\/.*$/,"");return n.some(function(i){var l=i.trim().toLowerCase();return l.charAt(0)==="."?s.toLowerCase().endsWith(l):l.endsWith("/*")?a===l.replace(/\/.*$/,""):o===l})}return!0}),_t}var Lc=zc();const Bc=Ro(Lc);function dr(e){return Hc(e)||Uc(e)||Hs(e)||Vc()}function Vc(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
57
57
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Uc(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function Hc(e){if(Array.isArray(e))return un(e)}function ur(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter(function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable})),n.push.apply(n,s)}return n}function fr(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?ur(Object(n),!0).forEach(function(s){Us(e,s,n[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ur(Object(n)).forEach(function(s){Object.defineProperty(e,s,Object.getOwnPropertyDescriptor(n,s))})}return e}function Us(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function ht(e,t){return qc(e)||Gc(e,t)||Hs(e,t)||Kc()}function Kc(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
58
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Hs(e,t){if(e){if(typeof e=="string")return un(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if(n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set")return Array.from(e);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return un(e,t)}}function un(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,s=new Array(t);n<t;n++)s[n]=e[n];return s}function Gc(e,t){var n=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(n!=null){var s=[],o=!0,a=!1,i,l;try{for(n=n.call(e);!(o=(i=n.next()).done)&&(s.push(i.value),!(t&&s.length===t));o=!0);}catch(c){a=!0,l=c}finally{try{!o&&n.return!=null&&n.return()}finally{if(a)throw l}}return s}}function qc(e){if(Array.isArray(e))return e}var Wc="file-invalid-type",Yc="file-too-large",Xc="file-too-small",Jc="too-many-files",Qc=function(t){t=Array.isArray(t)&&t.length===1?t[0]:t;var n=Array.isArray(t)?"one of ".concat(t.join(", ")):t;return{code:Wc,message:"File type must be ".concat(n)}},pr=function(t){return{code:Yc,message:"File is larger than ".concat(t," ").concat(t===1?"byte":"bytes")}},gr=function(t){return{code:Xc,message:"File is smaller than ".concat(t," ").concat(t===1?"byte":"bytes")}},Zc={code:Jc,message:"Too many files"};function Ks(e,t){var n=e.type==="application/x-moz-file"||Bc(e,t);return[n,n?null:Qc(t)]}function Gs(e,t,n){if(We(e.size))if(We(t)&&We(n)){if(e.size>n)return[!1,pr(n)];if(e.size<t)return[!1,gr(t)]}else{if(We(t)&&e.size<t)return[!1,gr(t)];if(We(n)&&e.size>n)return[!1,pr(n)]}return[!0,null]}function We(e){return e!=null}function el(e){var t=e.files,n=e.accept,s=e.minSize,o=e.maxSize,a=e.multiple,i=e.maxFiles,l=e.validator;return!a&&t.length>1||a&&i>=1&&t.length>i?!1:t.every(function(c){var d=Ks(c,n),x=ht(d,1),f=x[0],m=Gs(c,s,o),y=ht(m,1),p=y[0],u=l?l(c):null;return f&&p&&!u})}function zt(e){return typeof e.isPropagationStopped=="function"?e.isPropagationStopped():typeof e.cancelBubble<"u"?e.cancelBubble:!1}function It(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 tl(e){return e.indexOf("MSIE")!==-1||e.indexOf("Trident/")!==-1}function nl(e){return e.indexOf("Edge/")!==-1}function rl(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:window.navigator.userAgent;return tl(e)||nl(e)}function Te(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return function(s){for(var o=arguments.length,a=new Array(o>1?o-1:0),i=1;i<o;i++)a[i-1]=arguments[i];return t.some(function(l){return!zt(s)&&l&&l.apply(void 0,[s].concat(a)),zt(s)})}}function sl(){return"showOpenFilePicker"in window}function ol(e){if(We(e)){var t=Object.entries(e).filter(function(n){var s=ht(n,2),o=s[0],a=s[1],i=!0;return qs(o)||(console.warn('Skipped "'.concat(o,'" 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(a)||!a.every(Ws))&&(console.warn('Skipped "'.concat(o,'" because an invalid file extension was provided.')),i=!1),i}).reduce(function(n,s){var o=ht(s,2),a=o[0],i=o[1];return fr(fr({},n),{},Us({},a,i))},{});return[{description:"Files",accept:t}]}return e}function al(e){if(We(e))return Object.entries(e).reduce(function(t,n){var s=ht(n,2),o=s[0],a=s[1];return[].concat(dr(t),[o],dr(a))},[]).filter(function(t){return qs(t)||Ws(t)}).join(",")}function il(e){return e instanceof DOMException&&(e.name==="AbortError"||e.code===e.ABORT_ERR)}function cl(e){return e instanceof DOMException&&(e.name==="SecurityError"||e.code===e.SECURITY_ERR)}function qs(e){return e==="audio/*"||e==="video/*"||e==="image/*"||e==="text/*"||/\w+\/[-+.\w]+/g.test(e)}function Ws(e){return/^.*\.[\w]+$/.test(e)}var ll=["children"],dl=["open"],ul=["refKey","role","onKeyDown","onFocus","onBlur","onClick","onDragEnter","onDragOver","onDragLeave","onDrop"],fl=["refKey","onChange","onClick"];function pl(e){return hl(e)||ml(e)||Ys(e)||gl()}function gl(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
58
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Hs(e,t){if(e){if(typeof e=="string")return un(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if(n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set")return Array.from(e);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return un(e,t)}}function un(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,s=new Array(t);n<t;n++)s[n]=e[n];return s}function Gc(e,t){var n=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(n!=null){var s=[],o=!0,a=!1,i,l;try{for(n=n.call(e);!(o=(i=n.next()).done)&&(s.push(i.value),!(t&&s.length===t));o=!0);}catch(c){a=!0,l=c}finally{try{!o&&n.return!=null&&n.return()}finally{if(a)throw l}}return s}}function qc(e){if(Array.isArray(e))return e}var Wc="file-invalid-type",Yc="file-too-large",Qc="file-too-small",Jc="too-many-files",Xc=function(t){t=Array.isArray(t)&&t.length===1?t[0]:t;var n=Array.isArray(t)?"one of ".concat(t.join(", ")):t;return{code:Wc,message:"File type must be ".concat(n)}},pr=function(t){return{code:Yc,message:"File is larger than ".concat(t," ").concat(t===1?"byte":"bytes")}},gr=function(t){return{code:Qc,message:"File is smaller than ".concat(t," ").concat(t===1?"byte":"bytes")}},Zc={code:Jc,message:"Too many files"};function Ks(e,t){var n=e.type==="application/x-moz-file"||Bc(e,t);return[n,n?null:Xc(t)]}function Gs(e,t,n){if(We(e.size))if(We(t)&&We(n)){if(e.size>n)return[!1,pr(n)];if(e.size<t)return[!1,gr(t)]}else{if(We(t)&&e.size<t)return[!1,gr(t)];if(We(n)&&e.size>n)return[!1,pr(n)]}return[!0,null]}function We(e){return e!=null}function el(e){var t=e.files,n=e.accept,s=e.minSize,o=e.maxSize,a=e.multiple,i=e.maxFiles,l=e.validator;return!a&&t.length>1||a&&i>=1&&t.length>i?!1:t.every(function(c){var d=Ks(c,n),x=ht(d,1),f=x[0],m=Gs(c,s,o),y=ht(m,1),p=y[0],u=l?l(c):null;return f&&p&&!u})}function zt(e){return typeof e.isPropagationStopped=="function"?e.isPropagationStopped():typeof e.cancelBubble<"u"?e.cancelBubble:!1}function It(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 tl(e){return e.indexOf("MSIE")!==-1||e.indexOf("Trident/")!==-1}function nl(e){return e.indexOf("Edge/")!==-1}function rl(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:window.navigator.userAgent;return tl(e)||nl(e)}function Ne(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return function(s){for(var o=arguments.length,a=new Array(o>1?o-1:0),i=1;i<o;i++)a[i-1]=arguments[i];return t.some(function(l){return!zt(s)&&l&&l.apply(void 0,[s].concat(a)),zt(s)})}}function sl(){return"showOpenFilePicker"in window}function ol(e){if(We(e)){var t=Object.entries(e).filter(function(n){var s=ht(n,2),o=s[0],a=s[1],i=!0;return qs(o)||(console.warn('Skipped "'.concat(o,'" 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(a)||!a.every(Ws))&&(console.warn('Skipped "'.concat(o,'" because an invalid file extension was provided.')),i=!1),i}).reduce(function(n,s){var o=ht(s,2),a=o[0],i=o[1];return fr(fr({},n),{},Us({},a,i))},{});return[{description:"Files",accept:t}]}return e}function al(e){if(We(e))return Object.entries(e).reduce(function(t,n){var s=ht(n,2),o=s[0],a=s[1];return[].concat(dr(t),[o],dr(a))},[]).filter(function(t){return qs(t)||Ws(t)}).join(",")}function il(e){return e instanceof DOMException&&(e.name==="AbortError"||e.code===e.ABORT_ERR)}function cl(e){return e instanceof DOMException&&(e.name==="SecurityError"||e.code===e.SECURITY_ERR)}function qs(e){return e==="audio/*"||e==="video/*"||e==="image/*"||e==="text/*"||/\w+\/[-+.\w]+/g.test(e)}function Ws(e){return/^.*\.[\w]+$/.test(e)}var ll=["children"],dl=["open"],ul=["refKey","role","onKeyDown","onFocus","onBlur","onClick","onDragEnter","onDragOver","onDragLeave","onDrop"],fl=["refKey","onChange","onClick"];function pl(e){return hl(e)||ml(e)||Ys(e)||gl()}function gl(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
59
59
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function ml(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function hl(e){if(Array.isArray(e))return fn(e)}function en(e,t){return vl(e)||yl(e,t)||Ys(e,t)||xl()}function xl(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
60
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Ys(e,t){if(e){if(typeof e=="string")return fn(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if(n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set")return Array.from(e);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return fn(e,t)}}function fn(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,s=new Array(t);n<t;n++)s[n]=e[n];return s}function yl(e,t){var n=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(n!=null){var s=[],o=!0,a=!1,i,l;try{for(n=n.call(e);!(o=(i=n.next()).done)&&(s.push(i.value),!(t&&s.length===t));o=!0);}catch(c){a=!0,l=c}finally{try{!o&&n.return!=null&&n.return()}finally{if(a)throw l}}return s}}function vl(e){if(Array.isArray(e))return e}function hr(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter(function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable})),n.push.apply(n,s)}return n}function J(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?hr(Object(n),!0).forEach(function(s){pn(e,s,n[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):hr(Object(n)).forEach(function(s){Object.defineProperty(e,s,Object.getOwnPropertyDescriptor(n,s))})}return e}function pn(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Lt(e,t){if(e==null)return{};var n=jl(e,t),s,o;if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(o=0;o<a.length;o++)s=a[o],!(t.indexOf(s)>=0)&&Object.prototype.propertyIsEnumerable.call(e,s)&&(n[s]=e[s])}return n}function jl(e,t){if(e==null)return{};var n={},s=Object.keys(e),o,a;for(a=0;a<s.length;a++)o=s[a],!(t.indexOf(o)>=0)&&(n[o]=e[o]);return n}var wn=g.forwardRef(function(e,t){var n=e.children,s=Lt(e,ll),o=Js(s),a=o.open,i=Lt(o,dl);return g.useImperativeHandle(t,function(){return{open:a}},[a]),T.createElement(g.Fragment,null,n(J(J({},i),{},{open:a})))});wn.displayName="Dropzone";var Xs={disabled:!1,getFilesFromEvent:Pc,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};wn.defaultProps=Xs;wn.propTypes={children:W.func,accept:W.objectOf(W.arrayOf(W.string)),multiple:W.bool,preventDropOnDocument:W.bool,noClick:W.bool,noKeyboard:W.bool,noDrag:W.bool,noDragEventsBubbling:W.bool,minSize:W.number,maxSize:W.number,maxFiles:W.number,disabled:W.bool,getFilesFromEvent:W.func,onFileDialogCancel:W.func,onFileDialogOpen:W.func,useFsAccessApi:W.bool,autoFocus:W.bool,onDragEnter:W.func,onDragLeave:W.func,onDragOver:W.func,onDrop:W.func,onDropAccepted:W.func,onDropRejected:W.func,onError:W.func,validator:W.func};var gn={isFocused:!1,isFileDialogActive:!1,isDragActive:!1,isDragAccept:!1,isDragReject:!1,acceptedFiles:[],fileRejections:[]};function Js(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t=J(J({},Xs),e),n=t.accept,s=t.disabled,o=t.getFilesFromEvent,a=t.maxSize,i=t.minSize,l=t.multiple,c=t.maxFiles,d=t.onDragEnter,x=t.onDragLeave,f=t.onDragOver,m=t.onDrop,y=t.onDropAccepted,p=t.onDropRejected,u=t.onFileDialogCancel,v=t.onFileDialogOpen,h=t.useFsAccessApi,j=t.autoFocus,C=t.preventDropOnDocument,I=t.noClick,O=t.noKeyboard,_=t.noDrag,b=t.noDragEventsBubbling,w=t.onError,A=t.validator,k=g.useMemo(function(){return al(n)},[n]),N=g.useMemo(function(){return ol(n)},[n]),G=g.useMemo(function(){return typeof v=="function"?v:xr},[v]),Y=g.useMemo(function(){return typeof u=="function"?u:xr},[u]),R=g.useRef(null),z=g.useRef(null),le=g.useReducer(bl,gn),ie=en(le,2),M=ie[0],B=ie[1],he=M.isFocused,de=M.isFileDialogActive,ue=g.useRef(typeof window<"u"&&window.isSecureContext&&h&&sl()),be=function(){!ue.current&&de&&setTimeout(function(){if(z.current){var E=z.current.files;E.length||(B({type:"closeDialog"}),Y())}},300)};g.useEffect(function(){return window.addEventListener("focus",be,!1),function(){window.removeEventListener("focus",be,!1)}},[z,de,Y,ue]);var K=g.useRef([]),xe=function(E){R.current&&R.current.contains(E.target)||(E.preventDefault(),K.current=[])};g.useEffect(function(){return C&&(document.addEventListener("dragover",mr,!1),document.addEventListener("drop",xe,!1)),function(){C&&(document.removeEventListener("dragover",mr),document.removeEventListener("drop",xe))}},[R,C]),g.useEffect(function(){return!s&&j&&R.current&&R.current.focus(),function(){}},[R,j,s]);var ae=g.useCallback(function(D){w?w(D):console.error(D)},[w]),ee=g.useCallback(function(D){D.preventDefault(),D.persist(),ve(D),K.current=[].concat(pl(K.current),[D.target]),It(D)&&Promise.resolve(o(D)).then(function(E){if(!(zt(D)&&!b)){var Z=E.length,se=Z>0&&el({files:E,accept:k,minSize:i,maxSize:a,multiple:l,maxFiles:c,validator:A}),me=Z>0&&!se;B({isDragAccept:se,isDragReject:me,isDragActive:!0,type:"setDraggedFiles"}),d&&d(D)}}).catch(function(E){return ae(E)})},[o,d,ae,b,k,i,a,l,c,A]),P=g.useCallback(function(D){D.preventDefault(),D.persist(),ve(D);var E=It(D);if(E&&D.dataTransfer)try{D.dataTransfer.dropEffect="copy"}catch{}return E&&f&&f(D),!1},[f,b]),fe=g.useCallback(function(D){D.preventDefault(),D.persist(),ve(D);var E=K.current.filter(function(se){return R.current&&R.current.contains(se)}),Z=E.indexOf(D.target);Z!==-1&&E.splice(Z,1),K.current=E,!(E.length>0)&&(B({type:"setDraggedFiles",isDragActive:!1,isDragAccept:!1,isDragReject:!1}),It(D)&&x&&x(D))},[R,x,b]),te=g.useCallback(function(D,E){var Z=[],se=[];D.forEach(function(me){var ke=Ks(me,k),Ce=en(ke,2),Ke=Ce[0],Ge=Ce[1],Me=Gs(me,i,a),Ze=en(Me,2),at=Ze[0],it=Ze[1],ct=A?A(me):null;if(Ke&&at&&!ct)Z.push(me);else{var lt=[Ge,it];ct&&(lt=lt.concat(ct)),se.push({file:me,errors:lt.filter(function(Dt){return Dt})})}}),(!l&&Z.length>1||l&&c>=1&&Z.length>c)&&(Z.forEach(function(me){se.push({file:me,errors:[Zc]})}),Z.splice(0)),B({acceptedFiles:Z,fileRejections:se,type:"setFiles"}),m&&m(Z,se,E),se.length>0&&p&&p(se,E),Z.length>0&&y&&y(Z,E)},[B,l,k,i,a,c,m,y,p,A]),H=g.useCallback(function(D){D.preventDefault(),D.persist(),ve(D),K.current=[],It(D)&&Promise.resolve(o(D)).then(function(E){zt(D)&&!b||te(E,D)}).catch(function(E){return ae(E)}),B({type:"reset"})},[o,te,ae,b]),S=g.useCallback(function(){if(ue.current){B({type:"openDialog"}),G();var D={multiple:l,types:N};window.showOpenFilePicker(D).then(function(E){return o(E)}).then(function(E){te(E,null),B({type:"closeDialog"})}).catch(function(E){il(E)?(Y(E),B({type:"closeDialog"})):cl(E)?(ue.current=!1,z.current?(z.current.value=null,z.current.click()):ae(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."))):ae(E)});return}z.current&&(B({type:"openDialog"}),G(),z.current.value=null,z.current.click())},[B,G,Y,h,te,ae,N,l]),V=g.useCallback(function(D){!R.current||!R.current.isEqualNode(D.target)||(D.key===" "||D.key==="Enter"||D.keyCode===32||D.keyCode===13)&&(D.preventDefault(),S())},[R,S]),q=g.useCallback(function(){B({type:"focus"})},[]),ne=g.useCallback(function(){B({type:"blur"})},[]),pe=g.useCallback(function(){I||(rl()?setTimeout(S,0):S())},[I,S]),ce=function(E){return s?null:E},ye=function(E){return O?null:ce(E)},ge=function(E){return _?null:ce(E)},ve=function(E){b&&E.stopPropagation()},re=g.useMemo(function(){return function(){var D=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},E=D.refKey,Z=E===void 0?"ref":E,se=D.role,me=D.onKeyDown,ke=D.onFocus,Ce=D.onBlur,Ke=D.onClick,Ge=D.onDragEnter,Me=D.onDragOver,Ze=D.onDragLeave,at=D.onDrop,it=Lt(D,ul);return J(J(pn({onKeyDown:ye(Te(me,V)),onFocus:ye(Te(ke,q)),onBlur:ye(Te(Ce,ne)),onClick:ce(Te(Ke,pe)),onDragEnter:ge(Te(Ge,ee)),onDragOver:ge(Te(Me,P)),onDragLeave:ge(Te(Ze,fe)),onDrop:ge(Te(at,H)),role:typeof se=="string"&&se!==""?se:"presentation"},Z,R),!s&&!O?{tabIndex:0}:{}),it)}},[R,V,q,ne,pe,ee,P,fe,H,O,_,s]),Fe=g.useCallback(function(D){D.stopPropagation()},[]),ot=g.useMemo(function(){return function(){var D=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},E=D.refKey,Z=E===void 0?"ref":E,se=D.onChange,me=D.onClick,ke=Lt(D,fl),Ce=pn({accept:k,multiple:l,type:"file",style:{display:"none"},onChange:ce(Te(se,H)),onClick:ce(Te(me,Fe)),tabIndex:-1},Z,z);return J(J({},Ce),ke)}},[z,n,l,H,s]);return J(J({},M),{},{isFocused:he&&!s,getRootProps:re,getInputProps:ot,rootRef:R,inputRef:z,open:ce(S)})}function bl(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({},gn),{},{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({},gn);default:return e}}function xr(){}const[Cl,Dl]=Kr("Dropzone component was not found in tree");var yr=Object.getOwnPropertySymbols,Sl=Object.prototype.hasOwnProperty,wl=Object.prototype.propertyIsEnumerable,_l=(e,t)=>{var n={};for(var s in e)Sl.call(e,s)&&t.indexOf(s)<0&&(n[s]=e[s]);if(e!=null&&yr)for(var s of yr(e))t.indexOf(s)<0&&wl.call(e,s)&&(n[s]=e[s]);return n};function _n(e){const t=n=>{const s=Ue(`Dropzone${qn(e)}`,{},n),{children:o}=s,a=_l(s,["children"]),i=Dl(),l=Mo(o)?o:T.createElement("span",null,o);return i[e]?g.cloneElement(l,a):null};return t.displayName=`@mantine/dropzone/${qn(e)}`,t}const Il=_n("accept"),El=_n("reject"),Ol=_n("idle");var Pl=Object.defineProperty,Al=Object.defineProperties,Tl=Object.getOwnPropertyDescriptors,vr=Object.getOwnPropertySymbols,Nl=Object.prototype.hasOwnProperty,$l=Object.prototype.propertyIsEnumerable,jr=(e,t,n)=>t in e?Pl(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,br=(e,t)=>{for(var n in t||(t={}))Nl.call(t,n)&&jr(e,n,t[n]);if(vr)for(var n of vr(t))$l.call(t,n)&&jr(e,n,t[n]);return e},Fl=(e,t)=>Al(e,Tl(t)),kl=Ve((e,{padding:t,radius:n})=>{const s=e.fn.variant({color:"red",variant:"light"}),o=e.fn.variant({color:e.primaryColor,variant:"light"});return{root:Fl(br(br({},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:we({size:t,sizes:e.spacing}),borderRadius:e.fn.radius(n),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"?o.background:e.colors[e.primaryColor][0],borderColor:e.colorScheme==="dark"?o.border:e.colors[e.primaryColor][4],"&:hover":{backgroundColor:e.colorScheme==="dark"?o.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"}}}),Rl=Object.defineProperty,Ml=Object.defineProperties,zl=Object.getOwnPropertyDescriptors,Bt=Object.getOwnPropertySymbols,Qs=Object.prototype.hasOwnProperty,Zs=Object.prototype.propertyIsEnumerable,Cr=(e,t,n)=>t in e?Rl(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,dt=(e,t)=>{for(var n in t||(t={}))Qs.call(t,n)&&Cr(e,n,t[n]);if(Bt)for(var n of Bt(t))Zs.call(t,n)&&Cr(e,n,t[n]);return e},tn=(e,t)=>Ml(e,zl(t)),Ll=(e,t)=>{var n={};for(var s in e)Qs.call(e,s)&&t.indexOf(s)<0&&(n[s]=e[s]);if(e!=null&&Bt)for(var s of Bt(e))t.indexOf(s)<0&&Zs.call(e,s)&&(n[s]=e[s]);return n};const Bl={padding:"md",loading:!1,multiple:!0,maxSize:1/0,autoFocus:!1,activateOnClick:!0,activateOnDrag:!0,dragEventsBubbling:!0,activateOnKeyboard:!0,useFsAccessApi:!0};function st(e){const t=Ue("Dropzone",Bl,e),{className:n,padding:s,radius:o,disabled:a,classNames:i,styles:l,loading:c,multiple:d,maxSize:x,accept:f,children:m,onDropAny:y,onDrop:p,onReject:u,openRef:v,name:h,unstyled:j,maxFiles:C,autoFocus:I,activateOnClick:O,activateOnDrag:_,dragEventsBubbling:b,activateOnKeyboard:w,onDragEnter:A,onDragLeave:k,onDragOver:N,onFileDialogCancel:G,onFileDialogOpen:Y,preventDropOnDocument:R,useFsAccessApi:z,getFilesFromEvent:le,validator:ie,variant:M}=t,B=Ll(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:he,cx:de}=kl({radius:o,padding:s},{name:"Dropzone",classNames:i,styles:l,unstyled:j,variant:M}),{getRootProps:ue,getInputProps:be,isDragAccept:K,isDragReject:xe,open:ae}=Js(dt({onDrop:y,onDropAccepted:p,onDropRejected:u,disabled:a||c,accept:Array.isArray(f)?f.reduce((P,fe)=>tn(dt({},P),{[fe]:[]}),{}):f,multiple:d,maxSize:x,maxFiles:C,autoFocus:I,noClick:!O,noDrag:!_,noDragEventsBubbling:!b,noKeyboard:!w,onDragEnter:A,onDragLeave:k,onDragOver:N,onFileDialogCancel:G,onFileDialogOpen:Y,preventDropOnDocument:R,useFsAccessApi:z,validator:ie},le?{getFilesFromEvent:le}:null));Br(v,ae);const ee=!K&&!xe;return T.createElement(Cl,{value:{accept:K,reject:xe,idle:ee}},T.createElement(He,tn(dt(dt({},B),ue()),{"data-accept":K||void 0,"data-reject":xe||void 0,"data-idle":ee||void 0,"data-loading":c||void 0,className:de(he.root,n)}),T.createElement(ks,{visible:c,radius:o,unstyled:j}),T.createElement("input",tn(dt({},be()),{name:h})),T.createElement("div",{className:he.inner},m)))}st.displayName="@mantine/dropzone/Dropzone";st.Accept=Il;st.Reject=El;st.Idle=Ol;const eo=st;var Vl=Object.defineProperty,Ul=Object.defineProperties,Hl=Object.getOwnPropertyDescriptors,Dr=Object.getOwnPropertySymbols,Kl=Object.prototype.hasOwnProperty,Gl=Object.prototype.propertyIsEnumerable,Sr=(e,t,n)=>t in e?Vl(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,ql=(e,t)=>{for(var n in t||(t={}))Kl.call(t,n)&&Sr(e,n,t[n]);if(Dr)for(var n of Dr(t))Gl.call(t,n)&&Sr(e,n,t[n]);return e},Wl=(e,t)=>Ul(e,Hl(t)),Yl=Ve(e=>({wrapper:Wl(ql({},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}})),Xl=Object.defineProperty,Jl=Object.defineProperties,Ql=Object.getOwnPropertyDescriptors,Vt=Object.getOwnPropertySymbols,to=Object.prototype.hasOwnProperty,no=Object.prototype.propertyIsEnumerable,wr=(e,t,n)=>t in e?Xl(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,nn=(e,t)=>{for(var n in t||(t={}))to.call(t,n)&&wr(e,n,t[n]);if(Vt)for(var n of Vt(t))no.call(t,n)&&wr(e,n,t[n]);return e},rn=(e,t)=>Jl(e,Ql(t)),Zl=(e,t)=>{var n={};for(var s in e)to.call(e,s)&&t.indexOf(s)<0&&(n[s]=e[s]);if(e!=null&&Vt)for(var s of Vt(e))t.indexOf(s)<0&&no.call(e,s)&&(n[s]=e[s]);return n};const ed={padding:"md",loading:!1,multiple:!0,maxSize:1/0,autoFocus:!1,activateOnClick:!0,activateOnDrag:!0,dragEventsBubbling:!0,activateOnKeyboard:!0,active:!0,zIndex:Vr("max"),withinPortal:!0};function ro(e){const t=Ue("DropzoneFullScreen",ed,e),{classNames:n,styles:s,sx:o,className:a,style:i,unstyled:l,active:c,onDrop:d,onReject:x,zIndex:f,withinPortal:m,portalProps:y}=t,p=Zl(t,["classNames","styles","sx","className","style","unstyled","active","onDrop","onReject","zIndex","withinPortal","portalProps"]),[u,v]=T.useState(0),[h,{open:j,close:C}]=gt(!1),{classes:I,cx:O}=Yl(null,{name:"DropzoneFullScreen",classNames:n,styles:s,unstyled:l}),_=w=>{w.dataTransfer.types.includes("Files")&&(v(A=>A+1),j())},b=()=>{v(w=>w-1)};return g.useEffect(()=>{u===0&&C()},[u]),g.useEffect(()=>{if(c)return document.addEventListener("dragenter",_,!1),document.addEventListener("dragleave",b,!1),()=>{document.removeEventListener("dragenter",_,!1),document.removeEventListener("dragleave",b,!1)}},[c]),T.createElement(zo,rn(nn({},y),{withinPortal:m}),T.createElement(He,{className:O(I.wrapper,a),sx:o,style:rn(nn({},i),{opacity:h?1:0,pointerEvents:h?"all":"none",zIndex:f})},T.createElement(st,rn(nn({},p),{classNames:n,styles:s,unstyled:l,className:I.dropzone,onDrop:w=>{d?.(w),C()},onReject:w=>{x?.(w),C()}}))))}ro.displayName="@mantine/dropzone/DropzoneFullScreen";eo.FullScreen=ro;const td=eo,nd=({children:e,chargeId:t})=>{const{uploading:n,uploadMultipleDocuments:s}=Lo();function o(a){F.error("Error",{description:a,duration:5e3})}return r.jsx(td,{onDrop:a=>s({documents:a,chargeId:t,isSensitive:!1}),onReject:a=>o(`Rejected Files:
60
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Ys(e,t){if(e){if(typeof e=="string")return fn(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if(n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set")return Array.from(e);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return fn(e,t)}}function fn(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,s=new Array(t);n<t;n++)s[n]=e[n];return s}function yl(e,t){var n=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(n!=null){var s=[],o=!0,a=!1,i,l;try{for(n=n.call(e);!(o=(i=n.next()).done)&&(s.push(i.value),!(t&&s.length===t));o=!0);}catch(c){a=!0,l=c}finally{try{!o&&n.return!=null&&n.return()}finally{if(a)throw l}}return s}}function vl(e){if(Array.isArray(e))return e}function hr(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter(function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable})),n.push.apply(n,s)}return n}function J(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?hr(Object(n),!0).forEach(function(s){pn(e,s,n[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):hr(Object(n)).forEach(function(s){Object.defineProperty(e,s,Object.getOwnPropertyDescriptor(n,s))})}return e}function pn(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Lt(e,t){if(e==null)return{};var n=jl(e,t),s,o;if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(o=0;o<a.length;o++)s=a[o],!(t.indexOf(s)>=0)&&Object.prototype.propertyIsEnumerable.call(e,s)&&(n[s]=e[s])}return n}function jl(e,t){if(e==null)return{};var n={},s=Object.keys(e),o,a;for(a=0;a<s.length;a++)o=s[a],!(t.indexOf(o)>=0)&&(n[o]=e[o]);return n}var wn=g.forwardRef(function(e,t){var n=e.children,s=Lt(e,ll),o=Js(s),a=o.open,i=Lt(o,dl);return g.useImperativeHandle(t,function(){return{open:a}},[a]),N.createElement(g.Fragment,null,n(J(J({},i),{},{open:a})))});wn.displayName="Dropzone";var Qs={disabled:!1,getFilesFromEvent:Pc,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};wn.defaultProps=Qs;wn.propTypes={children:W.func,accept:W.objectOf(W.arrayOf(W.string)),multiple:W.bool,preventDropOnDocument:W.bool,noClick:W.bool,noKeyboard:W.bool,noDrag:W.bool,noDragEventsBubbling:W.bool,minSize:W.number,maxSize:W.number,maxFiles:W.number,disabled:W.bool,getFilesFromEvent:W.func,onFileDialogCancel:W.func,onFileDialogOpen:W.func,useFsAccessApi:W.bool,autoFocus:W.bool,onDragEnter:W.func,onDragLeave:W.func,onDragOver:W.func,onDrop:W.func,onDropAccepted:W.func,onDropRejected:W.func,onError:W.func,validator:W.func};var gn={isFocused:!1,isFileDialogActive:!1,isDragActive:!1,isDragAccept:!1,isDragReject:!1,acceptedFiles:[],fileRejections:[]};function Js(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t=J(J({},Qs),e),n=t.accept,s=t.disabled,o=t.getFilesFromEvent,a=t.maxSize,i=t.minSize,l=t.multiple,c=t.maxFiles,d=t.onDragEnter,x=t.onDragLeave,f=t.onDragOver,m=t.onDrop,y=t.onDropAccepted,p=t.onDropRejected,u=t.onFileDialogCancel,v=t.onFileDialogOpen,h=t.useFsAccessApi,j=t.autoFocus,C=t.preventDropOnDocument,I=t.noClick,O=t.noKeyboard,_=t.noDrag,b=t.noDragEventsBubbling,w=t.onError,A=t.validator,k=g.useMemo(function(){return al(n)},[n]),T=g.useMemo(function(){return ol(n)},[n]),G=g.useMemo(function(){return typeof v=="function"?v:xr},[v]),Y=g.useMemo(function(){return typeof u=="function"?u:xr},[u]),R=g.useRef(null),z=g.useRef(null),le=g.useReducer(bl,gn),ie=en(le,2),M=ie[0],B=ie[1],he=M.isFocused,de=M.isFileDialogActive,ue=g.useRef(typeof window<"u"&&window.isSecureContext&&h&&sl()),be=function(){!ue.current&&de&&setTimeout(function(){if(z.current){var E=z.current.files;E.length||(B({type:"closeDialog"}),Y())}},300)};g.useEffect(function(){return window.addEventListener("focus",be,!1),function(){window.removeEventListener("focus",be,!1)}},[z,de,Y,ue]);var K=g.useRef([]),xe=function(E){R.current&&R.current.contains(E.target)||(E.preventDefault(),K.current=[])};g.useEffect(function(){return C&&(document.addEventListener("dragover",mr,!1),document.addEventListener("drop",xe,!1)),function(){C&&(document.removeEventListener("dragover",mr),document.removeEventListener("drop",xe))}},[R,C]),g.useEffect(function(){return!s&&j&&R.current&&R.current.focus(),function(){}},[R,j,s]);var ae=g.useCallback(function(D){w?w(D):console.error(D)},[w]),ee=g.useCallback(function(D){D.preventDefault(),D.persist(),ve(D),K.current=[].concat(pl(K.current),[D.target]),It(D)&&Promise.resolve(o(D)).then(function(E){if(!(zt(D)&&!b)){var Z=E.length,se=Z>0&&el({files:E,accept:k,minSize:i,maxSize:a,multiple:l,maxFiles:c,validator:A}),me=Z>0&&!se;B({isDragAccept:se,isDragReject:me,isDragActive:!0,type:"setDraggedFiles"}),d&&d(D)}}).catch(function(E){return ae(E)})},[o,d,ae,b,k,i,a,l,c,A]),P=g.useCallback(function(D){D.preventDefault(),D.persist(),ve(D);var E=It(D);if(E&&D.dataTransfer)try{D.dataTransfer.dropEffect="copy"}catch{}return E&&f&&f(D),!1},[f,b]),fe=g.useCallback(function(D){D.preventDefault(),D.persist(),ve(D);var E=K.current.filter(function(se){return R.current&&R.current.contains(se)}),Z=E.indexOf(D.target);Z!==-1&&E.splice(Z,1),K.current=E,!(E.length>0)&&(B({type:"setDraggedFiles",isDragActive:!1,isDragAccept:!1,isDragReject:!1}),It(D)&&x&&x(D))},[R,x,b]),te=g.useCallback(function(D,E){var Z=[],se=[];D.forEach(function(me){var ke=Ks(me,k),Ce=en(ke,2),Ke=Ce[0],Ge=Ce[1],Me=Gs(me,i,a),Ze=en(Me,2),at=Ze[0],it=Ze[1],ct=A?A(me):null;if(Ke&&at&&!ct)Z.push(me);else{var lt=[Ge,it];ct&&(lt=lt.concat(ct)),se.push({file:me,errors:lt.filter(function(Dt){return Dt})})}}),(!l&&Z.length>1||l&&c>=1&&Z.length>c)&&(Z.forEach(function(me){se.push({file:me,errors:[Zc]})}),Z.splice(0)),B({acceptedFiles:Z,fileRejections:se,type:"setFiles"}),m&&m(Z,se,E),se.length>0&&p&&p(se,E),Z.length>0&&y&&y(Z,E)},[B,l,k,i,a,c,m,y,p,A]),H=g.useCallback(function(D){D.preventDefault(),D.persist(),ve(D),K.current=[],It(D)&&Promise.resolve(o(D)).then(function(E){zt(D)&&!b||te(E,D)}).catch(function(E){return ae(E)}),B({type:"reset"})},[o,te,ae,b]),S=g.useCallback(function(){if(ue.current){B({type:"openDialog"}),G();var D={multiple:l,types:T};window.showOpenFilePicker(D).then(function(E){return o(E)}).then(function(E){te(E,null),B({type:"closeDialog"})}).catch(function(E){il(E)?(Y(E),B({type:"closeDialog"})):cl(E)?(ue.current=!1,z.current?(z.current.value=null,z.current.click()):ae(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."))):ae(E)});return}z.current&&(B({type:"openDialog"}),G(),z.current.value=null,z.current.click())},[B,G,Y,h,te,ae,T,l]),V=g.useCallback(function(D){!R.current||!R.current.isEqualNode(D.target)||(D.key===" "||D.key==="Enter"||D.keyCode===32||D.keyCode===13)&&(D.preventDefault(),S())},[R,S]),q=g.useCallback(function(){B({type:"focus"})},[]),ne=g.useCallback(function(){B({type:"blur"})},[]),pe=g.useCallback(function(){I||(rl()?setTimeout(S,0):S())},[I,S]),ce=function(E){return s?null:E},ye=function(E){return O?null:ce(E)},ge=function(E){return _?null:ce(E)},ve=function(E){b&&E.stopPropagation()},re=g.useMemo(function(){return function(){var D=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},E=D.refKey,Z=E===void 0?"ref":E,se=D.role,me=D.onKeyDown,ke=D.onFocus,Ce=D.onBlur,Ke=D.onClick,Ge=D.onDragEnter,Me=D.onDragOver,Ze=D.onDragLeave,at=D.onDrop,it=Lt(D,ul);return J(J(pn({onKeyDown:ye(Ne(me,V)),onFocus:ye(Ne(ke,q)),onBlur:ye(Ne(Ce,ne)),onClick:ce(Ne(Ke,pe)),onDragEnter:ge(Ne(Ge,ee)),onDragOver:ge(Ne(Me,P)),onDragLeave:ge(Ne(Ze,fe)),onDrop:ge(Ne(at,H)),role:typeof se=="string"&&se!==""?se:"presentation"},Z,R),!s&&!O?{tabIndex:0}:{}),it)}},[R,V,q,ne,pe,ee,P,fe,H,O,_,s]),Fe=g.useCallback(function(D){D.stopPropagation()},[]),ot=g.useMemo(function(){return function(){var D=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},E=D.refKey,Z=E===void 0?"ref":E,se=D.onChange,me=D.onClick,ke=Lt(D,fl),Ce=pn({accept:k,multiple:l,type:"file",style:{display:"none"},onChange:ce(Ne(se,H)),onClick:ce(Ne(me,Fe)),tabIndex:-1},Z,z);return J(J({},Ce),ke)}},[z,n,l,H,s]);return J(J({},M),{},{isFocused:he&&!s,getRootProps:re,getInputProps:ot,rootRef:R,inputRef:z,open:ce(S)})}function bl(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({},gn),{},{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({},gn);default:return e}}function xr(){}const[Cl,Dl]=Kr("Dropzone component was not found in tree");var yr=Object.getOwnPropertySymbols,Sl=Object.prototype.hasOwnProperty,wl=Object.prototype.propertyIsEnumerable,_l=(e,t)=>{var n={};for(var s in e)Sl.call(e,s)&&t.indexOf(s)<0&&(n[s]=e[s]);if(e!=null&&yr)for(var s of yr(e))t.indexOf(s)<0&&wl.call(e,s)&&(n[s]=e[s]);return n};function _n(e){const t=n=>{const s=Ue(`Dropzone${qn(e)}`,{},n),{children:o}=s,a=_l(s,["children"]),i=Dl(),l=Mo(o)?o:N.createElement("span",null,o);return i[e]?g.cloneElement(l,a):null};return t.displayName=`@mantine/dropzone/${qn(e)}`,t}const Il=_n("accept"),El=_n("reject"),Ol=_n("idle");var Pl=Object.defineProperty,Al=Object.defineProperties,Nl=Object.getOwnPropertyDescriptors,vr=Object.getOwnPropertySymbols,Tl=Object.prototype.hasOwnProperty,$l=Object.prototype.propertyIsEnumerable,jr=(e,t,n)=>t in e?Pl(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,br=(e,t)=>{for(var n in t||(t={}))Tl.call(t,n)&&jr(e,n,t[n]);if(vr)for(var n of vr(t))$l.call(t,n)&&jr(e,n,t[n]);return e},Fl=(e,t)=>Al(e,Nl(t)),kl=Ve((e,{padding:t,radius:n})=>{const s=e.fn.variant({color:"red",variant:"light"}),o=e.fn.variant({color:e.primaryColor,variant:"light"});return{root:Fl(br(br({},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:we({size:t,sizes:e.spacing}),borderRadius:e.fn.radius(n),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"?o.background:e.colors[e.primaryColor][0],borderColor:e.colorScheme==="dark"?o.border:e.colors[e.primaryColor][4],"&:hover":{backgroundColor:e.colorScheme==="dark"?o.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"}}}),Rl=Object.defineProperty,Ml=Object.defineProperties,zl=Object.getOwnPropertyDescriptors,Bt=Object.getOwnPropertySymbols,Xs=Object.prototype.hasOwnProperty,Zs=Object.prototype.propertyIsEnumerable,Cr=(e,t,n)=>t in e?Rl(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,dt=(e,t)=>{for(var n in t||(t={}))Xs.call(t,n)&&Cr(e,n,t[n]);if(Bt)for(var n of Bt(t))Zs.call(t,n)&&Cr(e,n,t[n]);return e},tn=(e,t)=>Ml(e,zl(t)),Ll=(e,t)=>{var n={};for(var s in e)Xs.call(e,s)&&t.indexOf(s)<0&&(n[s]=e[s]);if(e!=null&&Bt)for(var s of Bt(e))t.indexOf(s)<0&&Zs.call(e,s)&&(n[s]=e[s]);return n};const Bl={padding:"md",loading:!1,multiple:!0,maxSize:1/0,autoFocus:!1,activateOnClick:!0,activateOnDrag:!0,dragEventsBubbling:!0,activateOnKeyboard:!0,useFsAccessApi:!0};function st(e){const t=Ue("Dropzone",Bl,e),{className:n,padding:s,radius:o,disabled:a,classNames:i,styles:l,loading:c,multiple:d,maxSize:x,accept:f,children:m,onDropAny:y,onDrop:p,onReject:u,openRef:v,name:h,unstyled:j,maxFiles:C,autoFocus:I,activateOnClick:O,activateOnDrag:_,dragEventsBubbling:b,activateOnKeyboard:w,onDragEnter:A,onDragLeave:k,onDragOver:T,onFileDialogCancel:G,onFileDialogOpen:Y,preventDropOnDocument:R,useFsAccessApi:z,getFilesFromEvent:le,validator:ie,variant:M}=t,B=Ll(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:he,cx:de}=kl({radius:o,padding:s},{name:"Dropzone",classNames:i,styles:l,unstyled:j,variant:M}),{getRootProps:ue,getInputProps:be,isDragAccept:K,isDragReject:xe,open:ae}=Js(dt({onDrop:y,onDropAccepted:p,onDropRejected:u,disabled:a||c,accept:Array.isArray(f)?f.reduce((P,fe)=>tn(dt({},P),{[fe]:[]}),{}):f,multiple:d,maxSize:x,maxFiles:C,autoFocus:I,noClick:!O,noDrag:!_,noDragEventsBubbling:!b,noKeyboard:!w,onDragEnter:A,onDragLeave:k,onDragOver:T,onFileDialogCancel:G,onFileDialogOpen:Y,preventDropOnDocument:R,useFsAccessApi:z,validator:ie},le?{getFilesFromEvent:le}:null));Br(v,ae);const ee=!K&&!xe;return N.createElement(Cl,{value:{accept:K,reject:xe,idle:ee}},N.createElement(He,tn(dt(dt({},B),ue()),{"data-accept":K||void 0,"data-reject":xe||void 0,"data-idle":ee||void 0,"data-loading":c||void 0,className:de(he.root,n)}),N.createElement(ks,{visible:c,radius:o,unstyled:j}),N.createElement("input",tn(dt({},be()),{name:h})),N.createElement("div",{className:he.inner},m)))}st.displayName="@mantine/dropzone/Dropzone";st.Accept=Il;st.Reject=El;st.Idle=Ol;const eo=st;var Vl=Object.defineProperty,Ul=Object.defineProperties,Hl=Object.getOwnPropertyDescriptors,Dr=Object.getOwnPropertySymbols,Kl=Object.prototype.hasOwnProperty,Gl=Object.prototype.propertyIsEnumerable,Sr=(e,t,n)=>t in e?Vl(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,ql=(e,t)=>{for(var n in t||(t={}))Kl.call(t,n)&&Sr(e,n,t[n]);if(Dr)for(var n of Dr(t))Gl.call(t,n)&&Sr(e,n,t[n]);return e},Wl=(e,t)=>Ul(e,Hl(t)),Yl=Ve(e=>({wrapper:Wl(ql({},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}})),Ql=Object.defineProperty,Jl=Object.defineProperties,Xl=Object.getOwnPropertyDescriptors,Vt=Object.getOwnPropertySymbols,to=Object.prototype.hasOwnProperty,no=Object.prototype.propertyIsEnumerable,wr=(e,t,n)=>t in e?Ql(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,nn=(e,t)=>{for(var n in t||(t={}))to.call(t,n)&&wr(e,n,t[n]);if(Vt)for(var n of Vt(t))no.call(t,n)&&wr(e,n,t[n]);return e},rn=(e,t)=>Jl(e,Xl(t)),Zl=(e,t)=>{var n={};for(var s in e)to.call(e,s)&&t.indexOf(s)<0&&(n[s]=e[s]);if(e!=null&&Vt)for(var s of Vt(e))t.indexOf(s)<0&&no.call(e,s)&&(n[s]=e[s]);return n};const ed={padding:"md",loading:!1,multiple:!0,maxSize:1/0,autoFocus:!1,activateOnClick:!0,activateOnDrag:!0,dragEventsBubbling:!0,activateOnKeyboard:!0,active:!0,zIndex:Vr("max"),withinPortal:!0};function ro(e){const t=Ue("DropzoneFullScreen",ed,e),{classNames:n,styles:s,sx:o,className:a,style:i,unstyled:l,active:c,onDrop:d,onReject:x,zIndex:f,withinPortal:m,portalProps:y}=t,p=Zl(t,["classNames","styles","sx","className","style","unstyled","active","onDrop","onReject","zIndex","withinPortal","portalProps"]),[u,v]=N.useState(0),[h,{open:j,close:C}]=gt(!1),{classes:I,cx:O}=Yl(null,{name:"DropzoneFullScreen",classNames:n,styles:s,unstyled:l}),_=w=>{w.dataTransfer.types.includes("Files")&&(v(A=>A+1),j())},b=()=>{v(w=>w-1)};return g.useEffect(()=>{u===0&&C()},[u]),g.useEffect(()=>{if(c)return document.addEventListener("dragenter",_,!1),document.addEventListener("dragleave",b,!1),()=>{document.removeEventListener("dragenter",_,!1),document.removeEventListener("dragleave",b,!1)}},[c]),N.createElement(zo,rn(nn({},y),{withinPortal:m}),N.createElement(He,{className:O(I.wrapper,a),sx:o,style:rn(nn({},i),{opacity:h?1:0,pointerEvents:h?"all":"none",zIndex:f})},N.createElement(st,rn(nn({},p),{classNames:n,styles:s,unstyled:l,className:I.dropzone,onDrop:w=>{d?.(w),C()},onReject:w=>{x?.(w),C()}}))))}ro.displayName="@mantine/dropzone/DropzoneFullScreen";eo.FullScreen=ro;const td=eo,nd=({children:e,chargeId:t})=>{const{uploading:n,uploadMultipleDocuments:s}=Lo();function o(a){F.error("Error",{description:a,duration:5e3})}return r.jsx(td,{onDrop:a=>s({documents:a,chargeId:t,isSensitive:!1}),onReject:a=>o(`Rejected Files:
61
61
  ${a.map(i=>`"${i.file.name}": ${i.errors}`).join(`
62
- `)}`),activateOnClick:!1,activateOnKeyboard:!1,radius:0,padding:0,maxFiles:1/0,loading:n,sx:()=>({border:0,cursor:"default",width:"100%",height:"100%",zIndex:1}),children:e})},so=({items:e,extraClassName:t=""})=>{const n=["text-sm font-medium text-gray-900 bg-white border border-gray-200 rounded-lg",t].join(" ");return r.jsx("ul",{className:n,children:e.map((s,o)=>{const a=["w-full px-4 py-2",o===e.length-1?"rounded-b-lg":"border-b",o===0?"rounded-t-lg":"","border-gray-200",s&&typeof s=="object"&&"extraClassName"in s?s.extraClassName??"":""].join(" ");return r.jsx("li",{className:a,children:s&&typeof s=="object"&&"content"in s?s.content:s},o)})})},rd=({onDone:e,data:t})=>{const[n,s]=g.useState(!1);function o(){s(!1),e?.()}return r.jsxs(yn,{open:n,onOpenChange:s,children:[r.jsx(Bo,{asChild:!0,children:r.jsx(Le,{label:"Edit Misc Expense",children:r.jsx(X,{variant:"ghost",size:"icon",className:"size-7.5",children:r.jsx(Gr,{className:"size-5"})})})}),r.jsx(vn,{className:"sm:max-w-[425px]",children:r.jsx(Dc,{onDone:o,data:t})})]})},sd="batchUpdateCharges",od=()=>{const[{fetching:e},t]=Pe(Vo),n=g.useCallback(async s=>{const o=Array.isArray(s.chargeIds)?s.chargeIds:[s.chargeIds],a=`Error updating charge IDs [${o.join(", ")}]`,i=`${sd}-${o[0]}`;F.loading("Updating charge",{id:i});try{const l=await t(s),c=Ae(l,a,i,"batchUpdateCharges");if(c)return F.success("Success",{id:i,description:`${o.length} charge${o.length>1?"s":""} updated`}),c.batchUpdateCharges.charges}catch(l){console.error(`${a}: ${l}`),F.error("Error",{id:i,description:a,duration:1e5,closeButton:!0})}},[t]);return{fetching:e,batchUpdateCharges:n}},ad=[{id:"select",header:({table:e})=>r.jsx(Ln,{checked:e.getIsAllPageRowsSelected()||e.getIsSomePageRowsSelected()&&"indeterminate",onCheckedChange:t=>e.toggleAllPageRowsSelected(!!t),"aria-label":"Select all"}),cell:({row:e})=>r.jsx(Ln,{checked:e.getIsSelected(),onCheckedChange:t=>e.toggleSelected(!!t),"aria-label":"Select row"}),enableSorting:!1,enableHiding:!1},{accessorKey:"chargeType",header:"Type",cell:({row:e})=>r.jsx("div",{children:e.getValue("chargeType")})},{accessorKey:"counterpartyName",header:"Counterparty",cell:({row:e})=>r.jsx("div",{children:e.getValue("counterpartyName")})},{accessorKey:"date",header:"Date",cell:({row:e})=>{const t=e.getValue("date");return r.jsx("div",{children:t?Be(new Date(t),"yyyy-MM-dd"):"Missing"})}},{accessorKey:"amountRaw",header:"Amount",cell:({row:e})=>r.jsx("div",{children:e.original.amountFormatted})},{accessorKey:"vatAmountRaw",header:"VAT Amount",cell:({row:e})=>r.jsx("div",{children:e.original.vatAmountFormatted})},{accessorKey:"description",header:"Description",cell:({row:e})=>r.jsx("div",{children:e.getValue("description")})},{accessorKey:"taxCategoryName",header:"Tax Category",cell:({row:e})=>r.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?r.jsx("div",{children:"No tags"}):r.jsx("div",{children:t.join(" | ")})}},{accessorKey:"businessTripName",header:"Business Trip",cell:({row:e})=>r.jsx("div",{children:e.getValue("businessTripName")})},{accessorKey:"moreInfo",header:"More Info",cell:({row:e})=>{const t=e.original.transactions||0,n=e.original.documents||0,s=e.original.miscExpenses||0,o=e.original.ledgerRecords||0;return r.jsxs("div",{className:"flex flex-col justify-center text-sm",children:[t>0&&r.jsxs("div",{children:["Transactions: ",t]}),n>0&&r.jsxs("div",{children:["Documents: ",n]}),s>0&&r.jsxs("div",{children:["Misc Expenses: ",s]}),o>0&&r.jsxs("div",{children:["Ledger Records: ",o]})]})},enableSorting:!1}];function id({data:e,tagIds:t,description:n,onOpenChange:s,title:o="Similar Charges"}){const[a,i]=T.useState([]),[l,c]=T.useState({}),d=g.useMemo(()=>e.map(p=>L(Uo,p)),[e]),x=g.useMemo(()=>d.map(u=>({id:u.id,chargeType:Ss(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(v=>v.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]);g.useEffect(()=>{e&&x.length===0&&s(!1)},[e,x.length,s]);const f=qr({data:x,columns:ad,onSortingChange:i,getCoreRowModel:Yr(),getSortedRowModel:Wr(),onRowSelectionChange:c,state:{sorting:a,rowSelection:l}}),{batchUpdateCharges:m}=od(),y=g.useCallback(async()=>{const p=f.getSelectedRowModel().rows.map(u=>u.original.id);await m({chargeIds:p,fields:{...t?{tags:t}:{},...n?{userDescription:n}:{}}}),s(!1)},[m,s,f,t,n]);return g.useEffect(()=>{e.length===0&&s(!1)},[e.length,s]),e.length?r.jsxs(r.Fragment,{children:[r.jsxs(Ho,{className:"flex flex-row items-center justify-between",children:[r.jsx(Ko,{children:o}),r.jsx(X,{onClick:y,children:"Approve selected"})]}),r.jsx(Xr,{children:r.jsxs(jn,{children:[r.jsx(bn,{children:f.getHeaderGroups().map(p=>r.jsx(Ye,{children:p.headers.map(u=>r.jsx(Ne,{children:u.isPlaceholder?null:Pt(u.column.columnDef.header,u.getContext())},u.id))},p.id))}),r.jsx(Cn,{children:f.getRowModel().rows.map(p=>r.jsx(Ye,{"data-state":p.getIsSelected()&&"selected",children:p.getVisibleCells().map(u=>r.jsx(Ie,{children:Pt(u.column.columnDef.cell,u.getContext())},u.id))},p.id))})]})})]}):null}function oo({chargeId:e,tagIds:t,description:n,open:s,onOpenChange:o,onClose:a,showChargesWithExistingSuggestions:i=!1}){const[{data:l,fetching:c},d]=Qe({pause:!0,query:Go,variables:{chargeId:e,withMissingTags:i?!1:!!t,withMissingDescription:i?!1:!!n,tagsDifferentThan:i&&t?t.map(m=>m.id):void 0,descriptionDifferentThan:i?n:void 0}});g.useEffect(()=>{s&&(t||n)&&!l&&d()},[s,t,n,d,l]);const x=g.useCallback(m=>{o(m),s&&!m&&a?.()},[o,a,s]);g.useEffect(()=>{s&&!c&&l?.similarCharges.length===0&&a?.()},[s,c,l,a]);const f=g.useMemo(()=>s&&(!!t||!!n)&&l&&l?.similarCharges.length>0,[s,t,n,l]);return r.jsx(yn,{open:f,onOpenChange:x,children:r.jsx(vn,{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:r.jsx(qo,{fallback:r.jsx("div",{children:"Error fetching similar charges"}),children:c?r.jsx(Wo,{}):t||n?r.jsx(id,{data:l?.similarCharges??[],tagIds:t,description:n,onOpenChange:x}):null})})})}const cd="updateChargeAccountantApproval",ld=()=>{const[{fetching:e},t]=Pe(Yo),n=g.useCallback(async s=>{const o=`Error toggling accountant approval to ledger record ID [${s.chargeId}]`,a=`${cd}-${s.chargeId}`;F.loading("Updating approval status",{id:a});try{const i=await t(s),l=Ae(i,o,a,"updateChargeAccountantApproval");if(l)return F.success("Success",{id:a,description:"Accountant approval was updated"}),l.updateChargeAccountantApproval}catch(i){console.error(`${o}: ${i}`),F.error("Error",{id:a,description:o,duration:1e5,closeButton:!0})}},[t]);return{fetching:e,updateChargeAccountantApproval:n}};function dd({data:e,onChange:t}){const n=L(Jo,e),[s,o]=g.useState(n.accountantApproval),{updateChargeAccountantApproval:a}=ld();return g.useEffect(()=>{s==null&&n.accountantApproval!=null&&o(n.accountantApproval)},[s,n.accountantApproval]),r.jsx("td",{children:r.jsx(Xo,{value:s,onChange:i=>a({chargeId:n.id,status:i}).then(t)})})}const ud=({data:e})=>{const t=L(Qo,e),[n,s]=g.useState(!0),[o,a]=g.useState(!0),i="validCreditCardAmount"in t?t.validCreditCardAmount:null;return g.useEffect(()=>{t.__typename==="CreditcardBankCharge"&&(a(i==null),i!=null&&s(i))},[t.__typename,i]),r.jsx("td",{children:r.jsx("div",{children:r.jsx(Re,{inline:!0,size:12,disabled:n,processing:o,color:"red",zIndex:"auto",children:r.jsx("p",{className:(t.totalAmount?.raw??0)>0?"whitespace-nowrap text-green-700":"whitespace-nowrap text-red-500",children:t.totalAmount?.formatted})})})})},fd=({data:e})=>{const t=L(Jr,e);return"businessTrip"in t?r.jsx("td",{children:r.jsx(At,{to:t.businessTrip?.id?mt.BUSINESS_TRIPS.DETAIL(t.businessTrip?.id):mt.BUSINESS_TRIPS.ROOT,target:"_blank",rel:"noreferrer",onClick:n=>n.stopPropagation(),className:"inline-flex items-center font-semibold",children:t.businessTrip?.name})}):r.jsx("td",{})},pd=({data:e})=>{const{counterparty:t,validationData:n,__typename:s}=L(Qr,e),o=g.useMemo(()=>{switch(s){case"BusinessTripCharge":case"DividendCharge":case"ConversionCharge":case"SalaryCharge":case"InternalTransferCharge":return!1;default:return!0}},[s]),a=g.useMemo(()=>o&&n?.missingInfo?.includes(ze.Counterparty),[o,n?.missingInfo]),{name:i,id:l}=t??{name:"Missing",id:void 0};return r.jsx("td",{children:r.jsx("div",{className:"flex flex-wrap",children:r.jsxs(Re,{inline:!0,size:12,disabled:!a,color:"red",zIndex:"auto",children:[!a&&l&&r.jsx(At,{to:mt.BUSINESSES.DETAIL(l),target:"_blank",rel:"noreferrer",onClick:c=>c.stopPropagation(),className:"inline-flex items-center font-semibold",children:i}),a&&i]})})})},gd=({data:e})=>{const t=L(Zo,e),{minDebitDate:n,minEventDate:s,minDocumentsDate:o}=t,a=n||s||o;return r.jsx("td",{children:r.jsx("div",{children:a&&Be(new Date(a),"dd/MM/yy")})})},md=({data:e,onChange:t})=>{const[n,s]=g.useState(!1),o=L(ea,e),a=g.useMemo(()=>o?.validationData?.missingInfo?.includes(ze.Description),[o?.validationData?.missingInfo]),i=g.useMemo(()=>a&&!!o.missingInfoSuggestions?.description?.trim().length,[a,o.missingInfoSuggestions?.description]),{userDescription:l,id:c}=o,d=g.useMemo(()=>l&&l?.trim()!==""?l:o.missingInfoSuggestions?.description?o.missingInfoSuggestions.description:"Missing",[l,o.missingInfoSuggestions?.description]),{updateCharge:x,fetching:f}=Ls(),m=g.useCallback(async y=>{y!==void 0&&(await x({chargeId:c,fields:{userDescription:y}}),s(!0))},[c,x]);return r.jsxs("td",{children:[r.jsxs("div",{className:"flex flex-wrap",children:[r.jsx("div",{className:"flex flex-col justify-center",children:r.jsx(Re,{inline:!0,size:12,disabled:!a,color:"red",zIndex:"auto",children:r.jsx("p",{className:i?"bg-yellow-400":void 0,children:d})})}),i&&r.jsx(Zr,{onClick:y=>{y.stopPropagation(),m(o.missingInfoSuggestions.description)},disabled:f})]}),r.jsx(oo,{chargeId:c,description:o.missingInfoSuggestions?.description??void 0,open:n,onOpenChange:s,onClose:t})]})},hd=({data:e})=>{const t=L(ta,e),{metadata:n,validationData:s,id:o,__typename:a}=t,i=g.useMemo(()=>{switch(a){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}},[a]),l=g.useMemo(()=>{switch(a){case"FinancialCharge":return!1;default:return!0}},[a]),c=g.useMemo(()=>l&&s?.missingInfo?.includes(ze.Transactions),[l,s?.missingInfo]),d=g.useMemo(()=>i&&s?.missingInfo?.includes(ze.Documents),[i,s?.missingInfo]),x=g.useMemo(()=>!n?.invalidLedger,[n?.invalidLedger]),f=g.useMemo(()=>n?.invalidLedger,[n?.invalidLedger]),m=g.useMemo(()=>{const y=[];return(c||n?.transactionsCount||l)&&y.push({extraClassName:n?.transactionsCount||!l?void 0:"bg-yellow-400",content:r.jsx(Re,{inline:!0,size:12,disabled:!c,color:"red",zIndex:"auto",children:r.jsxs("div",{className:"whitespace-nowrap",children:["Transactions: ",n?.transactionsCount??0]})},"transactions")}),y.push({content:r.jsx(Re,{inline:!0,size:12,processing:x,disabled:f==="VALID",color:f==="DIFF"?"orange":"red",zIndex:"auto",children:r.jsxs("div",{className:"whitespace-nowrap",children:["Ledger Records: ",n?.ledgerCount??0]})},"ledger")}),(d||n?.documentsCount)&&y.push({content:r.jsx(Re,{inline:!0,size:12,disabled:!d,color:"red",zIndex:"auto",children:r.jsxs("div",{className:"whitespace-nowrap",children:["Documents: ",n?.documentsCount??0]})},"documents"),extraClassName:!s?.missingInfo?.includes(ze.Documents)||!i?void 0:"bg-yellow-400"}),n?.miscExpensesCount&&y.push({content:r.jsxs("div",{className:"whitespace-nowrap",children:["Misc Expenses: ",n?.miscExpensesCount??0]})}),y},[n?.transactionsCount,n?.ledgerCount,n?.documentsCount,n?.miscExpensesCount,i,l,c,d,s?.missingInfo,f,x]);return r.jsx("td",{children:r.jsx(nd,{chargeId:o,children:r.jsx(so,{items:m})})})},xd=({data:e,onChange:t})=>{const{tags:n,id:s,validationData:o,missingInfoSuggestions:a}=L(es,e),{updateCharge:i,fetching:l}=Ls(),[c,d]=g.useState(n??[]),[x,f]=g.useState(!1),m=o?.missingInfo?.includes(ze.Tags),y=m&&!!a?.tags?.length;g.useEffect(()=>{n?.length&&!c.length&&d(n)},[n,c.length]),g.useEffect(()=>{c.length===0&&y&&d(a?.tags??[])},[c.length,y,a?.tags]);const p=g.useCallback(async u=>{await i({chargeId:s,fields:{tags:u?.map(v=>({id:v.id}))}}),f(!0)},[s,i]);return r.jsxs("td",{children:[r.jsx(Re,{inline:!0,size:12,disabled:!m,color:"red",zIndex:"auto",children:r.jsx(so,{items:c.map(u=>r.jsx(an,{children:r.jsxs("div",{children:[u.namePath&&r.jsx(Xe,{size:"xs",opacity:.65,children:`${u.namePath.join(" > ")} >`}),r.jsx(Xe,{size:"sm",children:u.name})]})},u.id)),extraClassName:y?"bg-yellow-400":void 0})}),y&&r.jsx(Zr,{onClick:u=>{u.stopPropagation(),p(a.tags)},disabled:l}),r.jsx(oo,{chargeId:s,tagIds:a?.tags?.map(u=>({id:u.id})),open:x,onOpenChange:f,onClose:t})]})},yd=({data:e})=>{const{validationData:t,taxCategory:n,__typename:s}=L(ts,e),o=g.useMemo(()=>{switch(s){case"DividendCharge":case"InternalTransferCharge":case"SalaryCharge":case"BankDepositCharge":case"ForeignSecuritiesCharge":return!1;default:return!0}},[s]),a=g.useMemo(()=>t?.missingInfo?.includes(ze.TaxCategory),[t?.missingInfo]);return o?r.jsx("td",{children:r.jsx(Re,{inline:!0,size:12,disabled:!a,color:"red",zIndex:"auto",children:n?.name??"N/A"})}):r.jsx("td",{})},vd=({data:e})=>{const t=L(na,e),{__typename:n}=t,{text:s,icon:o}=g.useMemo(()=>({text:Ss(n),icon:pi(n)}),[n]);return r.jsxs("td",{children:[r.jsx("div",{children:s}),r.jsx(zs,{radius:"xl",size:"xl",children:o})]})},jd=({data:e})=>{const{vat:t,totalAmount:n,validationData:s,__typename:o}=L(ra,e),a=g.useMemo(()=>s?.missingInfo?.includes(ze.Vat),[s?.missingInfo]),i=g.useMemo(()=>!t&&n?.currency===Dn.Ils,[t,n?.currency]),l=g.useMemo(()=>(t?.raw??0)>0&&(n?.raw??0)<0||(t?.raw??0)<0&&(n?.raw??0)>0,[t?.raw,n?.raw]),c=i||l;return g.useMemo(()=>{switch(o){case"BusinessTripCharge":case"DividendCharge":case"ConversionCharge":case"SalaryCharge":case"InternalTransferCharge":case"BankDepositCharge":case"ForeignSecuritiesCharge":case"CreditcardBankCharge":return!1;default:return!0}},[o])?r.jsx("td",{children:r.jsx("div",{className:c?"whitespace-nowrap text-red-500":"whitespace-nowrap text-green-700",children:r.jsx(Re,{inline:!0,size:12,disabled:!a,color:"red",zIndex:"auto",children:t?.formatted})})}):r.jsx("td",{})},bd="insertDepreciationRecord",Cd=()=>{const[{fetching:e},t]=Pe(sa),n=g.useCallback(async s=>{const o="Error adding depreciation record",a=bd;F.loading("Adding depreciation record",{id:a});try{const i=await t(s),l=Ae(i,o,a,"insertDepreciationRecord");if(l)return F.success("Success",{id:a,description:"Depreciation record was added"}),l.insertDepreciationRecord}catch(i){console.error(`${o}: ${i}`),F.error("Error",{id:a,description:o,duration:1e5,closeButton:!0})}},[t]);return{fetching:e,addDepreciationRecord:n}};function _r(e){const{chargeId:t,onAdd:n}=e,[s,{close:o,open:a}]=gt(!1);return r.jsxs(r.Fragment,{children:[r.jsx(Le,{label:"Add Depreciation Record",children:r.jsx(X,{variant:"outline",size:"icon",className:"size-7.5",onClick:i=>{i.stopPropagation(),a()},children:r.jsx(ns,{className:"size-5"})})}),s&&r.jsx(Dd,{chargeId:t,opened:s,close:o,onAdd:n})]})}function Dd({chargeId:e,opened:t,close:n,onAdd:s}){const{control:o,handleSubmit:a}=xn({defaultValues:{chargeId:e}}),[i,l]=g.useState(!1),[{data:c,fetching:d}]=Qe({query:rs}),{addDepreciationRecord:x,fetching:f}=Cd(),m=p=>{x({fields:p}).then(()=>{s?.(),n()})},y=c?.depreciationCategories?.map(p=>({value:p.id,label:p.name}))??[];return g.useEffect(()=>{l(!!(d||f))},[d,f]),r.jsxs(ft,{opened:t,onClose:n,centered:!0,lockScroll:!0,children:[r.jsx(ft.Title,{children:"Add Depreciation Record"}),r.jsx(ft.Body,{children:r.jsxs("form",{onSubmit:a(m),children:[r.jsx($e,{name:"activationDate",control:o,rules:{pattern:{value:ss,message:"Date must be im format yyyy-mm-dd"}},render:({field:{value:p,...u}})=>{const v=p?new Date(p):void 0;return r.jsx(os,{...u,onChange:h=>{const j=h?typeof h=="string"?h:Be(h,"yyyy-MM-dd"):void 0;j!==p&&u.onChange(j)},value:v,label:"Activation Date",popoverProps:{withinPortal:!0}})}}),r.jsx($e,{name:"amount",control:o,render:({field:p,fieldState:u})=>r.jsx($e,{name:"currency",control:o,render:({field:v,fieldState:h})=>r.jsx(as,{...p,value:p.value??void 0,error:u.error?.message||h.error?.message,label:"Amount",currencyCodeProps:{...v,label:"Currency"}})})}),r.jsx($e,{name:"categoryId",control:o,render:({field:p,fieldState:u})=>r.jsx(Tt,{...p,disabled:d,data:y,label:"Category",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:u.error?.message,withinPortal:!0})}),r.jsx($e,{name:"type",control:o,render:({field:p,fieldState:u})=>r.jsx(Tt,{...p,data:ao,value:p.value,label:"Type",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:u.error?.message,withinPortal:!0})}),r.jsx("div",{className:"flex justify-center mt-5 gap-3",children:r.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"})})]})}),(f||i)&&r.jsx(Ur,{blur:1,center:!0,children:r.jsx(jt,{})})]})}const Sd="updateDepreciationRecord",wd=()=>{const[{fetching:e},t]=Pe(oa),n=g.useCallback(async s=>{const o="Error updating depreciation record",a=Sd;F.loading("Updating depreciation record",{id:a});try{const i=await t(s),l=Ae(i,o,a,"updateDepreciationRecord");if(l)return F.success("Success",{id:a,description:"Depreciation record was updated"}),l.updateDepreciationRecord}catch(i){console.error(`${o}: ${i}`),F.error("Error",{id:a,description:o,duration:1e5,closeButton:!0})}},[t]);return{fetching:e,updateDepreciationRecord:n}},_d="deleteDepreciationRecord",Id=()=>{const[{fetching:e},t]=Pe(aa),n=g.useCallback(async s=>{const o="Error deleting depreciation record",a=`${_d}-${s.depreciationRecordId}`;F.loading("Deleting depreciation record",{id:a});try{const i=await t(s),l=Ae(i,o,a);if(l)return F.success("Success",{id:a,description:"Depreciation record was deleted"}),l.deleteDepreciationRecord}catch(i){console.error(`${o}: ${i}`),F.error("Error",{id:a,description:o,duration:1e5,closeButton:!0})}},[t]);return{fetching:e,deleteDepreciationRecord:n}};function Ed(e){const{fetching:t,deleteDepreciationRecord:n}=Id(),s=g.useCallback(()=>{n({depreciationRecordId:e.depreciationRecordId}).then(()=>{e.onDelete?.()})},[e,n]);return r.jsx(Gt,{onConfirm:s,title:"Are you sure you want to delete the depreciation record?",children:r.jsx(Le,{label:"Remove Depreciation",children:r.jsx(X,{variant:"outline",size:"icon",className:"size-7.5 text-red-500",disabled:t,children:r.jsx(Sn,{className:"size-5"})})})})}const Od=({data:e,onChange:t})=>{const n=L(ca,e),[s,o]=g.useState(!1),[{data:a,fetching:i},l]=Qe({query:rs,pause:!0}),{control:c,handleSubmit:d,formState:{dirtyFields:x}}=xn({defaultValues:{id:n.id}}),{updateDepreciationRecord:f,fetching:m}=wd(),y=u=>{const v=la(u,x);v&&Object.keys(v).length>0&&f({fields:{...u,id:n.id}}).then(()=>{t?.(),o(!1)})},p=a?.depreciationCategories.map(u=>({value:u.id,label:u.name}));return g.useEffect(()=>{s&&!a&&l()},[s,a,l]),r.jsxs("tr",{children:[r.jsx("td",{children:r.jsx("form",{id:`form ${n.id}`,onSubmit:d(y),children:s?r.jsx($e,{name:"amount",control:c,render:({field:u,fieldState:v})=>r.jsx($e,{name:"currency",control:c,render:({field:h,fieldState:j})=>r.jsx(as,{...u,defaultValue:n.amount?.raw??n.charge.totalAmount?.raw,value:u.value??void 0,error:v.error?.message||j.error?.message,label:"Amount",currencyCodeProps:{...h,label:"Currency",defaultValue:n.amount?.currency??n.charge.totalAmount?.currency}})})}):r.jsx("div",{children:n.amount?.formatted??n.charge.totalAmount?.formatted})})}),r.jsx("td",{children:r.jsx("div",{className:"flex flex-col gap-2 justify-center",children:s?r.jsx($e,{name:"activationDate",control:c,defaultValue:n.activationDate,rules:{pattern:{value:ss,message:"Date must be im format yyyy-mm-dd"}},render:({field:{value:u,...v},fieldState:h})=>{const j=u?new Date(u):void 0;return r.jsx(os,{...v,form:`form ${n.id}`,onChange:C=>{const I=C?typeof C=="string"?C:Be(C,"yyyy-MM-dd"):void 0;I!==u&&v.onChange(I)},value:j,label:"Activation Date",error:h.error?.message,popoverProps:{withinPortal:!0}})}}):r.jsx("div",{children:Be(new Date(n.activationDate),"dd/MM/yy")})})}),r.jsx("td",{children:s?r.jsx($e,{name:"categoryId",control:c,render:({field:u,fieldState:v})=>r.jsx(Tt,{...u,form:`form ${n.id}`,disabled:i,data:p??[],label:"Category",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:v.error?.message,withinPortal:!0})}):r.jsxs("div",{children:[n.category.name," (",n.category.percentage,"%)"]})}),r.jsx("td",{children:s?r.jsx($e,{name:"type",control:c,render:({field:u,fieldState:v})=>r.jsx(Tt,{...u,form:`form ${n.id}`,data:ao,value:u.value,label:"Type",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:v.error?.message,withinPortal:!0})}):r.jsx("div",{children:n.type})}),r.jsxs("td",{children:[r.jsx(Le,{label:"Edit",children:r.jsx(X,{disabled:m||i,variant:s?"default":"outline",size:"icon",className:"size-7.5",onClick:u=>{u.stopPropagation(),o(v=>!v)},children:r.jsx(Gr,{className:"size-5"})})}),s&&r.jsx(Le,{label:"Confirm Changes",children:r.jsx(X,{type:"submit",form:`form ${n.id}`,variant:"outline",size:"icon",className:"size-7.5 text-green-500",children:r.jsx(ia,{className:"size-5"})})}),r.jsx(Ed,{depreciationRecordId:n.id,onDelete:t})]})]},n.id)},Pd=({chargeId:e,onChange:t})=>{const[{data:n,fetching:s}]=Qe({query:da,variables:{chargeId:e}});return!s&&!n?.depreciationRecordsByCharge.length?r.jsx(_r,{chargeId:e,onAdd:t}):s?r.jsx(is,{className:"h-10 w-10 animate-spin mr-2 self-center"}):r.jsx("div",{className:"flex flex-col gap-2 mt-5",children:r.jsxs(Cs,{highlightOnHover:!0,withBorder:!0,children:[r.jsx("thead",{children:r.jsxs("tr",{children:[r.jsx("th",{children:"Amount"}),r.jsx("th",{children:"Activation Date"}),r.jsx("th",{children:"Category"}),r.jsx("th",{children:"Type"}),r.jsx("th",{})]})}),r.jsxs("tbody",{children:[n?.depreciationRecordsByCharge.map(o=>r.jsx(Od,{data:o,onChange:t},o.id)),r.jsx("tr",{children:r.jsx("td",{colSpan:5,children:r.jsx(_r,{chargeId:e,onAdd:t})})})]})]})})},ao=Object.entries(ua).map(([e,t])=>({value:t,label:e}));function Ad({chargeId:e,chargeType:t,setInsertDocument:n,setMatchDocuments:s,onChange:o,isIncome:a}){const{deleteCharge:i}=mc(),[l,c]=g.useState(!1),[d,{open:x,close:f}]=gt(!1),[m,y]=g.useState(!1),[p,{open:u,close:v}]=gt(!1),[h,j]=g.useState(!1),[C,I]=g.useState(!1);function O(){i({chargeId:e}),o?.()}function _(){c(!1)}return r.jsxs(r.Fragment,{children:[r.jsxs(oe,{shadow:"md",width:200,opened:l,children:[r.jsx(oe.Target,{children:r.jsx(Ua,{opened:l,onClick:b=>{b.stopPropagation(),c(w=>!w)}})}),r.jsxs(oe.Dropdown,{children:[r.jsx(oe.Label,{children:"Charge"}),r.jsx(Gt,{onConfirm:O,title:"Are you sure you want to delete this charge?",children:r.jsx(oe.Item,{icon:r.jsx(Sn,{size:14}),children:"Delete Charge"})}),r.jsx(oe.Divider,{}),r.jsx(oe.Label,{children:"Documents"}),n&&r.jsx(oe.Item,{icon:r.jsx(Jt,{size:14}),onClick:b=>{b.stopPropagation(),n(),_()},children:"Insert Document"}),"(",r.jsx(oe.Item,{icon:r.jsx(Gn,{size:14}),onClick:b=>{b.stopPropagation(),I(!0),_()},children:"Upload Documents"}),")",s&&r.jsx(oe.Item,{icon:r.jsx(fa,{size:14}),onClick:()=>{s(),_()},children:"Match Document"}),a&&r.jsx(oe.Item,{icon:r.jsx(Jt,{size:14}),onClick:b=>{b.stopPropagation(),j(!0),_()},children:"Issue Document"}),r.jsx(oe.Divider,{}),r.jsx(oe.Label,{children:"Misc Expenses"}),r.jsx(oe.Item,{icon:r.jsx(Jt,{size:14}),onClick:b=>{b.stopPropagation(),_(),y(!0)},children:"Add expense"}),t==="CommonCharge"&&r.jsxs(r.Fragment,{children:[r.jsx(oe.Divider,{}),r.jsx(oe.Label,{children:"Depreciation"}),r.jsx(oe.Item,{icon:r.jsx(Ga,{size:14}),onClick:b=>{b.stopPropagation(),x(),_()},children:"Depreciation"})]}),t==="SalaryCharge"&&r.jsxs(r.Fragment,{children:[r.jsx(oe.Divider,{}),r.jsx(oe.Label,{children:"Salaries"}),r.jsx(oe.Item,{icon:r.jsx(Gn,{size:14}),onClick:b=>{b.stopPropagation(),_(),u()},children:"Payroll file upload"})]})]})]}),r.jsx(ft,{withinPortal:!0,size:"xl",centered:!0,opened:d,onClose:f,title:"Depreciation",onClick:b=>b.stopPropagation(),children:r.jsx(Pd,{chargeId:e,onChange:()=>{f(),o?.()}})}),r.jsx(yn,{open:m,onOpenChange:y,children:r.jsx(vn,{className:"sm:max-w-[425px]",onClick:b=>b.stopPropagation(),children:r.jsx(Ta,{onDone:()=>{y(!1),o?.()},chargeId:e})})}),r.jsx(ft,{centered:!0,opened:p,onClose:v,title:"Upload Payroll File",onClick:b=>b.stopPropagation(),children:r.jsx(_c,{onDone:()=>{v(),o?.()},chargeId:e})}),r.jsx(pa,{open:C,onOpenChange:I,onChange:o,chargeId:e}),r.jsx(cn,{chargeId:e,open:h,setOpen:j,onDone:()=>o?.()})]})}function Td(e){return Object.prototype.toString.call(e)==="[object Object]"}function Ir(e){return Td(e)||Array.isArray(e)}function Nd(){return!!(typeof window<"u"&&window.document&&window.document.createElement)}function In(e,t){const n=Object.keys(e),s=Object.keys(t);if(n.length!==s.length)return!1;const o=JSON.stringify(Object.keys(e.breakpoints||{})),a=JSON.stringify(Object.keys(t.breakpoints||{}));return o!==a?!1:n.every(i=>{const l=e[i],c=t[i];return typeof l=="function"?`${l}`==`${c}`:!Ir(l)||!Ir(c)?l===c:In(l,c)})}function Er(e){return e.concat().sort((t,n)=>t.name>n.name?1:-1).map(t=>t.options)}function $d(e,t){if(e.length!==t.length)return!1;const n=Er(e),s=Er(t);return n.every((o,a)=>{const i=s[a];return In(o,i)})}function En(e){return typeof e=="number"}function mn(e){return typeof e=="string"}function qt(e){return typeof e=="boolean"}function Or(e){return Object.prototype.toString.call(e)==="[object Object]"}function Q(e){return Math.abs(e)}function On(e){return Math.sign(e)}function pt(e,t){return Q(e-t)}function Fd(e,t){if(e===0||t===0||Q(e)<=Q(t))return 0;const n=pt(Q(e),Q(t));return Q(n/e)}function kd(e){return Math.round(e*100)/100}function xt(e){return yt(e).map(Number)}function Ee(e){return e[Ct(e)]}function Ct(e){return Math.max(0,e.length-1)}function Pn(e,t){return t===Ct(e)}function Pr(e,t=0){return Array.from(Array(e),(n,s)=>t+s)}function yt(e){return Object.keys(e)}function io(e,t){return[e,t].reduce((n,s)=>(yt(s).forEach(o=>{const a=n[o],i=s[o],l=Or(a)&&Or(i);n[o]=l?io(a,i):i}),n),{})}function hn(e,t){return typeof t.MouseEvent<"u"&&e instanceof t.MouseEvent}function Rd(e,t){const n={start:s,center:o,end:a};function s(){return 0}function o(c){return a(c)/2}function a(c){return t-c}function i(c,d){return mn(e)?n[e](c):e(t,c,d)}return{measure:i}}function vt(){let e=[];function t(o,a,i,l={passive:!0}){let c;if("addEventListener"in o)o.addEventListener(a,i,l),c=()=>o.removeEventListener(a,i,l);else{const d=o;d.addListener(i),c=()=>d.removeListener(i)}return e.push(c),s}function n(){e=e.filter(o=>o())}const s={add:t,clear:n};return s}function Md(e,t,n,s){const o=vt(),a=1e3/60;let i=null,l=0,c=0;function d(){o.add(e,"visibilitychange",()=>{e.hidden&&p()})}function x(){y(),o.clear()}function f(v){if(!c)return;i||(i=v,n(),n());const h=v-i;for(i=v,l+=h;l>=a;)n(),l-=a;const j=l/a;s(j),c&&(c=t.requestAnimationFrame(f))}function m(){c||(c=t.requestAnimationFrame(f))}function y(){t.cancelAnimationFrame(c),i=null,l=0,c=0}function p(){i=null,l=0}return{init:d,destroy:x,start:m,stop:y,update:n,render:s}}function zd(e,t){const n=t==="rtl",s=e==="y",o=s?"y":"x",a=s?"x":"y",i=!s&&n?-1:1,l=x(),c=f();function d(p){const{height:u,width:v}=p;return s?u:v}function x(){return s?"top":n?"right":"left"}function f(){return s?"bottom":n?"left":"right"}function m(p){return p*i}return{scroll:o,cross:a,startEdge:l,endEdge:c,measureSize:d,direction:m}}function Je(e=0,t=0){const n=Q(e-t);function s(d){return d<e}function o(d){return d>t}function a(d){return s(d)||o(d)}function i(d){return a(d)?s(d)?e:t:d}function l(d){return n?d-n*Math.ceil((d-t)/n):d}return{length:n,max:t,min:e,constrain:i,reachedAny:a,reachedMax:o,reachedMin:s,removeOffset:l}}function co(e,t,n){const{constrain:s}=Je(0,e),o=e+1;let a=i(t);function i(m){return n?Q((o+m)%o):s(m)}function l(){return a}function c(m){return a=i(m),f}function d(m){return x().set(l()+m)}function x(){return co(e,l(),n)}const f={get:l,set:c,add:d,clone:x};return f}function Ld(e,t,n,s,o,a,i,l,c,d,x,f,m,y,p,u,v,h,j){const{cross:C,direction:I}=e,O=["INPUT","SELECT","TEXTAREA"],_={passive:!1},b=vt(),w=vt(),A=Je(50,225).constrain(y.measure(20)),k={mouse:300,touch:400},N={mouse:500,touch:600},G=p?43:25;let Y=!1,R=0,z=0,le=!1,ie=!1,M=!1,B=!1;function he(S){if(!j)return;function V(ne){(qt(j)||j(S,ne))&&ae(ne)}const q=t;b.add(q,"dragstart",ne=>ne.preventDefault(),_).add(q,"touchmove",()=>{},_).add(q,"touchend",()=>{}).add(q,"touchstart",V).add(q,"mousedown",V).add(q,"touchcancel",P).add(q,"contextmenu",P).add(q,"click",fe,!0)}function de(){b.clear(),w.clear()}function ue(){const S=B?n:t;w.add(S,"touchmove",ee,_).add(S,"touchend",P).add(S,"mousemove",ee,_).add(S,"mouseup",P)}function be(S){const V=S.nodeName||"";return O.includes(V)}function K(){return(p?N:k)[B?"mouse":"touch"]}function xe(S,V){const q=f.add(On(S)*-1),ne=x.byDistance(S,!p).distance;return p||Q(S)<A?ne:v&&V?ne*.5:x.byIndex(q.get(),0).distance}function ae(S){const V=hn(S,s);B=V,M=p&&V&&!S.buttons&&Y,Y=pt(o.get(),i.get())>=2,!(V&&S.button!==0)&&(be(S.target)||(le=!0,a.pointerDown(S),d.useFriction(0).useDuration(0),o.set(i),ue(),R=a.readPoint(S),z=a.readPoint(S,C),m.emit("pointerDown")))}function ee(S){if(!hn(S,s)&&S.touches.length>=2)return P(S);const q=a.readPoint(S),ne=a.readPoint(S,C),pe=pt(q,R),ce=pt(ne,z);if(!ie&&!B&&(!S.cancelable||(ie=pe>ce,!ie)))return P(S);const ye=a.pointerMove(S);pe>u&&(M=!0),d.useFriction(.3).useDuration(.75),l.start(),o.add(I(ye)),S.preventDefault()}function P(S){const q=x.byDistance(0,!1).index!==f.get(),ne=a.pointerUp(S)*K(),pe=xe(I(ne),q),ce=Fd(ne,pe),ye=G-10*ce,ge=h+ce/50;ie=!1,le=!1,w.clear(),d.useDuration(ye).useFriction(ge),c.distance(pe,!p),B=!1,m.emit("pointerUp")}function fe(S){M&&(S.stopPropagation(),S.preventDefault(),M=!1)}function te(){return le}return{init:he,destroy:de,pointerDown:te}}function Bd(e,t){let s,o;function a(f){return f.timeStamp}function i(f,m){const p=`client${(m||e.scroll)==="x"?"X":"Y"}`;return(hn(f,t)?f:f.touches[0])[p]}function l(f){return s=f,o=f,i(f)}function c(f){const m=i(f)-i(o),y=a(f)-a(s)>170;return o=f,y&&(s=f),m}function d(f){if(!s||!o)return 0;const m=i(o)-i(s),y=a(f)-a(s),p=a(f)-a(o)>170,u=m/y;return y&&!p&&Q(u)>.1?u:0}return{pointerDown:l,pointerMove:c,pointerUp:d,readPoint:i}}function Vd(){function e(n){const{offsetTop:s,offsetLeft:o,offsetWidth:a,offsetHeight:i}=n;return{top:s,right:o+a,bottom:s+i,left:o,width:a,height:i}}return{measure:e}}function Ud(e){function t(s){return e*(s/100)}return{measure:t}}function Hd(e,t,n,s,o,a,i){const l=[e].concat(s);let c,d,x=[],f=!1;function m(v){return o.measureSize(i.measure(v))}function y(v){if(!a)return;d=m(e),x=s.map(m);function h(j){for(const C of j){if(f)return;const I=C.target===e,O=s.indexOf(C.target),_=I?d:x[O],b=m(I?e:s[O]);if(Q(b-_)>=.5){v.reInit(),t.emit("resize");break}}}c=new ResizeObserver(j=>{(qt(a)||a(v,j))&&h(j)}),n.requestAnimationFrame(()=>{l.forEach(j=>c.observe(j))})}function p(){f=!0,c&&c.disconnect()}return{init:y,destroy:p}}function Kd(e,t,n,s,o,a){let i=0,l=0,c=o,d=a,x=e.get(),f=0;function m(){const _=s.get()-e.get(),b=!c;let w=0;return b?(i=0,n.set(s),e.set(s),w=_):(n.set(e),i+=_/c,i*=d,x+=i,e.add(i),w=x-f),l=On(w),f=x,O}function y(){const _=s.get()-t.get();return Q(_)<.001}function p(){return c}function u(){return l}function v(){return i}function h(){return C(o)}function j(){return I(a)}function C(_){return c=_,O}function I(_){return d=_,O}const O={direction:u,duration:p,velocity:v,seek:m,settled:y,useBaseFriction:j,useBaseDuration:h,useFriction:I,useDuration:C};return O}function Gd(e,t,n,s,o){const a=o.measure(10),i=o.measure(50),l=Je(.1,.99);let c=!1;function d(){return!(c||!e.reachedAny(n.get())||!e.reachedAny(t.get()))}function x(y){if(!d())return;const p=e.reachedMin(t.get())?"min":"max",u=Q(e[p]-t.get()),v=n.get()-t.get(),h=l.constrain(u/i);n.subtract(v*h),!y&&Q(v)<a&&(n.set(e.constrain(n.get())),s.useDuration(25).useBaseFriction())}function f(y){c=!y}return{shouldConstrain:d,constrain:x,toggleActive:f}}function qd(e,t,n,s,o){const a=Je(-t+e,0),i=f(),l=x(),c=m();function d(p,u){return pt(p,u)<=1}function x(){const p=i[0],u=Ee(i),v=i.lastIndexOf(p),h=i.indexOf(u)+1;return Je(v,h)}function f(){return n.map((p,u)=>{const{min:v,max:h}=a,j=a.constrain(p),C=!u,I=Pn(n,u);return C?h:I||d(v,j)?v:d(h,j)?h:j}).map(p=>parseFloat(p.toFixed(3)))}function m(){if(t<=e+o)return[a.max];if(s==="keepSnaps")return i;const{min:p,max:u}=l;return i.slice(p,u)}return{snapsContained:c,scrollContainLimit:l}}function Wd(e,t,n){const s=t[0],o=n?s-e:Ee(t);return{limit:Je(o,s)}}function Yd(e,t,n,s){const a=t.min+.1,i=t.max+.1,{reachedMin:l,reachedMax:c}=Je(a,i);function d(m){return m===1?c(n.get()):m===-1?l(n.get()):!1}function x(m){if(!d(m))return;const y=e*(m*-1);s.forEach(p=>p.add(y))}return{loop:x}}function Xd(e){const{max:t,length:n}=e;function s(a){const i=a-t;return n?i/-n:0}return{get:s}}function Jd(e,t,n,s,o){const{startEdge:a,endEdge:i}=e,{groupSlides:l}=o,c=f().map(t.measure),d=m(),x=y();function f(){return l(s).map(u=>Ee(u)[i]-u[0][a]).map(Q)}function m(){return s.map(u=>n[a]-u[a]).map(u=>-Q(u))}function y(){return l(d).map(u=>u[0]).map((u,v)=>u+c[v])}return{snaps:d,snapsAligned:x}}function Qd(e,t,n,s,o,a){const{groupSlides:i}=o,{min:l,max:c}=s,d=x();function x(){const m=i(a),y=!e||t==="keepSnaps";return n.length===1?[a]:y?m:m.slice(l,c).map((p,u,v)=>{const h=!u,j=Pn(v,u);if(h){const C=Ee(v[0])+1;return Pr(C)}if(j){const C=Ct(a)-Ee(v)[0]+1;return Pr(C,Ee(v)[0])}return p})}return{slideRegistry:d}}function Zd(e,t,n,s,o){const{reachedAny:a,removeOffset:i,constrain:l}=s;function c(p){return p.concat().sort((u,v)=>Q(u)-Q(v))[0]}function d(p){const u=e?i(p):l(p),v=t.map((j,C)=>({diff:x(j-u,0),index:C})).sort((j,C)=>Q(j.diff)-Q(C.diff)),{index:h}=v[0];return{index:h,distance:u}}function x(p,u){const v=[p,p+n,p-n];if(!e)return p;if(!u)return c(v);const h=v.filter(j=>On(j)===u);return h.length?c(h):Ee(v)-n}function f(p,u){const v=t[p]-o.get(),h=x(v,u);return{index:p,distance:h}}function m(p,u){const v=o.get()+p,{index:h,distance:j}=d(v),C=!e&&a(v);if(!u||C)return{index:h,distance:p};const I=t[h]-j,O=p+x(I,0);return{index:h,distance:O}}return{byDistance:m,byIndex:f,shortcut:x}}function eu(e,t,n,s,o,a,i){function l(f){const m=f.distance,y=f.index!==t.get();a.add(m),m&&(s.duration()?e.start():(e.update(),e.render(1),e.update())),y&&(n.set(t.get()),t.set(f.index),i.emit("select"))}function c(f,m){const y=o.byDistance(f,m);l(y)}function d(f,m){const y=t.clone().set(f),p=o.byIndex(y.get(),m);l(p)}return{distance:c,index:d}}function tu(e,t,n,s,o,a,i,l){const c={passive:!0,capture:!0};let d=0;function x(y){if(!l)return;function p(u){if(new Date().getTime()-d>10)return;i.emit("slideFocusStart"),e.scrollLeft=0;const j=n.findIndex(C=>C.includes(u));En(j)&&(o.useDuration(0),s.index(j,0),i.emit("slideFocus"))}a.add(document,"keydown",f,!1),t.forEach((u,v)=>{a.add(u,"focus",h=>{(qt(l)||l(y,h))&&p(v)},c)})}function f(y){y.code==="Tab"&&(d=new Date().getTime())}return{init:x}}function ut(e){let t=e;function n(){return t}function s(c){t=i(c)}function o(c){t+=i(c)}function a(c){t-=i(c)}function i(c){return En(c)?c:c.get()}return{get:n,set:s,add:o,subtract:a}}function lo(e,t){const n=e.scroll==="x"?i:l,s=t.style;let o=null,a=!1;function i(m){return`translate3d(${m}px,0px,0px)`}function l(m){return`translate3d(0px,${m}px,0px)`}function c(m){if(a)return;const y=kd(e.direction(m));y!==o&&(s.transform=n(y),o=y)}function d(m){a=!m}function x(){a||(s.transform="",t.getAttribute("style")||t.removeAttribute("style"))}return{clear:x,to:c,toggleActive:d}}function nu(e,t,n,s,o,a,i,l,c){const x=xt(o),f=xt(o).reverse(),m=h().concat(j());function y(b,w){return b.reduce((A,k)=>A-o[k],w)}function p(b,w){return b.reduce((A,k)=>y(A,w)>0?A.concat([k]):A,[])}function u(b){return a.map((w,A)=>({start:w-s[A]+.5+b,end:w+t-.5+b}))}function v(b,w,A){const k=u(w);return b.map(N=>{const G=A?0:-n,Y=A?n:0,R=A?"end":"start",z=k[N][R];return{index:N,loopPoint:z,slideLocation:ut(-1),translate:lo(e,c[N]),target:()=>l.get()>z?G:Y}})}function h(){const b=i[0],w=p(f,b);return v(w,n,!1)}function j(){const b=t-i[0]-1,w=p(x,b);return v(w,-n,!0)}function C(){return m.every(({index:b})=>{const w=x.filter(A=>A!==b);return y(w,t)<=.1})}function I(){m.forEach(b=>{const{target:w,translate:A,slideLocation:k}=b,N=w();N!==k.get()&&(A.to(N),k.set(N))})}function O(){m.forEach(b=>b.translate.clear())}return{canLoop:C,clear:O,loop:I,loopPoints:m}}function ru(e,t,n){let s,o=!1;function a(c){if(!n)return;function d(x){for(const f of x)if(f.type==="childList"){c.reInit(),t.emit("slidesChanged");break}}s=new MutationObserver(x=>{o||(qt(n)||n(c,x))&&d(x)}),s.observe(e,{childList:!0})}function i(){s&&s.disconnect(),o=!0}return{init:a,destroy:i}}function su(e,t,n,s){const o={};let a=null,i=null,l,c=!1;function d(){l=new IntersectionObserver(p=>{c||(p.forEach(u=>{const v=t.indexOf(u.target);o[v]=u}),a=null,i=null,n.emit("slidesInView"))},{root:e.parentElement,threshold:s}),t.forEach(p=>l.observe(p))}function x(){l&&l.disconnect(),c=!0}function f(p){return yt(o).reduce((u,v)=>{const h=parseInt(v),{isIntersecting:j}=o[h];return(p&&j||!p&&!j)&&u.push(h),u},[])}function m(p=!0){if(p&&a)return a;if(!p&&i)return i;const u=f(p);return p&&(a=u),p||(i=u),u}return{init:d,destroy:x,get:m}}function ou(e,t,n,s,o,a){const{measureSize:i,startEdge:l,endEdge:c}=e,d=n[0]&&o,x=p(),f=u(),m=n.map(i),y=v();function p(){if(!d)return 0;const j=n[0];return Q(t[l]-j[l])}function u(){if(!d)return 0;const j=a.getComputedStyle(Ee(s));return parseFloat(j.getPropertyValue(`margin-${c}`))}function v(){return n.map((j,C,I)=>{const O=!C,_=Pn(I,C);return O?m[C]+x:_?m[C]+f:I[C+1][l]-j[l]}).map(Q)}return{slideSizes:m,slideSizesWithGaps:y,startGap:x,endGap:f}}function au(e,t,n,s,o,a,i,l,c){const{startEdge:d,endEdge:x,direction:f}=e,m=En(n);function y(h,j){return xt(h).filter(C=>C%j===0).map(C=>h.slice(C,C+j))}function p(h){return h.length?xt(h).reduce((j,C,I)=>{const O=Ee(j)||0,_=O===0,b=C===Ct(h),w=o[d]-a[O][d],A=o[d]-a[C][x],k=!s&&_?f(i):0,N=!s&&b?f(l):0,G=Q(A-N-(w+k));return I&&G>t+c&&j.push(C),b&&j.push(h.length),j},[]).map((j,C,I)=>{const O=Math.max(I[C-1]||0);return h.slice(O,j)}):[]}function u(h){return m?y(h,n):p(h)}return{groupSlides:u}}function iu(e,t,n,s,o,a,i){const{align:l,axis:c,direction:d,startIndex:x,loop:f,duration:m,dragFree:y,dragThreshold:p,inViewThreshold:u,slidesToScroll:v,skipSnaps:h,containScroll:j,watchResize:C,watchSlides:I,watchDrag:O,watchFocus:_}=a,b=2,w=Vd(),A=w.measure(t),k=n.map(w.measure),N=zd(c,d),G=N.measureSize(A),Y=Ud(G),R=Rd(l,G),z=!f&&!!j,le=f||!!j,{slideSizes:ie,slideSizesWithGaps:M,startGap:B,endGap:he}=ou(N,A,k,n,le,o),de=au(N,G,v,f,A,k,B,he,b),{snaps:ue,snapsAligned:be}=Jd(N,R,A,k,de),K=-Ee(ue)+Ee(M),{snapsContained:xe,scrollContainLimit:ae}=qd(G,K,be,j,b),ee=z?xe:be,{limit:P}=Wd(K,ee,f),fe=co(Ct(ee),x,f),te=fe.clone(),H=xt(n),S=({dragHandler:Ce,scrollBody:Ke,scrollBounds:Ge,options:{loop:Me}})=>{Me||Ge.constrain(Ce.pointerDown()),Ke.seek()},V=({scrollBody:Ce,translate:Ke,location:Ge,offsetLocation:Me,previousLocation:Ze,scrollLooper:at,slideLooper:it,dragHandler:ct,animation:lt,eventHandler:Dt,scrollBounds:ho,options:{loop:Nn}},$n)=>{const Fn=Ce.settled(),xo=!ho.shouldConstrain(),kn=Nn?Fn:Fn&&xo,Rn=kn&&!ct.pointerDown();Rn&&lt.stop();const yo=Ge.get()*$n+Ze.get()*(1-$n);Me.set(yo),Nn&&(at.loop(Ce.direction()),it.loop()),Ke.to(Me.get()),Rn&&Dt.emit("settle"),kn||Dt.emit("scroll")},q=Md(s,o,()=>S(ke),Ce=>V(ke,Ce)),ne=.68,pe=ee[fe.get()],ce=ut(pe),ye=ut(pe),ge=ut(pe),ve=ut(pe),re=Kd(ce,ge,ye,ve,m,ne),Fe=Zd(f,ee,K,P,ve),ot=eu(q,fe,te,re,Fe,ve,i),D=Xd(P),E=vt(),Z=su(t,n,i,u),{slideRegistry:se}=Qd(z,j,ee,ae,de,H),me=tu(e,n,se,ot,re,E,i,_),ke={ownerDocument:s,ownerWindow:o,eventHandler:i,containerRect:A,slideRects:k,animation:q,axis:N,dragHandler:Ld(N,e,s,o,ve,Bd(N,o),ce,q,ot,re,Fe,fe,i,Y,y,p,h,ne,O),eventStore:E,percentOfView:Y,index:fe,indexPrevious:te,limit:P,location:ce,offsetLocation:ge,previousLocation:ye,options:a,resizeHandler:Hd(t,i,o,n,N,C,w),scrollBody:re,scrollBounds:Gd(P,ge,ve,re,Y),scrollLooper:Yd(K,P,ge,[ce,ge,ye,ve]),scrollProgress:D,scrollSnapList:ee.map(D.get),scrollSnaps:ee,scrollTarget:Fe,scrollTo:ot,slideLooper:nu(N,G,K,ie,M,ue,ee,ge,n),slideFocus:me,slidesHandler:ru(t,i,I),slidesInView:Z,slideIndexes:H,slideRegistry:se,slidesToScroll:de,target:ve,translate:lo(N,t)};return ke}function cu(){let e={},t;function n(d){t=d}function s(d){return e[d]||[]}function o(d){return s(d).forEach(x=>x(t,d)),c}function a(d,x){return e[d]=s(d).concat([x]),c}function i(d,x){return e[d]=s(d).filter(f=>f!==x),c}function l(){e={}}const c={init:n,emit:o,off:i,on:a,clear:l};return c}const lu={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 du(e){function t(a,i){return io(a,i||{})}function n(a){const i=a.breakpoints||{},l=yt(i).filter(c=>e.matchMedia(c).matches).map(c=>i[c]).reduce((c,d)=>t(c,d),{});return t(a,l)}function s(a){return a.map(i=>yt(i.breakpoints||{})).reduce((i,l)=>i.concat(l),[]).map(e.matchMedia)}return{mergeOptions:t,optionsAtMedia:n,optionsMediaQueries:s}}function uu(e){let t=[];function n(a,i){return t=i.filter(({options:l})=>e.optionsAtMedia(l).active!==!1),t.forEach(l=>l.init(a,e)),i.reduce((l,c)=>Object.assign(l,{[c.name]:c}),{})}function s(){t=t.filter(a=>a.destroy())}return{init:n,destroy:s}}function Ut(e,t,n){const s=e.ownerDocument,o=s.defaultView,a=du(o),i=uu(a),l=vt(),c=cu(),{mergeOptions:d,optionsAtMedia:x,optionsMediaQueries:f}=a,{on:m,off:y,emit:p}=c,u=N;let v=!1,h,j=d(lu,Ut.globalOptions),C=d(j),I=[],O,_,b;function w(){const{container:H,slides:S}=C;_=(mn(H)?e.querySelector(H):H)||e.children[0];const q=mn(S)?_.querySelectorAll(S):S;b=[].slice.call(q||_.children)}function A(H){const S=iu(e,_,b,s,o,H,c);if(H.loop&&!S.slideLooper.canLoop()){const V=Object.assign({},H,{loop:!1});return A(V)}return S}function k(H,S){v||(j=d(j,H),C=x(j),I=S||I,w(),h=A(C),f([j,...I.map(({options:V})=>V)]).forEach(V=>l.add(V,"change",N)),C.active&&(h.translate.to(h.location.get()),h.animation.init(),h.slidesInView.init(),h.slideFocus.init(te),h.eventHandler.init(te),h.resizeHandler.init(te),h.slidesHandler.init(te),h.options.loop&&h.slideLooper.loop(),_.offsetParent&&b.length&&h.dragHandler.init(te),O=i.init(te,I)))}function N(H,S){const V=de();G(),k(d({startIndex:V},H),S),c.emit("reInit")}function G(){h.dragHandler.destroy(),h.eventStore.clear(),h.translate.clear(),h.slideLooper.clear(),h.resizeHandler.destroy(),h.slidesHandler.destroy(),h.slidesInView.destroy(),h.animation.destroy(),i.destroy(),l.clear()}function Y(){v||(v=!0,l.clear(),G(),c.emit("destroy"),c.clear())}function R(H,S,V){!C.active||v||(h.scrollBody.useBaseFriction().useDuration(S===!0?0:C.duration),h.scrollTo.index(H,V||0))}function z(H){const S=h.index.add(1).get();R(S,H,-1)}function le(H){const S=h.index.add(-1).get();R(S,H,1)}function ie(){return h.index.add(1).get()!==de()}function M(){return h.index.add(-1).get()!==de()}function B(){return h.scrollSnapList}function he(){return h.scrollProgress.get(h.offsetLocation.get())}function de(){return h.index.get()}function ue(){return h.indexPrevious.get()}function be(){return h.slidesInView.get()}function K(){return h.slidesInView.get(!1)}function xe(){return O}function ae(){return h}function ee(){return e}function P(){return _}function fe(){return b}const te={canScrollNext:ie,canScrollPrev:M,containerNode:P,internalEngine:ae,destroy:Y,off:y,on:m,emit:p,plugins:xe,previousScrollSnap:ue,reInit:u,rootNode:ee,scrollNext:z,scrollPrev:le,scrollProgress:he,scrollSnapList:B,scrollTo:R,selectedScrollSnap:de,slideNodes:fe,slidesInView:be,slidesNotInView:K};return k(t,n),setTimeout(()=>c.emit("init"),0),te}Ut.globalOptions=void 0;function An(e={},t=[]){const n=g.useRef(e),s=g.useRef(t),[o,a]=g.useState(),[i,l]=g.useState(),c=g.useCallback(()=>{o&&o.reInit(n.current,s.current)},[o]);return g.useEffect(()=>{In(n.current,e)||(n.current=e,c())},[e,c]),g.useEffect(()=>{$d(s.current,t)||(s.current=t,c())},[t,c]),g.useEffect(()=>{if(Nd()&&i){Ut.globalOptions=An.globalOptions;const d=Ut(i,n.current,s.current);return a(d),()=>d.destroy()}else a(void 0)},[i,a]),[l,o]}An.globalOptions=void 0;const fu={context:"[@mantine/carousel] Carousel.Slide was rendered outside of Carousel context"},[pu,gu]=Kr(fu.context);var mu=Object.defineProperty,hu=Object.defineProperties,xu=Object.getOwnPropertyDescriptors,Ar=Object.getOwnPropertySymbols,yu=Object.prototype.hasOwnProperty,vu=Object.prototype.propertyIsEnumerable,Tr=(e,t,n)=>t in e?mu(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,sn=(e,t)=>{for(var n in t||(t={}))yu.call(t,n)&&Tr(e,n,t[n]);if(Ar)for(var n of Ar(t))vu.call(t,n)&&Tr(e,n,t[n]);return e},ju=(e,t)=>hu(e,xu(t)),bu=Ve((e,{controlSize:t,controlsOffset:n,orientation:s,height:o,includeGapInSize:a,breakpoints:i=[],slideGap:l})=>{const c=s==="horizontal",d=m=>{if(!a)return{};const y=we({size:m,sizes:e.spacing});return{[s==="horizontal"?"marginRight":"marginBottom"]:`calc(${y} * -1)`}},f=i.some(m=>typeof m.slideGap<"u"||typeof m.slideSize<"u")?cs(e,i).reduce((m,y)=>{const p="maxWidth"in y?"max-width":"min-width",u=we({size:p==="max-width"?y.maxWidth:y.minWidth,sizes:e.breakpoints}),v=typeof y.slideGap>"u"?void 0:$(y.slideGap),h=ls(u)-(p==="max-width"?1:0);return m[`@media (${p}: ${$(h)})`]=d(v),m},{}):null;return{root:{position:"relative"},viewport:{height:$(o),overflow:"hidden"},container:sn(sn({display:"flex",flexDirection:c?"row":"column",height:$(o)},d(l)),f),controls:{position:"absolute",zIndex:1,left:c?0:`calc(50% - ${$(t)} / 2)`,right:c?0:void 0,top:c?`calc(50% - ${$(t)} / 2)`:0,bottom:c?void 0:0,display:"flex",flexDirection:c?"row":"column",alignItems:"center",justifyContent:"space-between",paddingLeft:c?we({size:n,sizes:e.spacing}):void 0,paddingRight:c?we({size:n,sizes:e.spacing}):void 0,paddingTop:c?void 0:we({size:n,sizes:e.spacing}),paddingBottom:c?void 0:we({size:n,sizes:e.spacing}),pointerEvents:"none"},control:ju(sn({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:c?e.spacing.md:0,top:c?void 0:0,left:c?0:void 0,right:c?0:e.spacing.md,display:"flex",flexDirection:c?"row":"column",justifyContent:"center",gap:$(8),pointerEvents:"none"},indicator:{pointerEvents:"all",width:c?$(25):$(5),height:c?$(5):$(25),borderRadius:e.radius.xl,backgroundColor:e.white,boxShadow:e.shadows.sm,opacity:.6,transition:`opacity 150ms ${e.transitionTimingFunction}`,"&[data-active]":{opacity:1}}}}),Cu=Object.defineProperty,Nr=Object.getOwnPropertySymbols,Du=Object.prototype.hasOwnProperty,Su=Object.prototype.propertyIsEnumerable,$r=(e,t,n)=>t in e?Cu(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,on=(e,t)=>{for(var n in t||(t={}))Du.call(t,n)&&$r(e,n,t[n]);if(Nr)for(var n of Nr(t))Su.call(t,n)&&$r(e,n,t[n]);return e},wu=Ve((e,{size:t,gap:n,orientation:s,includeGapInSize:o,breakpoints:a=[]})=>{const i=(d,x)=>{const f=we({size:d,sizes:e.spacing}),m=$(x),y=o?{[s==="horizontal"?"paddingRight":"paddingBottom"]:f}:{[s==="horizontal"?"marginRight":"marginBottom"]:f};return on({flex:`0 0 ${m}`},y)},c=a.some(d=>typeof d.slideGap<"u"||typeof d.slideSize<"u")?cs(e,a).reduce((d,x)=>{const f="maxWidth"in x?"max-width":"min-width",m=we({size:f==="max-width"?x.maxWidth:x.minWidth,sizes:e.breakpoints}),y=typeof x.slideGap>"u"?n:x.slideGap,p=ls(m)-(f==="max-width"?1:0);return d[`@media (${f}: ${$(p)})`]=i(y,x.slideSize),d},{}):null;return{slide:on(on({position:"relative"},i(n,t)),c)}}),_u=Object.defineProperty,Ht=Object.getOwnPropertySymbols,uo=Object.prototype.hasOwnProperty,fo=Object.prototype.propertyIsEnumerable,Fr=(e,t,n)=>t in e?_u(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Iu=(e,t)=>{for(var n in t||(t={}))uo.call(t,n)&&Fr(e,n,t[n]);if(Ht)for(var n of Ht(t))fo.call(t,n)&&Fr(e,n,t[n]);return e},Eu=(e,t)=>{var n={};for(var s in e)uo.call(e,s)&&t.indexOf(s)<0&&(n[s]=e[s]);if(e!=null&&Ht)for(var s of Ht(e))t.indexOf(s)<0&&fo.call(e,s)&&(n[s]=e[s]);return n};const po=g.forwardRef((e,t)=>{var n=e,{children:s,className:o,size:a,gap:i}=n,l=Eu(n,["children","className","size","gap"]);const c=gu(),{classes:d,cx:x}=wu({gap:typeof i>"u"?c.slideGap:i,size:typeof a>"u"?c.slideSize:a,orientation:c.orientation,includeGapInSize:c.includeGapInSize,breakpoints:c.breakpoints},{name:"Carousel",classNames:c.classNames,styles:c.styles,unstyled:c.unstyled,variant:c.variant});return T.createElement(He,Iu({className:x(d.slide,o),ref:t},l),s)});po.displayName="@mantine/carousel/CarouselSlide";function kr({dir:e,orientation:t,direction:n}){return n==="previous"?t==="horizontal"?90*(e==="ltr"?1:-1):-180:t==="horizontal"?90*(e==="ltr"?-1:1):0}var Ou=Object.defineProperty,Kt=Object.getOwnPropertySymbols,go=Object.prototype.hasOwnProperty,mo=Object.prototype.propertyIsEnumerable,Rr=(e,t,n)=>t in e?Ou(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Pu=(e,t)=>{for(var n in t||(t={}))go.call(t,n)&&Rr(e,n,t[n]);if(Kt)for(var n of Kt(t))mo.call(t,n)&&Rr(e,n,t[n]);return e},Au=(e,t)=>{var n={};for(var s in e)go.call(e,s)&&t.indexOf(s)<0&&(n[s]=e[s]);if(e!=null&&Kt)for(var s of Kt(e))t.indexOf(s)<0&&mo.call(e,s)&&(n[s]=e[s]);return n};const Tu={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},Tn=g.forwardRef((e,t)=>{const n=Ue("Carousel",Tu,e),{children:s,className:o,getEmblaApi:a,onNextSlide:i,onPreviousSlide:l,onSlideChange:c,nextControlLabel:d,previousControlLabel:x,controlSize:f,controlsOffset:m,classNames:y,styles:p,unstyled:u,slideSize:v,slideGap:h,orientation:j,height:C,align:I,slidesToScroll:O,includeGapInSize:_,draggable:b,dragFree:w,loop:A,speed:k,initialSlide:N,inViewThreshold:G,withControls:Y,withIndicators:R,plugins:z,nextControlIcon:le,previousControlIcon:ie,breakpoints:M,skipSnaps:B,containScroll:he,withKeyboardEvents:de,variant:ue}=n,be=Au(n,["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:K,cx:xe,theme:ae}=bu({controlSize:f,controlsOffset:m,orientation:j,height:C,includeGapInSize:_,breakpoints:M,slideGap:h},{name:"Carousel",classNames:y,styles:p,unstyled:u,variant:ue}),[ee,P]=An({axis:j==="horizontal"?"x":"y",direction:j==="horizontal"?ae.dir:void 0,startIndex:N,loop:A,align:I,slidesToScroll:O,draggable:b,dragFree:w,speed:k,inViewThreshold:G,skipSnaps:B,containScroll:he},z),[fe,te]=g.useState(0),[H,S]=g.useState(0),V=g.useCallback(re=>P&&P.scrollTo(re),[P]),q=g.useCallback(()=>{if(!P)return;const re=P.selectedScrollSnap();te(re),c?.(re)},[P,te]),ne=g.useCallback(()=>{P?.scrollPrev(),l?.()},[P]),pe=g.useCallback(()=>{P?.scrollNext(),i?.()},[P]),ce=g.useCallback(re=>{de&&(re.key==="ArrowRight"&&(re.preventDefault(),pe()),re.key==="ArrowLeft"&&(re.preventDefault(),ne()))},[P]);g.useEffect(()=>{if(P)return a?.(P),q(),S(P.scrollSnapList().length),P.on("select",q),()=>{P.off("select",q)}},[P,O]),g.useEffect(()=>{P&&(P.reInit(),S(P.scrollSnapList().length),te(re=>ga(re,0,g.Children.toArray(s).length-1)))},[g.Children.toArray(s).length,O]);const ye=P?.canScrollPrev()||!1,ge=P?.canScrollNext()||!1,ve=Array(H).fill(0).map((re,Fe)=>T.createElement(Yt,{key:Fe,"data-active":Fe===fe||void 0,className:K.indicator,"aria-hidden":!0,tabIndex:-1,onClick:()=>V(Fe)}));return T.createElement(pu,{value:{slideGap:h,slideSize:v,embla:P,orientation:j,includeGapInSize:_,breakpoints:M,classNames:y,styles:p,unstyled:u,variant:ue}},T.createElement(He,Pu({className:xe(K.root,o),ref:t,onKeyDownCapture:ce},be),T.createElement("div",{className:K.viewport,ref:ee},T.createElement("div",{className:K.container},s)),R&&T.createElement("div",{className:K.indicators},ve),Y&&T.createElement("div",{className:K.controls},T.createElement(Yt,{onClick:ne,className:K.control,"aria-label":x,"data-inactive":!ye||void 0,tabIndex:ye?0:-1},typeof ie<"u"?ie:T.createElement(Bn,{style:{transform:`rotate(${kr({dir:ae.dir,orientation:j,direction:"previous"})}deg)`}})),T.createElement(Yt,{onClick:pe,className:K.control,"aria-label":d,"data-inactive":!ge||void 0,tabIndex:ge?0:-1},typeof le<"u"?le:T.createElement(Bn,{style:{transform:`rotate(${kr({dir:ae.dir,orientation:j,direction:"next"})}deg)`}})))))});Tn.Slide=po;Tn.displayName="@mantine/carousel/Carousel";const Mr=Tn,Nu=({chargeProps:e,onChange:t})=>{const{additionalDocuments:n}=L(ds,e),[s,o]=g.useState(void 0);return r.jsx("div",{className:"container mx-auto text-gray-600 body-font",children:n?.length>0?r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"flex flex-wrap",children:r.jsx(Mr,{sx:{maxWidth:320},mx:"auto",align:"center",withControls:n.length>1,slideGap:0,withIndicators:!0,className:"[&>*>.mantine-Carousel-indicator]:bg-gray-500",children:n.map(a=>r.jsx(Mr.Slide,{children:r.jsxs("div",{className:"flex flex-col items-center",children:[r.jsx("h2",{className:"text-gray-900 text-base font-medium",children:"documentType"in a?a.documentType:"Unprocessed"}),r.jsx("button",{className:"mx-10",onClick:()=>o(a.id),children:r.jsx("div",{className:"flex rounded-lg h-full bg-gray-100 p-2 m-2 flex-col",children:r.jsx(ma,{src:a.image?.toString(),withPlaceholder:!0})})})]})},a.id))})}),r.jsx(ha,{documentId:s,onDone:()=>o(void 0),onChange:t})]}):r.jsx(ln,{color:"red",children:"No Documents Related"})})},Et=({foreignAmount:e,localAmount:t,diff:n})=>{const s=e!=null&&e.currency!==Dn.Ils,o=n&&n.localAmount?.formatted!==t?.formatted,a=n&&n.foreignAmount?.formatted!==e?.formatted;return r.jsx("div",{className:"flex flex-col",children:(t||o)&&r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"flex gap-2 items-center",children:[s&&r.jsx("p",{className:a?"line-through":"",children:e.formatted}),a&&n.foreignAmount&&r.jsx("p",{className:"border-2 border-yellow-500 rounded-md",children:n.foreignAmount.formatted})]}),r.jsxs("div",{className:"flex gap-2 items-center",children:[t!=null&&r.jsx("p",{className:o?"line-through":"",children:t.formatted}),o&&n.localAmount&&r.jsx("p",{className:"border-2 border-yellow-500 rounded-md",children:n.localAmount.formatted})]})]})})},Ot=({account:e,diffAccount:t})=>{const n=t&&t?.id!==e?.id;return r.jsx("div",{className:"flex flex-col whitespace-normal",children:(e||n)&&r.jsxs(r.Fragment,{children:[e&&r.jsx(At,{to:mt.BUSINESSES.DETAIL(e.id),target:"_blank",rel:"noreferrer",onClick:s=>s.stopPropagation(),className:`inline-flex items-center font-semibold ${n?"line-through":""}`,children:e.name}),n&&t&&r.jsx("div",{className:"border-2 border-yellow-500 rounded-md",children:r.jsx(At,{to:mt.BUSINESSES.DETAIL(t.id),target:"_blank",rel:"noreferrer",onClick:s=>s.stopPropagation(),className:"inline-flex items-center font-semibold",children:t.name})})]})})},zr=({date:e,diff:t})=>{const n=e?Be(new Date(e),"dd/MM/yy"):void 0,s=t?Be(new Date(t),"dd/MM/yy"):void 0,o=s&&n!==s;return r.jsxs(r.Fragment,{children:[r.jsx("p",{className:o?"line-through":"",children:n??"Missing Data"}),o&&r.jsx("div",{className:"flex flex-col border-2 border-yellow-500 rounded-md",children:s})]})},Lr=[{accessorKey:"invoiceDate",header:({column:e})=>r.jsxs(X,{variant:"ghost",onClick:()=>e.toggleSorting(e.getIsSorted()==="asc"),children:["Invoice Date",e.getIsSorted()&&(e.getIsSorted()==="asc"?r.jsx(De,{className:"ml-2 h-4 w-4"}):r.jsx(Se,{className:"ml-2 h-4 w-4"}))]}),cell:({row:e})=>r.jsx(zr,{date:e.original.invoiceDate,diff:e.original.diff?.invoiceDate})},{accessorKey:"valueDate",header:({column:e})=>r.jsxs(X,{variant:"ghost",onClick:()=>e.toggleSorting(e.getIsSorted()==="asc"),children:["Value Date",e.getIsSorted()&&(e.getIsSorted()==="asc"?r.jsx(De,{className:"ml-2 h-4 w-4"}):r.jsx(Se,{className:"ml-2 h-4 w-4"}))]}),cell:({row:e})=>r.jsx(zr,{date:e.original.valueDate,diff:e.original.diff?.valueDate})},{header:"Debit Account (Main)",columns:[{accessorKey:"debitAccount1.name",header:({column:e})=>r.jsxs(X,{variant:"ghost",onClick:()=>e.toggleSorting(e.getIsSorted()==="asc"),children:["Account",e.getIsSorted()&&(e.getIsSorted()==="asc"?r.jsx(De,{className:"ml-2 h-4 w-4"}):r.jsx(Se,{className:"ml-2 h-4 w-4"}))]}),cell:({row:e})=>r.jsx(Ot,{account:e.original.debitAccount1,diffAccount:e.original.diff?.debitAccount1})},{accessorKey:"localCurrencyDebitAmount1.raw",header:({column:e})=>r.jsxs(X,{variant:"ghost",onClick:()=>e.toggleSorting(e.getIsSorted()==="asc"),children:["Amount",e.getIsSorted()&&(e.getIsSorted()==="asc"?r.jsx(De,{className:"ml-2 h-4 w-4"}):r.jsx(Se,{className:"ml-2 h-4 w-4"}))]}),cell:({row:e})=>r.jsx(Et,{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})=>r.jsxs(X,{variant:"ghost",onClick:()=>e.toggleSorting(e.getIsSorted()==="asc"),children:["Account",e.getIsSorted()&&(e.getIsSorted()==="asc"?r.jsx(De,{className:"ml-2 h-4 w-4"}):r.jsx(Se,{className:"ml-2 h-4 w-4"}))]}),cell:({row:e})=>r.jsx(Ot,{account:e.original.creditAccount1,diffAccount:e.original.diff?.creditAccount1})},{accessorKey:"localCurrencyCreditAmount1.raw",header:({column:e})=>r.jsxs(X,{variant:"ghost",onClick:()=>e.toggleSorting(e.getIsSorted()==="asc"),children:["Amount",e.getIsSorted()&&(e.getIsSorted()==="asc"?r.jsx(De,{className:"ml-2 h-4 w-4"}):r.jsx(Se,{className:"ml-2 h-4 w-4"}))]}),cell:({row:e})=>r.jsx(Et,{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})=>r.jsxs(X,{variant:"ghost",onClick:()=>e.toggleSorting(e.getIsSorted()==="asc"),children:["Account",e.getIsSorted()&&(e.getIsSorted()==="asc"?r.jsx(De,{className:"ml-2 h-4 w-4"}):r.jsx(Se,{className:"ml-2 h-4 w-4"}))]}),cell:({row:e})=>r.jsx(Ot,{account:e.original.debitAccount2,diffAccount:e.original.diff?.debitAccount2})},{accessorKey:"localCurrencyDebitAmount2.raw",header:({column:e})=>r.jsxs(X,{variant:"ghost",onClick:()=>e.toggleSorting(e.getIsSorted()==="asc"),children:["Amount",e.getIsSorted()&&(e.getIsSorted()==="asc"?r.jsx(De,{className:"ml-2 h-4 w-4"}):r.jsx(Se,{className:"ml-2 h-4 w-4"}))]}),cell:({row:e})=>r.jsx(Et,{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})=>r.jsxs(X,{variant:"ghost",onClick:()=>e.toggleSorting(e.getIsSorted()==="asc"),children:["Account",e.getIsSorted()&&(e.getIsSorted()==="asc"?r.jsx(De,{className:"ml-2 h-4 w-4"}):r.jsx(Se,{className:"ml-2 h-4 w-4"}))]}),cell:({row:e})=>r.jsx(Ot,{account:e.original.creditAccount2,diffAccount:e.original.diff?.creditAccount2})},{accessorKey:"localCurrencyCreditAmount2.raw",header:({column:e})=>r.jsxs(X,{variant:"ghost",onClick:()=>e.toggleSorting(e.getIsSorted()==="asc"),children:["Amount",e.getIsSorted()&&(e.getIsSorted()==="asc"?r.jsx(De,{className:"ml-2 h-4 w-4"}):r.jsx(Se,{className:"ml-2 h-4 w-4"}))]}),cell:({row:e})=>r.jsx(Et,{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})=>r.jsxs(X,{variant:"ghost",onClick:()=>e.toggleSorting(e.getIsSorted()==="asc"),children:["Details",e.getIsSorted()&&(e.getIsSorted()==="asc"?r.jsx(De,{className:"ml-2 h-4 w-4"}):r.jsx(Se,{className:"ml-2 h-4 w-4"}))]}),cell:({row:{original:e}})=>{const t=e.diff&&e.diff.description!==e.description;return r.jsxs("div",{className:"flex flex-col whitespace-normal",children:[r.jsx("p",{className:t?"line-through":"",children:e.description}),t&&r.jsx("div",{className:"border-2 border-yellow-500 rounded-md",children:e.diff?.description})]})}},{accessorKey:"reference",header:({column:e})=>r.jsxs(X,{variant:"ghost",onClick:()=>e.toggleSorting(e.getIsSorted()==="asc"),children:["Reference",e.getIsSorted()&&(e.getIsSorted()==="asc"?r.jsx(De,{className:"ml-2 h-4 w-4"}):r.jsx(Se,{className:"ml-2 h-4 w-4"}))]}),cell:({row:{original:e}})=>{const t=e.diff&&e.diff.reference!==e.reference;return r.jsxs("div",{className:"flex flex-col whitespace-normal",children:[r.jsx("p",{className:t?"line-through":"",children:e.reference}),t&&r.jsx("div",{className:"border-2 border-yellow-500 rounded-md",children:e.diff?.reference})]})}},{accessorKey:"matchingStatus",header:({column:e})=>r.jsxs(X,{variant:"ghost",onClick:()=>e.toggleSorting(e.getIsSorted()==="asc"),children:["Status",e.getIsSorted()&&(e.getIsSorted()==="asc"?r.jsx(De,{className:"ml-2 h-4 w-4"}):r.jsx(Se,{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 r.jsx(us,{variant:"default",className:t,children:e})}return null}}];function $u(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 Fu=({ledgerRecordsData:e,ledgerDiffData:t,matches:n})=>{const[s,o]=g.useState([]),a=g.useMemo(()=>{const l=e.map(f=>L(Vn,f)),c=t?.map(f=>L(Vn,f)),d=l.map(f=>{const m=c?.find(y=>y.id===f.id);return{...f,matchingStatus:!n||n?.includes(f.id)?void 0:m?"Diff":"Deleted",diff:m}}),x=c?.filter(f=>f.id===xa).map(f=>({...f,matchingStatus:"New"}))??[];return d.push(...x),d},[e,t,n]),i=qr({data:a,columns:Lr,getCoreRowModel:Yr(),onSortingChange:o,getSortedRowModel:Wr(),getPaginationRowModel:ya(),state:{sorting:s},initialState:{pagination:{pageIndex:0,pageSize:10},sorting:[{id:"invoiceDate",desc:!0}]}});return r.jsxs(r.Fragment,{children:[r.jsxs(jn,{children:[r.jsx(bn,{children:i.getHeaderGroups().map(l=>r.jsx(Ye,{children:l.headers.map(c=>r.jsx(Ne,{className:"text-center",colSpan:c.colSpan,children:c.isPlaceholder?null:Pt(c.column.columnDef.header,c.getContext())},c.id))},l.id))}),r.jsx(Cn,{children:i.getRowModel().rows?.length?i.getRowModel().rows.map(l=>r.jsx(Ye,{"data-state":l.getIsSelected()&&"selected",className:$u(l.original.matchingStatus),children:l.getVisibleCells().map(c=>r.jsx(Ie,{children:Pt(c.column.columnDef.cell,c.getContext())},c.id))},l.id)):r.jsx(Ye,{children:r.jsx(Ie,{colSpan:Lr.length,className:"h-24 text-center",children:"No results."})})})]}),r.jsx("div",{className:"flex items-center justify-end space-x-2 py-4",children:r.jsx(va,{value:i.getState().pagination.pageIndex,total:i.getPageCount(),onChange:l=>i.setPageIndex(l)})})]})},ku=({data:e})=>{const t=L(ps,e);return t?.errorsLedger?.validate?.errors?.length?r.jsxs(fs,{shadow:"xs",p:"md",children:[r.jsx(Xe,{c:"red",children:"Errors:"}),r.jsx(Hn,{size:"sm",withPadding:!0,children:t.errorsLedger.validate.errors.map((n,s)=>r.jsx(Hn.Item,{children:r.jsx(Xe,{c:"red",children:n})},s))})]}):null},Ru=({transactionsProps:e,onChange:t})=>{const{transactions:n}=L(gs,e);return r.jsx(bs,{transactionsProps:n,onChange:t,enableEdit:!0})},Mu=({chargeId:e})=>{const[{data:t,fetching:n}]=Qe({query:ja,variables:{chargeId:e}}),s=g.useMemo(()=>t?.depositByCharge?.transactions?.filter(o=>o.chargeId!==e)??[],[t?.depositByCharge?.transactions,e]);return n?r.jsx(is,{className:"h-10 w-10 animate-spin"}):t?.depositByCharge?r.jsxs("div",{children:[r.jsxs("div",{className:"text-lg font-semibold mb-4",children:['Bank Deposit "',t?.depositByCharge?.id,'" Balance:'," ",t?.depositByCharge?.balance.formatted]}),r.jsx("div",{className:"mb-4",children:r.jsx("span",{className:"text-sm text-gray-500",children:t?.depositByCharge?.isOpen?"Deposit is open":"Deposit is closed"})}),s.length===0?r.jsx("div",{className:"text-sm text-gray-500",children:"No transactions found for this deposit."}):r.jsx(bs,{transactionsProps:s,enableChargeLink:!0})]}):r.jsx("div",{className:"text-sm text-gray-500",children:"No bank deposit found for this charge."})},zu=({chargeProps:e})=>{const t=L(ms,e);if(t.__typename!=="ConversionCharge")return r.jsx(r.Fragment,{});const{eventRate:n,officialRate:s}=t;return r.jsxs(Xt,{justify:"center",children:[s&&r.jsx(Xt.Col,{span:"content",children:r.jsx(Kn,{shadow:"sm",padding:"xs",radius:"md",withBorder:!0,children:r.jsxs(an,{position:"apart",children:[r.jsx(Xe,{weight:500,children:"Official Conversion Rate"}),r.jsx(ln,{color:"green",variant:"light",children:`${Number(s.rate)} ${tt(s.from)} => ${tt(s.to)}`})]})})}),n&&r.jsx(Xt.Col,{span:"content",children:r.jsx(Kn,{shadow:"sm",padding:"xs",radius:"md",withBorder:!0,children:r.jsxs(an,{position:"apart",children:[r.jsx(Xe,{weight:500,children:"Bank Conversion Rate"}),r.jsx(ln,{color:"green",variant:"light",children:`${Number(n.rate)} ${tt(n.from)} => ${tt(n.to)}`})]})})})]})},Lu=({chargeProps:e})=>{const t=L(hs,e),n=g.useMemo(()=>t.__typename==="CreditcardBankCharge"&&t.creditCardTransactions?t.creditCardTransactions.map(s=>L(ba,s)):[],[t]);return n.length?r.jsxs(jn,{children:[r.jsx(bn,{children:r.jsxs(Ye,{children:[r.jsx(Ne,{children:"Event Date"}),r.jsx(Ne,{children:"Debit Date"}),r.jsx(Ne,{children:"Amount"}),r.jsx(Ne,{children:"Account"}),r.jsx(Ne,{children:"Description"}),r.jsx(Ne,{children:"Reference#"}),r.jsx(Ne,{children:"Counterparty"}),r.jsx(Ne,{children:"Charge"})]})}),r.jsx(Cn,{children:n.map(s=>{const o={...s,onUpdate:()=>{},editTransaction:()=>{},enableEdit:!1,enableChargeLink:!1};return r.jsxs(Ye,{children:[r.jsx(Ie,{children:r.jsx(Na,{transaction:o})}),r.jsx(Ie,{children:r.jsx($a,{transaction:o})}),r.jsx(Ie,{children:r.jsx(Fa,{transaction:o})}),r.jsx(Ie,{children:r.jsx(ka,{transaction:o})}),r.jsx(Ie,{children:r.jsx(Ra,{transaction:o})}),r.jsx(Ie,{children:r.jsx(Ma,{transaction:o})}),r.jsx(Ie,{children:r.jsx(za,{transaction:o})}),r.jsx(Ie,{children:r.jsx(La,{chargeId:s.chargeId})})]},s.id)})})]}):null},Bu=({chargeProps:e})=>{const t=L(xs,e),n=g.useMemo(()=>t.__typename!=="FinancialCharge"?[]:Object.entries(t.exchangeRates??{}).sort((s,o)=>s[0].localeCompare(o[0])),[t]);return t.__typename!=="FinancialCharge"?r.jsx(r.Fragment,{}):r.jsx("div",{className:"flex flex-row flex-wrap gap-2 px-2",children:n.map(([s,o])=>r.jsx(Xr,{className:"gap-0 py-2",children:r.jsxs(Ca,{className:"flex flex-col px-2",children:[r.jsx(Da,{className:"text-xl font-semibold",children:s.toLocaleUpperCase()}),r.jsxs("div",{className:"flex items-center space-x-2",children:[r.jsxs("span",{className:"whitespace-nowrap",children:[tt(s.toLocaleUpperCase()),"1="]}),r.jsxs(us,{variant:"default",className:"flex gap-1 rounded-lg text-md",children:[tt(Dn.Ils),o]})]})]})},s))})},Vu="deleteMiscExpense",Uu=()=>{const[{fetching:e},t]=Pe(Sa),n=g.useCallback(async s=>{const o="Error deleting misc expense",a=`${Vu}-${s.id}`;F.loading("Deleting misc expense",{id:a});try{const i=await t(s),l=Ae(i,o,a);if(l)return F.success("Success",{id:a,description:"Misc expense was deleted successfully"}),l.deleteMiscExpense}catch(i){console.error(`${o}: ${i}`),F.error("Error",{id:a,description:o,duration:1e5,closeButton:!0})}},[t]);return{fetching:e,deleteMiscExpense:n}};function Hu({miscExpenseId:e,onChange:t}){const{deleteMiscExpense:n}=Uu();async function s(){try{await n({id:e}),t?.()}catch(o){const a="Failed to delete misc expense";console.error(`${a}: ${o}`),F.error("Error",{description:a})}}return r.jsx(Gt,{onConfirm:s,title:"Are you sure you want to delete this expense?",children:r.jsx(X,{className:"size-7.5 text-red-500",variant:"ghost",children:r.jsx(Sn,{className:"size-5"})})})}const Ku=({miscExpensesData:e,onChange:t})=>{const n=L(ys,e),{miscExpenses:s}=n;return r.jsxs("table",{className:"w-full h-full",children:[r.jsx("thead",{children:r.jsxs("tr",{children:[r.jsx("th",{children:"Creditor"}),r.jsx("th",{children:"Debtor"}),r.jsx("th",{children:"Amount"}),r.jsx("th",{children:"Invoice Date"}),r.jsx("th",{children:"Value Date"}),r.jsx("th",{children:"Description"}),r.jsx("th",{children:"Actions"})]})}),r.jsx("tbody",{children:s?.map(o=>r.jsxs("tr",{children:[r.jsx("td",{children:r.jsx("div",{children:o.creditor?.name})}),r.jsx("td",{children:r.jsx("div",{children:o.debtor?.name})}),r.jsx("td",{children:r.jsx("div",{children:o.amount?.formatted})}),r.jsx("td",{children:r.jsx("div",{children:o.invoiceDate})}),r.jsx("td",{children:r.jsx("div",{children:o.valueDate&&Be(new Date(o.valueDate),"yyyy-MM-dd")})}),r.jsx("td",{children:r.jsx("div",{children:o.description})}),r.jsxs("td",{children:[r.jsx(rd,{onDone:t,data:o}),r.jsx(Hu,{miscExpenseId:o.id,onChange:t})]})]},o?.id))})]})},Gu=({salaryRecordsProps:e})=>{const t=L(vs,e);if(t.__typename!=="SalaryCharge")return r.jsx(r.Fragment,{});const{salaryRecords:n}=t;return r.jsxs("table",{className:"w-full h-full",children:[r.jsx("thead",{children:r.jsxs("tr",{children:[r.jsx("th",{children:"Employee"}),r.jsx("th",{children:"Direct Salary"}),r.jsx("th",{children:"Base Salary"}),r.jsx("th",{children:"Pension"}),r.jsx("th",{children:"Training Fund"}),r.jsx("th",{children:"Social Security"}),r.jsx("th",{children:"Tax"})]})}),r.jsx("tbody",{children:n?.map(s=>r.jsxs("tr",{children:[r.jsx("td",{children:r.jsx("div",{children:s.employee?.name??"Missing"})}),r.jsx("td",{children:r.jsx("div",{children:s.directAmount.formatted})}),r.jsx("td",{children:r.jsx("div",{children:s.baseAmount?.formatted})}),r.jsxs("td",{children:[r.jsx("div",{children:s.pensionFund?.name}),r.jsxs("div",{children:["Employee: ",s.pensionEmployeeAmount?.formatted]}),r.jsxs("div",{children:["Employer: ",s.pensionEmployerAmount?.formatted]}),r.jsxs("div",{children:["Compensation: ",s.compensationsAmount?.formatted]})]}),r.jsxs("td",{children:[r.jsx("div",{children:s.trainingFund?.name}),r.jsxs("div",{children:["Employee: ",s.trainingFundEmployeeAmount?.formatted]}),r.jsxs("div",{children:["Employer: ",s.trainingFundEmployerAmount?.formatted]})]}),r.jsxs("td",{children:[r.jsxs("div",{children:["Employee: ",s.socialSecurityEmployeeAmount?.formatted]}),r.jsxs("div",{children:["Employer: ",s.socialSecurityEmployerAmount?.formatted]}),r.jsxs("div",{children:["Health: ",s.healthInsuranceAmount?.formatted]})]}),r.jsx("td",{children:r.jsx("div",{children:s.incomeTaxAmount?.formatted})})]},`${s.employee?.name}-${s.baseAmount}`))})]})};function qu({chargeID:e,onChange:t=()=>{},fetching:n}){const[s,o]=g.useState([]),[a,i]=g.useState(e),[l,{toggle:c}]=gt(!1),[d,x]=g.useState(void 0),[{data:f,fetching:m},y]=Qe({query:_e,variables:{chargeId:a}}),p=g.useCallback(()=>{y(),t()},[y,t]);g.useEffect(()=>{f?.charge&&x(f.charge)},[f]),g.useEffect(()=>{n&&y()},[n,y]),g.useEffect(()=>{e!==a&&(i(e),y())},[e,a,y]);const u=d?.__typename,v=!!d?.metadata?.ledgerCount,h=!!d?.metadata?.transactionsCount,j=!!d?.metadata?.documentsCount,C=!!d?.metadata?.receiptsCount,I=u==="SalaryCharge",O=!!d?.miscExpenses?.length,_=d?.metadata?.openDocuments,b=(d?.totalAmount?.raw??0)>0&&!C;g.useEffect(()=>{const M=[];h&&M.push("transactions"),j&&M.push("documents"),v&&M.push("ledger"),I&&M.push("salaries"),O&&M.push("miscExpenses"),u==="BankDepositCharge"&&M.push("bankDeposit"),o(M)},[h,j,v,I,O,u]);function w(M){s.includes(M)?o(B=>B.filter(he=>he!==M)):o(B=>[...B,M])}const A=je(_e,ds,d),k=je(_e,Un,d),N=je(_e,js,d),G=je(_e,gs,d),Y=je(_e,ys,d),R=g.useMemo(()=>u==="ConversionCharge"&&je(_e,ms,d),[d,u]),z=g.useMemo(()=>u==="FinancialCharge"&&je(_e,xs,d),[d,u]),le=u==="SalaryCharge"&&je(_e,vs,d),ie=g.useMemo(()=>u==="CreditcardBankCharge"&&je(_e,hs,d),[d,u]);return r.jsxs("div",{className:"flex flex-col gap-5",children:[m&&r.jsx(jt,{className:"flex self-center my-5",color:"dark",size:"xl",variant:"dots"}),je(_e,ps,d)&&r.jsx(ku,{data:d}),d&&r.jsxs("div",{className:"flex flex-row",children:[r.jsxs(U,{className:"w-full",multiple:!0,value:s,chevron:r.jsx(ns,{size:"1rem"}),styles:{chevron:{"&[data-rotate]":{transform:"rotate(45deg)"}}},children:[u==="ConversionCharge"&&r.jsxs(U.Item,{value:"conversion",children:[r.jsx(U.Control,{disabled:!h,onClick:()=>w("conversion"),children:"Conversion Info"}),r.jsx(U.Panel,{children:R&&r.jsx(zu,{chargeProps:d})})]}),u==="FinancialCharge"&&r.jsxs(U.Item,{value:"exchangeRates",children:[r.jsx(U.Control,{disabled:!z,onClick:()=>w("exchangeRates"),children:"Exchange Rates"}),r.jsx(U.Panel,{children:z&&r.jsx(Bu,{chargeProps:d})})]}),h&&r.jsxs(U.Item,{value:"transactions",children:[r.jsx(U.Control,{disabled:!h,onClick:()=>w("transactions"),children:r.jsxs("div",{className:"flex flex-row items-center gap-2 justify-between w-full",children:["Transactions",b&&r.jsx(cn,{chargeId:d.id})]})}),r.jsx(U.Panel,{children:G&&r.jsx(Ru,{transactionsProps:d,onChange:p})})]}),O&&r.jsxs(U.Item,{value:"miscExpenses",children:[r.jsx(U.Control,{disabled:!O,onClick:()=>w("miscExpenses"),children:"Misc Expenses"}),r.jsx(U.Panel,{children:Y&&r.jsx(Ku,{miscExpensesData:d,onChange:p})})]}),j&&r.jsxs(U.Item,{value:"documents",children:[r.jsx(U.Control,{disabled:!j,onClick:()=>w("documents"),children:r.jsxs("div",{className:"flex flex-row items-center gap-2 justify-between w-full",children:[r.jsxs("div",{className:"flex flex-row items-center gap-2 justify-start",children:[j&&r.jsx(Le,{label:"Documents Gallery",children:r.jsx(X,{onClick:M=>{M.stopPropagation(),c()},variant:"outline",disabled:!A,size:"icon",className:"size-7.5 text-gray-500",children:r.jsx(wa,{className:"size-5"})})}),"Documents"]}),_&&r.jsx(cn,{chargeId:d.id})]})}),r.jsx(U.Panel,{children:k&&r.jsx(_a,{documentsProps:L(Un,d)?.additionalDocuments,onChange:p})})]}),u==="SalaryCharge"&&r.jsxs(U.Item,{value:"salaries",children:[r.jsx(U.Control,{disabled:!I,onClick:()=>w("salaries"),children:"Salaries"}),r.jsx(U.Panel,{children:le&&r.jsx(Gu,{salaryRecordsProps:d})})]}),d.__typename==="BusinessTripCharge"&&r.jsxs(U.Item,{value:"businessTrip",children:[r.jsx(U.Control,{onClick:()=>w("businessTrip"),children:"Business Trip"}),r.jsx(U.Panel,{children:r.jsx(pc,{data:d.businessTrip})})]}),u==="CreditcardBankCharge"&&r.jsxs(U.Item,{value:"creditcard",children:[r.jsx(U.Control,{onClick:()=>w("creditcard"),children:"CreditCard Transactions"}),r.jsx(U.Panel,{children:ie&&r.jsx(Lu,{chargeProps:d})})]}),u==="BankDepositCharge"&&r.jsxs(U.Item,{value:"bankDeposit",children:[r.jsx(U.Control,{onClick:()=>w("bankDeposit"),children:"Bank Deposit"}),r.jsx(U.Panel,{children:r.jsx(Mu,{chargeId:d.id})})]}),v&&r.jsxs(U.Item,{value:"ledger",children:[r.jsx(U.Control,{disabled:!v,onClick:M=>{M.stopPropagation(),w("ledger")},children:r.jsxs("div",{className:"flex flex-row items-center gap-2 justify-start w-full",children:[!d.metadata?.isLedgerLocked&&r.jsx(yc,{chargeId:d.id,onChange:p,variant:"outline"}),"Ledger Records"]})}),r.jsx(U.Panel,{children:N&&r.jsx(Wu,{data:d})})]})]}),A&&r.jsx(He,{maw:"1/6",children:r.jsx(Ha,{in:l,transitionDuration:500,transitionTimingFunction:"linear",children:r.jsx(Nu,{chargeProps:d,onChange:p})})})]}),!m&&!d&&r.jsx("p",{children:"Error fetching extended information for this charge"})]})}const Wu=({data:e})=>{const{ledger:t}=L(js,e);return r.jsx(Fu,{ledgerRecordsData:t.records,ledgerDiffData:t.validate?.differences,matches:t.validate?.matches})},Yu=({setEditCharge:e,setInsertDocument:t,setMatchDocuments:n,toggleMergeCharge:s,isSelectedForMerge:o,data:a,isAllOpened:i})=>{const[l,c]=g.useState(!1),[d,x]=g.useState(L(qe,a)),[{data:f,fetching:m},y]=Qe({query:Ia,pause:!0,variables:{chargeId:a.id}}),p=y;g.useEffect(()=>{const h=f?.charge;h&&x(L(qe,h))},[f]),g.useEffect(()=>{x(L(qe,a))},[a]),g.useEffect(()=>{c(i)},[i]);const u=g.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]),v=(d?.totalAmount?.raw??0)>0;return r.jsxs(r.Fragment,{children:[r.jsxs("tr",{onClick:()=>{u&&(c(h=>!h),p())},children:[r.jsx(vd,{data:d}),r.jsx(gd,{data:d}),r.jsx(ud,{data:d}),r.jsx(jd,{data:d}),je(qe,Qr,d)?r.jsx(pd,{data:d}):r.jsx("td",{}),r.jsx(md,{data:d,onChange:p}),je(qe,es,d)?r.jsx(xd,{data:d,onChange:p}):r.jsx("td",{}),je(qe,ts,d)?r.jsx(yd,{data:d}):r.jsx("td",{}),je(qe,Jr,d)?r.jsx(fd,{data:d}):r.jsx("td",{}),r.jsx(hd,{data:d}),r.jsx(dd,{data:d,onChange:p}),r.jsx("td",{children:r.jsxs("div",{className:"flex flex-col gap-2",children:[e&&r.jsx(Ea,{onClick:h=>{h.stopPropagation(),e(p)}}),s&&r.jsx(vc,{toggleMergeSelected:()=>s(p),mergeSelected:o})]})}),r.jsx("td",{children:r.jsxs("div",{className:"flex flex-col gap-2",children:[r.jsx(Ad,{chargeId:d.id,chargeType:d.__typename,setInsertDocument:t?()=>t(p):void 0,setMatchDocuments:n,onChange:p,isIncome:v}),u&&r.jsx(Pa,{toggleExpansion:c,isExpanded:l,onClickAction:()=>p()})]})})]}),u&&l&&r.jsx("tr",{children:r.jsx("td",{colSpan:13,children:r.jsx(fs,{style:{width:"100%"},withBorder:!0,shadow:"lg",children:r.jsx(qu,{chargeID:d.id,onChange:p,fetching:m})})})})]})},nf=({setEditChargeId:e,setInsertDocument:t,setMatchDocuments:n,toggleMergeCharge:s,mergeSelectedCharges:o,data:a,isAllOpened:i})=>{const l=a?.map(c=>L(Oa,c))??[];return r.jsxs(Cs,{striped:!0,highlightOnHover:!0,children:[r.jsx("thead",{className:"sticky top-0 z-20",children:r.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:[r.jsx("th",{children:"Type"}),r.jsx("th",{children:"Date"}),r.jsx("th",{children:"Amount"}),r.jsx("th",{children:"Vat"}),r.jsx("th",{children:"Counterparty"}),r.jsx("th",{children:"Description"}),r.jsx("th",{children:"Tags"}),r.jsx("th",{children:"Tax Category"}),r.jsx("th",{children:"Business Trip"}),r.jsx("th",{children:"More Info"}),r.jsx("th",{children:"Accountant Approval"}),r.jsx("th",{children:"Edit"}),r.jsx("th",{children:"More Info"})]})}),r.jsx("tbody",{children:l?.map(c=>r.jsx(Yu,{data:c,setEditCharge:e?d=>e({id:c.id,onChange:d}):void 0,setInsertDocument:t?d=>t({id:c.id,onChange:d}):void 0,setMatchDocuments:n?()=>n({id:c.id,ownerId:c.owner.id}):void 0,toggleMergeCharge:s?d=>s(c.id,d):void 0,isSelectedForMerge:o?.has(c.id)??!1,isAllOpened:i},c.id))})]})};export{nf as C,Fu as L,id as S,zs as T,vc as a,qu as b,so as c,Ls as d,oo as e,Ds as f,ld as u};
62
+ `)}`),activateOnClick:!1,activateOnKeyboard:!1,radius:0,padding:0,maxFiles:1/0,loading:n,sx:()=>({border:0,cursor:"default",width:"100%",height:"100%",zIndex:1}),children:e})},so=({items:e,extraClassName:t=""})=>{const n=["text-sm font-medium text-gray-900 bg-white border border-gray-200 rounded-lg",t].join(" ");return r.jsx("ul",{className:n,children:e.map((s,o)=>{const a=["w-full px-4 py-2",o===e.length-1?"rounded-b-lg":"border-b",o===0?"rounded-t-lg":"","border-gray-200",s&&typeof s=="object"&&"extraClassName"in s?s.extraClassName??"":""].join(" ");return r.jsx("li",{className:a,children:s&&typeof s=="object"&&"content"in s?s.content:s},o)})})},rd=({onDone:e,data:t})=>{const[n,s]=g.useState(!1);function o(){s(!1),e?.()}return r.jsxs(yn,{open:n,onOpenChange:s,children:[r.jsx(Bo,{asChild:!0,children:r.jsx(Le,{label:"Edit Misc Expense",children:r.jsx(Q,{variant:"ghost",size:"icon",className:"size-7.5",children:r.jsx(Gr,{className:"size-5"})})})}),r.jsx(vn,{className:"sm:max-w-[425px]",children:r.jsx(Dc,{onDone:o,data:t})})]})},sd="batchUpdateCharges",od=()=>{const[{fetching:e},t]=Pe(Vo),n=g.useCallback(async s=>{const o=Array.isArray(s.chargeIds)?s.chargeIds:[s.chargeIds],a=`Error updating charge IDs [${o.join(", ")}]`,i=`${sd}-${o[0]}`;F.loading("Updating charge",{id:i});try{const l=await t(s),c=Ae(l,a,i,"batchUpdateCharges");if(c)return F.success("Success",{id:i,description:`${o.length} charge${o.length>1?"s":""} updated`}),c.batchUpdateCharges.charges}catch(l){console.error(`${a}: ${l}`),F.error("Error",{id:i,description:a,duration:1e5,closeButton:!0})}},[t]);return{fetching:e,batchUpdateCharges:n}},ad=[{id:"select",header:({table:e})=>r.jsx(Ln,{checked:e.getIsAllPageRowsSelected()||e.getIsSomePageRowsSelected()&&"indeterminate",onCheckedChange:t=>e.toggleAllPageRowsSelected(!!t),"aria-label":"Select all"}),cell:({row:e})=>r.jsx(Ln,{checked:e.getIsSelected(),onCheckedChange:t=>e.toggleSelected(!!t),"aria-label":"Select row"}),enableSorting:!1,enableHiding:!1},{accessorKey:"chargeType",header:"Type",cell:({row:e})=>r.jsx("div",{children:e.getValue("chargeType")})},{accessorKey:"counterpartyName",header:"Counterparty",cell:({row:e})=>r.jsx("div",{children:e.getValue("counterpartyName")})},{accessorKey:"date",header:"Date",cell:({row:e})=>{const t=e.getValue("date");return r.jsx("div",{children:t?Be(new Date(t),"yyyy-MM-dd"):"Missing"})}},{accessorKey:"amountRaw",header:"Amount",cell:({row:e})=>r.jsx("div",{children:e.original.amountFormatted})},{accessorKey:"vatAmountRaw",header:"VAT Amount",cell:({row:e})=>r.jsx("div",{children:e.original.vatAmountFormatted})},{accessorKey:"description",header:"Description",cell:({row:e})=>r.jsx("div",{children:e.getValue("description")})},{accessorKey:"taxCategoryName",header:"Tax Category",cell:({row:e})=>r.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?r.jsx("div",{children:"No tags"}):r.jsx("div",{children:t.join(" | ")})}},{accessorKey:"businessTripName",header:"Business Trip",cell:({row:e})=>r.jsx("div",{children:e.getValue("businessTripName")})},{accessorKey:"moreInfo",header:"More Info",cell:({row:e})=>{const t=e.original.transactions||0,n=e.original.documents||0,s=e.original.miscExpenses||0,o=e.original.ledgerRecords||0;return r.jsxs("div",{className:"flex flex-col justify-center text-sm",children:[t>0&&r.jsxs("div",{children:["Transactions: ",t]}),n>0&&r.jsxs("div",{children:["Documents: ",n]}),s>0&&r.jsxs("div",{children:["Misc Expenses: ",s]}),o>0&&r.jsxs("div",{children:["Ledger Records: ",o]})]})},enableSorting:!1}];function id({data:e,tagIds:t,description:n,onOpenChange:s,title:o="Similar Charges"}){const[a,i]=N.useState([]),[l,c]=N.useState({}),d=g.useMemo(()=>e.map(p=>L(Uo,p)),[e]),x=g.useMemo(()=>d.map(u=>({id:u.id,chargeType:Ss(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(v=>v.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]);g.useEffect(()=>{e&&x.length===0&&s(!1)},[e,x.length,s]);const f=qr({data:x,columns:ad,onSortingChange:i,getCoreRowModel:Yr(),getSortedRowModel:Wr(),onRowSelectionChange:c,state:{sorting:a,rowSelection:l}}),{batchUpdateCharges:m}=od(),y=g.useCallback(async()=>{const p=f.getSelectedRowModel().rows.map(u=>u.original.id);await m({chargeIds:p,fields:{...t?{tags:t}:{},...n?{userDescription:n}:{}}}),s(!1)},[m,s,f,t,n]);return g.useEffect(()=>{e.length===0&&s(!1)},[e.length,s]),e.length?r.jsxs(r.Fragment,{children:[r.jsxs(Ho,{className:"flex flex-row items-center justify-between",children:[r.jsx(Ko,{children:o}),r.jsx(Q,{onClick:y,children:"Approve selected"})]}),r.jsx(Qr,{children:r.jsxs(jn,{children:[r.jsx(bn,{children:f.getHeaderGroups().map(p=>r.jsx(Ye,{children:p.headers.map(u=>r.jsx(Te,{children:u.isPlaceholder?null:Pt(u.column.columnDef.header,u.getContext())},u.id))},p.id))}),r.jsx(Cn,{children:f.getRowModel().rows.map(p=>r.jsx(Ye,{"data-state":p.getIsSelected()&&"selected",children:p.getVisibleCells().map(u=>r.jsx(Ie,{children:Pt(u.column.columnDef.cell,u.getContext())},u.id))},p.id))})]})})]}):null}function oo({chargeId:e,tagIds:t,description:n,open:s,onOpenChange:o,onClose:a,showChargesWithExistingSuggestions:i=!1}){const[{data:l,fetching:c},d]=Xe({pause:!0,query:Go,variables:{chargeId:e,withMissingTags:i?!1:!!t,withMissingDescription:i?!1:!!n,tagsDifferentThan:i&&t?t.map(m=>m.id):void 0,descriptionDifferentThan:i?n:void 0}});g.useEffect(()=>{s&&(t||n)&&!l&&d()},[s,t,n,d,l]);const x=g.useCallback(m=>{o(m),s&&!m&&a?.()},[o,a,s]);g.useEffect(()=>{s&&!c&&l?.similarCharges.length===0&&a?.()},[s,c,l,a]);const f=g.useMemo(()=>s&&(!!t||!!n)&&l&&l?.similarCharges.length>0,[s,t,n,l]);return r.jsx(yn,{open:f,onOpenChange:x,children:r.jsx(vn,{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:r.jsx(qo,{fallback:r.jsx("div",{children:"Error fetching similar charges"}),children:c?r.jsx(Wo,{}):t||n?r.jsx(id,{data:l?.similarCharges??[],tagIds:t,description:n,onOpenChange:x}):null})})})}const cd="updateChargeAccountantApproval",ld=()=>{const[{fetching:e},t]=Pe(Yo),n=g.useCallback(async s=>{const o=`Error toggling accountant approval to ledger record ID [${s.chargeId}]`,a=`${cd}-${s.chargeId}`;F.loading("Updating approval status",{id:a});try{const i=await t(s),l=Ae(i,o,a,"updateChargeAccountantApproval");if(l)return F.success("Success",{id:a,description:"Accountant approval was updated"}),l.updateChargeAccountantApproval}catch(i){console.error(`${o}: ${i}`),F.error("Error",{id:a,description:o,duration:1e5,closeButton:!0})}},[t]);return{fetching:e,updateChargeAccountantApproval:n}};function dd({data:e,onChange:t}){const n=L(Jo,e),[s,o]=g.useState(n.accountantApproval),{updateChargeAccountantApproval:a}=ld();return g.useEffect(()=>{s==null&&n.accountantApproval!=null&&o(n.accountantApproval)},[s,n.accountantApproval]),r.jsx("td",{children:r.jsx(Qo,{value:s,onChange:i=>a({chargeId:n.id,status:i}).then(t)})})}const ud=({data:e})=>{const t=L(Xo,e),[n,s]=g.useState(!0),[o,a]=g.useState(!0),i="validCreditCardAmount"in t?t.validCreditCardAmount:null;return g.useEffect(()=>{t.__typename==="CreditcardBankCharge"&&(a(i==null),i!=null&&s(i))},[t.__typename,i]),r.jsx("td",{children:r.jsx("div",{children:r.jsx(Re,{inline:!0,size:12,disabled:n,processing:o,color:"red",zIndex:"auto",children:r.jsx("p",{className:(t.totalAmount?.raw??0)>0?"whitespace-nowrap text-green-700":"whitespace-nowrap text-red-500",children:t.totalAmount?.formatted})})})})},fd=({data:e})=>{const t=L(Jr,e);return"businessTrip"in t?r.jsx("td",{children:r.jsx(At,{to:t.businessTrip?.id?mt.BUSINESS_TRIPS.DETAIL(t.businessTrip?.id):mt.BUSINESS_TRIPS.ROOT,target:"_blank",rel:"noreferrer",onClick:n=>n.stopPropagation(),className:"inline-flex items-center font-semibold",children:t.businessTrip?.name})}):r.jsx("td",{})},pd=({data:e})=>{const{counterparty:t,validationData:n,__typename:s}=L(Xr,e),o=g.useMemo(()=>{switch(s){case"BusinessTripCharge":case"DividendCharge":case"ConversionCharge":case"SalaryCharge":case"InternalTransferCharge":return!1;default:return!0}},[s]),a=g.useMemo(()=>o&&n?.missingInfo?.includes(ze.Counterparty),[o,n?.missingInfo]),{name:i,id:l}=t??{name:"Missing",id:void 0};return r.jsx("td",{children:r.jsx("div",{className:"flex flex-wrap",children:r.jsxs(Re,{inline:!0,size:12,disabled:!a,color:"red",zIndex:"auto",children:[!a&&l&&r.jsx(At,{to:mt.BUSINESSES.DETAIL(l),target:"_blank",rel:"noreferrer",onClick:c=>c.stopPropagation(),className:"inline-flex items-center font-semibold",children:i}),a&&i]})})})},gd=({data:e})=>{const t=L(Zo,e),{minDebitDate:n,minEventDate:s,minDocumentsDate:o}=t,a=n||s||o;return r.jsx("td",{children:r.jsx("div",{children:a&&Be(new Date(a),"dd/MM/yy")})})},md=({data:e,onChange:t})=>{const[n,s]=g.useState(!1),o=L(ea,e),a=g.useMemo(()=>o?.validationData?.missingInfo?.includes(ze.Description),[o?.validationData?.missingInfo]),i=g.useMemo(()=>a&&!!o.missingInfoSuggestions?.description?.trim().length,[a,o.missingInfoSuggestions?.description]),{userDescription:l,id:c}=o,d=g.useMemo(()=>l&&l?.trim()!==""?l:o.missingInfoSuggestions?.description?o.missingInfoSuggestions.description:"Missing",[l,o.missingInfoSuggestions?.description]),{updateCharge:x,fetching:f}=Ls(),m=g.useCallback(async y=>{y!==void 0&&(await x({chargeId:c,fields:{userDescription:y}}),s(!0))},[c,x]);return r.jsxs("td",{children:[r.jsxs("div",{className:"flex flex-wrap",children:[r.jsx("div",{className:"flex flex-col justify-center",children:r.jsx(Re,{inline:!0,size:12,disabled:!a,color:"red",zIndex:"auto",children:r.jsx("p",{className:i?"bg-yellow-400":void 0,children:d})})}),i&&r.jsx(Zr,{onClick:y=>{y.stopPropagation(),m(o.missingInfoSuggestions.description)},disabled:f})]}),r.jsx(oo,{chargeId:c,description:o.missingInfoSuggestions?.description??void 0,open:n,onOpenChange:s,onClose:t})]})},hd=({data:e})=>{const t=L(ta,e),{metadata:n,validationData:s,id:o,__typename:a}=t,i=g.useMemo(()=>{switch(a){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}},[a]),l=g.useMemo(()=>{switch(a){case"FinancialCharge":return!1;default:return!0}},[a]),c=g.useMemo(()=>l&&s?.missingInfo?.includes(ze.Transactions),[l,s?.missingInfo]),d=g.useMemo(()=>i&&s?.missingInfo?.includes(ze.Documents),[i,s?.missingInfo]),x=g.useMemo(()=>!n?.invalidLedger,[n?.invalidLedger]),f=g.useMemo(()=>n?.invalidLedger,[n?.invalidLedger]),m=g.useMemo(()=>{const y=[];return(c||n?.transactionsCount||l)&&y.push({extraClassName:n?.transactionsCount||!l?void 0:"bg-yellow-400",content:r.jsx(Re,{inline:!0,size:12,disabled:!c,color:"red",zIndex:"auto",children:r.jsxs("div",{className:"whitespace-nowrap",children:["Transactions: ",n?.transactionsCount??0]})},"transactions")}),y.push({content:r.jsx(Re,{inline:!0,size:12,processing:x,disabled:f==="VALID",color:f==="DIFF"?"orange":"red",zIndex:"auto",children:r.jsxs("div",{className:"whitespace-nowrap",children:["Ledger Records: ",n?.ledgerCount??0]})},"ledger")}),(d||n?.documentsCount)&&y.push({content:r.jsx(Re,{inline:!0,size:12,disabled:!d,color:"red",zIndex:"auto",children:r.jsxs("div",{className:"whitespace-nowrap",children:["Documents: ",n?.documentsCount??0]})},"documents"),extraClassName:!s?.missingInfo?.includes(ze.Documents)||!i?void 0:"bg-yellow-400"}),n?.miscExpensesCount&&y.push({content:r.jsxs("div",{className:"whitespace-nowrap",children:["Misc Expenses: ",n?.miscExpensesCount??0]})}),y},[n?.transactionsCount,n?.ledgerCount,n?.documentsCount,n?.miscExpensesCount,i,l,c,d,s?.missingInfo,f,x]);return r.jsx("td",{children:r.jsx(nd,{chargeId:o,children:r.jsx(so,{items:m})})})},xd=({data:e,onChange:t})=>{const{tags:n,id:s,validationData:o,missingInfoSuggestions:a}=L(es,e),{updateCharge:i,fetching:l}=Ls(),[c,d]=g.useState(n??[]),[x,f]=g.useState(!1),m=o?.missingInfo?.includes(ze.Tags),y=m&&!!a?.tags?.length;g.useEffect(()=>{n?.length&&!c.length&&d(n)},[n,c.length]),g.useEffect(()=>{c.length===0&&y&&d(a?.tags??[])},[c.length,y,a?.tags]);const p=g.useCallback(async u=>{await i({chargeId:s,fields:{tags:u?.map(v=>({id:v.id}))}}),f(!0)},[s,i]);return r.jsxs("td",{children:[r.jsx(Re,{inline:!0,size:12,disabled:!m,color:"red",zIndex:"auto",children:r.jsx(so,{items:c.map(u=>r.jsx(an,{children:r.jsxs("div",{children:[u.namePath&&r.jsx(Qe,{size:"xs",opacity:.65,children:`${u.namePath.join(" > ")} >`}),r.jsx(Qe,{size:"sm",children:u.name})]})},u.id)),extraClassName:y?"bg-yellow-400":void 0})}),y&&r.jsx(Zr,{onClick:u=>{u.stopPropagation(),p(a.tags)},disabled:l}),r.jsx(oo,{chargeId:s,tagIds:a?.tags?.map(u=>({id:u.id})),open:x,onOpenChange:f,onClose:t})]})},yd=({data:e})=>{const{validationData:t,taxCategory:n,__typename:s}=L(ts,e),o=g.useMemo(()=>{switch(s){case"DividendCharge":case"InternalTransferCharge":case"SalaryCharge":case"BankDepositCharge":case"ForeignSecuritiesCharge":return!1;default:return!0}},[s]),a=g.useMemo(()=>t?.missingInfo?.includes(ze.TaxCategory),[t?.missingInfo]);return o?r.jsx("td",{children:r.jsx(Re,{inline:!0,size:12,disabled:!a,color:"red",zIndex:"auto",children:n?.name??"N/A"})}):r.jsx("td",{})},vd=({data:e})=>{const t=L(na,e),{__typename:n}=t,{text:s,icon:o}=g.useMemo(()=>({text:Ss(n),icon:pi(n)}),[n]);return r.jsxs("td",{children:[r.jsx("div",{children:s}),r.jsx(zs,{radius:"xl",size:"xl",children:o})]})},jd=({data:e})=>{const{vat:t,totalAmount:n,validationData:s,__typename:o}=L(ra,e),a=g.useMemo(()=>s?.missingInfo?.includes(ze.Vat),[s?.missingInfo]),i=g.useMemo(()=>!t&&n?.currency===Dn.Ils,[t,n?.currency]),l=g.useMemo(()=>(t?.raw??0)>0&&(n?.raw??0)<0||(t?.raw??0)<0&&(n?.raw??0)>0,[t?.raw,n?.raw]),c=i||l;return g.useMemo(()=>{switch(o){case"BusinessTripCharge":case"DividendCharge":case"ConversionCharge":case"SalaryCharge":case"InternalTransferCharge":case"BankDepositCharge":case"ForeignSecuritiesCharge":case"CreditcardBankCharge":return!1;default:return!0}},[o])?r.jsx("td",{children:r.jsx("div",{className:c?"whitespace-nowrap text-red-500":"whitespace-nowrap text-green-700",children:r.jsx(Re,{inline:!0,size:12,disabled:!a,color:"red",zIndex:"auto",children:t?.formatted})})}):r.jsx("td",{})},bd="insertDepreciationRecord",Cd=()=>{const[{fetching:e},t]=Pe(sa),n=g.useCallback(async s=>{const o="Error adding depreciation record",a=bd;F.loading("Adding depreciation record",{id:a});try{const i=await t(s),l=Ae(i,o,a,"insertDepreciationRecord");if(l)return F.success("Success",{id:a,description:"Depreciation record was added"}),l.insertDepreciationRecord}catch(i){console.error(`${o}: ${i}`),F.error("Error",{id:a,description:o,duration:1e5,closeButton:!0})}},[t]);return{fetching:e,addDepreciationRecord:n}};function _r(e){const{chargeId:t,onAdd:n}=e,[s,{close:o,open:a}]=gt(!1);return r.jsxs(r.Fragment,{children:[r.jsx(Le,{label:"Add Depreciation Record",children:r.jsx(Q,{variant:"outline",size:"icon",className:"size-7.5",onClick:i=>{i.stopPropagation(),a()},children:r.jsx(ns,{className:"size-5"})})}),s&&r.jsx(Dd,{chargeId:t,opened:s,close:o,onAdd:n})]})}function Dd({chargeId:e,opened:t,close:n,onAdd:s}){const{control:o,handleSubmit:a}=xn({defaultValues:{chargeId:e}}),[i,l]=g.useState(!1),[{data:c,fetching:d}]=Xe({query:rs}),{addDepreciationRecord:x,fetching:f}=Cd(),m=p=>{x({fields:p}).then(()=>{s?.(),n()})},y=c?.depreciationCategories?.map(p=>({value:p.id,label:p.name}))??[];return g.useEffect(()=>{l(!!(d||f))},[d,f]),r.jsxs(ft,{opened:t,onClose:n,centered:!0,lockScroll:!0,children:[r.jsx(ft.Title,{children:"Add Depreciation Record"}),r.jsx(ft.Body,{children:r.jsxs("form",{onSubmit:a(m),children:[r.jsx($e,{name:"activationDate",control:o,rules:{pattern:{value:ss,message:"Date must be im format yyyy-mm-dd"}},render:({field:{value:p,...u}})=>{const v=p?new Date(p):void 0;return r.jsx(os,{...u,onChange:h=>{const j=h?typeof h=="string"?h:Be(h,"yyyy-MM-dd"):void 0;j!==p&&u.onChange(j)},value:v,label:"Activation Date",popoverProps:{withinPortal:!0}})}}),r.jsx($e,{name:"amount",control:o,render:({field:p,fieldState:u})=>r.jsx($e,{name:"currency",control:o,render:({field:v,fieldState:h})=>r.jsx(as,{...p,value:p.value??void 0,error:u.error?.message||h.error?.message,label:"Amount",currencyCodeProps:{...v,label:"Currency"}})})}),r.jsx($e,{name:"categoryId",control:o,render:({field:p,fieldState:u})=>r.jsx(Nt,{...p,disabled:d,data:y,label:"Category",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:u.error?.message,withinPortal:!0})}),r.jsx($e,{name:"type",control:o,render:({field:p,fieldState:u})=>r.jsx(Nt,{...p,data:ao,value:p.value,label:"Type",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:u.error?.message,withinPortal:!0})}),r.jsx("div",{className:"flex justify-center mt-5 gap-3",children:r.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"})})]})}),(f||i)&&r.jsx(Ur,{blur:1,center:!0,children:r.jsx(jt,{})})]})}const Sd="updateDepreciationRecord",wd=()=>{const[{fetching:e},t]=Pe(oa),n=g.useCallback(async s=>{const o="Error updating depreciation record",a=Sd;F.loading("Updating depreciation record",{id:a});try{const i=await t(s),l=Ae(i,o,a,"updateDepreciationRecord");if(l)return F.success("Success",{id:a,description:"Depreciation record was updated"}),l.updateDepreciationRecord}catch(i){console.error(`${o}: ${i}`),F.error("Error",{id:a,description:o,duration:1e5,closeButton:!0})}},[t]);return{fetching:e,updateDepreciationRecord:n}},_d="deleteDepreciationRecord",Id=()=>{const[{fetching:e},t]=Pe(aa),n=g.useCallback(async s=>{const o="Error deleting depreciation record",a=`${_d}-${s.depreciationRecordId}`;F.loading("Deleting depreciation record",{id:a});try{const i=await t(s),l=Ae(i,o,a);if(l)return F.success("Success",{id:a,description:"Depreciation record was deleted"}),l.deleteDepreciationRecord}catch(i){console.error(`${o}: ${i}`),F.error("Error",{id:a,description:o,duration:1e5,closeButton:!0})}},[t]);return{fetching:e,deleteDepreciationRecord:n}};function Ed(e){const{fetching:t,deleteDepreciationRecord:n}=Id(),s=g.useCallback(()=>{n({depreciationRecordId:e.depreciationRecordId}).then(()=>{e.onDelete?.()})},[e,n]);return r.jsx(Gt,{onConfirm:s,title:"Are you sure you want to delete the depreciation record?",children:r.jsx(Le,{label:"Remove Depreciation",children:r.jsx(Q,{variant:"outline",size:"icon",className:"size-7.5 text-red-500",disabled:t,children:r.jsx(Sn,{className:"size-5"})})})})}const Od=({data:e,onChange:t})=>{const n=L(ca,e),[s,o]=g.useState(!1),[{data:a,fetching:i},l]=Xe({query:rs,pause:!0}),{control:c,handleSubmit:d,formState:{dirtyFields:x}}=xn({defaultValues:{id:n.id}}),{updateDepreciationRecord:f,fetching:m}=wd(),y=u=>{const v=la(u,x);v&&Object.keys(v).length>0&&f({fields:{...u,id:n.id}}).then(()=>{t?.(),o(!1)})},p=a?.depreciationCategories.map(u=>({value:u.id,label:u.name}));return g.useEffect(()=>{s&&!a&&l()},[s,a,l]),r.jsxs("tr",{children:[r.jsx("td",{children:r.jsx("form",{id:`form ${n.id}`,onSubmit:d(y),children:s?r.jsx($e,{name:"amount",control:c,render:({field:u,fieldState:v})=>r.jsx($e,{name:"currency",control:c,render:({field:h,fieldState:j})=>r.jsx(as,{...u,defaultValue:n.amount?.raw??n.charge.totalAmount?.raw,value:u.value??void 0,error:v.error?.message||j.error?.message,label:"Amount",currencyCodeProps:{...h,label:"Currency",defaultValue:n.amount?.currency??n.charge.totalAmount?.currency}})})}):r.jsx("div",{children:n.amount?.formatted??n.charge.totalAmount?.formatted})})}),r.jsx("td",{children:r.jsx("div",{className:"flex flex-col gap-2 justify-center",children:s?r.jsx($e,{name:"activationDate",control:c,defaultValue:n.activationDate,rules:{pattern:{value:ss,message:"Date must be im format yyyy-mm-dd"}},render:({field:{value:u,...v},fieldState:h})=>{const j=u?new Date(u):void 0;return r.jsx(os,{...v,form:`form ${n.id}`,onChange:C=>{const I=C?typeof C=="string"?C:Be(C,"yyyy-MM-dd"):void 0;I!==u&&v.onChange(I)},value:j,label:"Activation Date",error:h.error?.message,popoverProps:{withinPortal:!0}})}}):r.jsx("div",{children:Be(new Date(n.activationDate),"dd/MM/yy")})})}),r.jsx("td",{children:s?r.jsx($e,{name:"categoryId",control:c,render:({field:u,fieldState:v})=>r.jsx(Nt,{...u,form:`form ${n.id}`,disabled:i,data:p??[],label:"Category",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:v.error?.message,withinPortal:!0})}):r.jsxs("div",{children:[n.category.name," (",n.category.percentage,"%)"]})}),r.jsx("td",{children:s?r.jsx($e,{name:"type",control:c,render:({field:u,fieldState:v})=>r.jsx(Nt,{...u,form:`form ${n.id}`,data:ao,value:u.value,label:"Type",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:v.error?.message,withinPortal:!0})}):r.jsx("div",{children:n.type})}),r.jsxs("td",{children:[r.jsx(Le,{label:"Edit",children:r.jsx(Q,{disabled:m||i,variant:s?"default":"outline",size:"icon",className:"size-7.5",onClick:u=>{u.stopPropagation(),o(v=>!v)},children:r.jsx(Gr,{className:"size-5"})})}),s&&r.jsx(Le,{label:"Confirm Changes",children:r.jsx(Q,{type:"submit",form:`form ${n.id}`,variant:"outline",size:"icon",className:"size-7.5 text-green-500",children:r.jsx(ia,{className:"size-5"})})}),r.jsx(Ed,{depreciationRecordId:n.id,onDelete:t})]})]},n.id)},Pd=({chargeId:e,onChange:t})=>{const[{data:n,fetching:s}]=Xe({query:da,variables:{chargeId:e}});return!s&&!n?.depreciationRecordsByCharge.length?r.jsx(_r,{chargeId:e,onAdd:t}):s?r.jsx(is,{className:"h-10 w-10 animate-spin mr-2 self-center"}):r.jsx("div",{className:"flex flex-col gap-2 mt-5",children:r.jsxs(Cs,{highlightOnHover:!0,withBorder:!0,children:[r.jsx("thead",{children:r.jsxs("tr",{children:[r.jsx("th",{children:"Amount"}),r.jsx("th",{children:"Activation Date"}),r.jsx("th",{children:"Category"}),r.jsx("th",{children:"Type"}),r.jsx("th",{})]})}),r.jsxs("tbody",{children:[n?.depreciationRecordsByCharge.map(o=>r.jsx(Od,{data:o,onChange:t},o.id)),r.jsx("tr",{children:r.jsx("td",{colSpan:5,children:r.jsx(_r,{chargeId:e,onAdd:t})})})]})]})})},ao=Object.entries(ua).map(([e,t])=>({value:t,label:e}));function Ad({chargeId:e,chargeType:t,setInsertDocument:n,setMatchDocuments:s,onChange:o,isIncome:a}){const{deleteCharge:i}=mc(),[l,c]=g.useState(!1),[d,{open:x,close:f}]=gt(!1),[m,y]=g.useState(!1),[p,{open:u,close:v}]=gt(!1),[h,j]=g.useState(!1),[C,I]=g.useState(!1);function O(){i({chargeId:e}),o?.()}function _(){c(!1)}return r.jsxs(r.Fragment,{children:[r.jsxs(oe,{shadow:"md",width:200,opened:l,children:[r.jsx(oe.Target,{children:r.jsx(Ua,{opened:l,onClick:b=>{b.stopPropagation(),c(w=>!w)}})}),r.jsxs(oe.Dropdown,{children:[r.jsx(oe.Label,{children:"Charge"}),r.jsx(Gt,{onConfirm:O,title:"Are you sure you want to delete this charge?",children:r.jsx(oe.Item,{icon:r.jsx(Sn,{size:14}),children:"Delete Charge"})}),r.jsx(oe.Divider,{}),r.jsx(oe.Label,{children:"Documents"}),n&&r.jsx(oe.Item,{icon:r.jsx(Jt,{size:14}),onClick:b=>{b.stopPropagation(),n(),_()},children:"Insert Document"}),"(",r.jsx(oe.Item,{icon:r.jsx(Gn,{size:14}),onClick:b=>{b.stopPropagation(),I(!0),_()},children:"Upload Documents"}),")",s&&r.jsx(oe.Item,{icon:r.jsx(fa,{size:14}),onClick:()=>{s(),_()},children:"Match Document"}),a&&r.jsx(oe.Item,{icon:r.jsx(Jt,{size:14}),onClick:b=>{b.stopPropagation(),j(!0),_()},children:"Issue Document"}),r.jsx(oe.Divider,{}),r.jsx(oe.Label,{children:"Misc Expenses"}),r.jsx(oe.Item,{icon:r.jsx(Jt,{size:14}),onClick:b=>{b.stopPropagation(),_(),y(!0)},children:"Add expense"}),t==="CommonCharge"&&r.jsxs(r.Fragment,{children:[r.jsx(oe.Divider,{}),r.jsx(oe.Label,{children:"Depreciation"}),r.jsx(oe.Item,{icon:r.jsx(Ga,{size:14}),onClick:b=>{b.stopPropagation(),x(),_()},children:"Depreciation"})]}),t==="SalaryCharge"&&r.jsxs(r.Fragment,{children:[r.jsx(oe.Divider,{}),r.jsx(oe.Label,{children:"Salaries"}),r.jsx(oe.Item,{icon:r.jsx(Gn,{size:14}),onClick:b=>{b.stopPropagation(),_(),u()},children:"Payroll file upload"})]})]})]}),r.jsx(ft,{withinPortal:!0,size:"xl",centered:!0,opened:d,onClose:f,title:"Depreciation",onClick:b=>b.stopPropagation(),children:r.jsx(Pd,{chargeId:e,onChange:()=>{f(),o?.()}})}),r.jsx(yn,{open:m,onOpenChange:y,children:r.jsx(vn,{className:"sm:max-w-[425px]",onClick:b=>b.stopPropagation(),children:r.jsx(Na,{onDone:()=>{y(!1),o?.()},chargeId:e})})}),r.jsx(ft,{centered:!0,opened:p,onClose:v,title:"Upload Payroll File",onClick:b=>b.stopPropagation(),children:r.jsx(_c,{onDone:()=>{v(),o?.()},chargeId:e})}),r.jsx(pa,{open:C,onOpenChange:I,onChange:o,chargeId:e}),r.jsx(cn,{chargeId:e,open:h,setOpen:j,onDone:()=>o?.()})]})}function Nd(e){return Object.prototype.toString.call(e)==="[object Object]"}function Ir(e){return Nd(e)||Array.isArray(e)}function Td(){return!!(typeof window<"u"&&window.document&&window.document.createElement)}function In(e,t){const n=Object.keys(e),s=Object.keys(t);if(n.length!==s.length)return!1;const o=JSON.stringify(Object.keys(e.breakpoints||{})),a=JSON.stringify(Object.keys(t.breakpoints||{}));return o!==a?!1:n.every(i=>{const l=e[i],c=t[i];return typeof l=="function"?`${l}`==`${c}`:!Ir(l)||!Ir(c)?l===c:In(l,c)})}function Er(e){return e.concat().sort((t,n)=>t.name>n.name?1:-1).map(t=>t.options)}function $d(e,t){if(e.length!==t.length)return!1;const n=Er(e),s=Er(t);return n.every((o,a)=>{const i=s[a];return In(o,i)})}function En(e){return typeof e=="number"}function mn(e){return typeof e=="string"}function qt(e){return typeof e=="boolean"}function Or(e){return Object.prototype.toString.call(e)==="[object Object]"}function X(e){return Math.abs(e)}function On(e){return Math.sign(e)}function pt(e,t){return X(e-t)}function Fd(e,t){if(e===0||t===0||X(e)<=X(t))return 0;const n=pt(X(e),X(t));return X(n/e)}function kd(e){return Math.round(e*100)/100}function xt(e){return yt(e).map(Number)}function Ee(e){return e[Ct(e)]}function Ct(e){return Math.max(0,e.length-1)}function Pn(e,t){return t===Ct(e)}function Pr(e,t=0){return Array.from(Array(e),(n,s)=>t+s)}function yt(e){return Object.keys(e)}function io(e,t){return[e,t].reduce((n,s)=>(yt(s).forEach(o=>{const a=n[o],i=s[o],l=Or(a)&&Or(i);n[o]=l?io(a,i):i}),n),{})}function hn(e,t){return typeof t.MouseEvent<"u"&&e instanceof t.MouseEvent}function Rd(e,t){const n={start:s,center:o,end:a};function s(){return 0}function o(c){return a(c)/2}function a(c){return t-c}function i(c,d){return mn(e)?n[e](c):e(t,c,d)}return{measure:i}}function vt(){let e=[];function t(o,a,i,l={passive:!0}){let c;if("addEventListener"in o)o.addEventListener(a,i,l),c=()=>o.removeEventListener(a,i,l);else{const d=o;d.addListener(i),c=()=>d.removeListener(i)}return e.push(c),s}function n(){e=e.filter(o=>o())}const s={add:t,clear:n};return s}function Md(e,t,n,s){const o=vt(),a=1e3/60;let i=null,l=0,c=0;function d(){o.add(e,"visibilitychange",()=>{e.hidden&&p()})}function x(){y(),o.clear()}function f(v){if(!c)return;i||(i=v,n(),n());const h=v-i;for(i=v,l+=h;l>=a;)n(),l-=a;const j=l/a;s(j),c&&(c=t.requestAnimationFrame(f))}function m(){c||(c=t.requestAnimationFrame(f))}function y(){t.cancelAnimationFrame(c),i=null,l=0,c=0}function p(){i=null,l=0}return{init:d,destroy:x,start:m,stop:y,update:n,render:s}}function zd(e,t){const n=t==="rtl",s=e==="y",o=s?"y":"x",a=s?"x":"y",i=!s&&n?-1:1,l=x(),c=f();function d(p){const{height:u,width:v}=p;return s?u:v}function x(){return s?"top":n?"right":"left"}function f(){return s?"bottom":n?"left":"right"}function m(p){return p*i}return{scroll:o,cross:a,startEdge:l,endEdge:c,measureSize:d,direction:m}}function Je(e=0,t=0){const n=X(e-t);function s(d){return d<e}function o(d){return d>t}function a(d){return s(d)||o(d)}function i(d){return a(d)?s(d)?e:t:d}function l(d){return n?d-n*Math.ceil((d-t)/n):d}return{length:n,max:t,min:e,constrain:i,reachedAny:a,reachedMax:o,reachedMin:s,removeOffset:l}}function co(e,t,n){const{constrain:s}=Je(0,e),o=e+1;let a=i(t);function i(m){return n?X((o+m)%o):s(m)}function l(){return a}function c(m){return a=i(m),f}function d(m){return x().set(l()+m)}function x(){return co(e,l(),n)}const f={get:l,set:c,add:d,clone:x};return f}function Ld(e,t,n,s,o,a,i,l,c,d,x,f,m,y,p,u,v,h,j){const{cross:C,direction:I}=e,O=["INPUT","SELECT","TEXTAREA"],_={passive:!1},b=vt(),w=vt(),A=Je(50,225).constrain(y.measure(20)),k={mouse:300,touch:400},T={mouse:500,touch:600},G=p?43:25;let Y=!1,R=0,z=0,le=!1,ie=!1,M=!1,B=!1;function he(S){if(!j)return;function V(ne){(qt(j)||j(S,ne))&&ae(ne)}const q=t;b.add(q,"dragstart",ne=>ne.preventDefault(),_).add(q,"touchmove",()=>{},_).add(q,"touchend",()=>{}).add(q,"touchstart",V).add(q,"mousedown",V).add(q,"touchcancel",P).add(q,"contextmenu",P).add(q,"click",fe,!0)}function de(){b.clear(),w.clear()}function ue(){const S=B?n:t;w.add(S,"touchmove",ee,_).add(S,"touchend",P).add(S,"mousemove",ee,_).add(S,"mouseup",P)}function be(S){const V=S.nodeName||"";return O.includes(V)}function K(){return(p?T:k)[B?"mouse":"touch"]}function xe(S,V){const q=f.add(On(S)*-1),ne=x.byDistance(S,!p).distance;return p||X(S)<A?ne:v&&V?ne*.5:x.byIndex(q.get(),0).distance}function ae(S){const V=hn(S,s);B=V,M=p&&V&&!S.buttons&&Y,Y=pt(o.get(),i.get())>=2,!(V&&S.button!==0)&&(be(S.target)||(le=!0,a.pointerDown(S),d.useFriction(0).useDuration(0),o.set(i),ue(),R=a.readPoint(S),z=a.readPoint(S,C),m.emit("pointerDown")))}function ee(S){if(!hn(S,s)&&S.touches.length>=2)return P(S);const q=a.readPoint(S),ne=a.readPoint(S,C),pe=pt(q,R),ce=pt(ne,z);if(!ie&&!B&&(!S.cancelable||(ie=pe>ce,!ie)))return P(S);const ye=a.pointerMove(S);pe>u&&(M=!0),d.useFriction(.3).useDuration(.75),l.start(),o.add(I(ye)),S.preventDefault()}function P(S){const q=x.byDistance(0,!1).index!==f.get(),ne=a.pointerUp(S)*K(),pe=xe(I(ne),q),ce=Fd(ne,pe),ye=G-10*ce,ge=h+ce/50;ie=!1,le=!1,w.clear(),d.useDuration(ye).useFriction(ge),c.distance(pe,!p),B=!1,m.emit("pointerUp")}function fe(S){M&&(S.stopPropagation(),S.preventDefault(),M=!1)}function te(){return le}return{init:he,destroy:de,pointerDown:te}}function Bd(e,t){let s,o;function a(f){return f.timeStamp}function i(f,m){const p=`client${(m||e.scroll)==="x"?"X":"Y"}`;return(hn(f,t)?f:f.touches[0])[p]}function l(f){return s=f,o=f,i(f)}function c(f){const m=i(f)-i(o),y=a(f)-a(s)>170;return o=f,y&&(s=f),m}function d(f){if(!s||!o)return 0;const m=i(o)-i(s),y=a(f)-a(s),p=a(f)-a(o)>170,u=m/y;return y&&!p&&X(u)>.1?u:0}return{pointerDown:l,pointerMove:c,pointerUp:d,readPoint:i}}function Vd(){function e(n){const{offsetTop:s,offsetLeft:o,offsetWidth:a,offsetHeight:i}=n;return{top:s,right:o+a,bottom:s+i,left:o,width:a,height:i}}return{measure:e}}function Ud(e){function t(s){return e*(s/100)}return{measure:t}}function Hd(e,t,n,s,o,a,i){const l=[e].concat(s);let c,d,x=[],f=!1;function m(v){return o.measureSize(i.measure(v))}function y(v){if(!a)return;d=m(e),x=s.map(m);function h(j){for(const C of j){if(f)return;const I=C.target===e,O=s.indexOf(C.target),_=I?d:x[O],b=m(I?e:s[O]);if(X(b-_)>=.5){v.reInit(),t.emit("resize");break}}}c=new ResizeObserver(j=>{(qt(a)||a(v,j))&&h(j)}),n.requestAnimationFrame(()=>{l.forEach(j=>c.observe(j))})}function p(){f=!0,c&&c.disconnect()}return{init:y,destroy:p}}function Kd(e,t,n,s,o,a){let i=0,l=0,c=o,d=a,x=e.get(),f=0;function m(){const _=s.get()-e.get(),b=!c;let w=0;return b?(i=0,n.set(s),e.set(s),w=_):(n.set(e),i+=_/c,i*=d,x+=i,e.add(i),w=x-f),l=On(w),f=x,O}function y(){const _=s.get()-t.get();return X(_)<.001}function p(){return c}function u(){return l}function v(){return i}function h(){return C(o)}function j(){return I(a)}function C(_){return c=_,O}function I(_){return d=_,O}const O={direction:u,duration:p,velocity:v,seek:m,settled:y,useBaseFriction:j,useBaseDuration:h,useFriction:I,useDuration:C};return O}function Gd(e,t,n,s,o){const a=o.measure(10),i=o.measure(50),l=Je(.1,.99);let c=!1;function d(){return!(c||!e.reachedAny(n.get())||!e.reachedAny(t.get()))}function x(y){if(!d())return;const p=e.reachedMin(t.get())?"min":"max",u=X(e[p]-t.get()),v=n.get()-t.get(),h=l.constrain(u/i);n.subtract(v*h),!y&&X(v)<a&&(n.set(e.constrain(n.get())),s.useDuration(25).useBaseFriction())}function f(y){c=!y}return{shouldConstrain:d,constrain:x,toggleActive:f}}function qd(e,t,n,s,o){const a=Je(-t+e,0),i=f(),l=x(),c=m();function d(p,u){return pt(p,u)<=1}function x(){const p=i[0],u=Ee(i),v=i.lastIndexOf(p),h=i.indexOf(u)+1;return Je(v,h)}function f(){return n.map((p,u)=>{const{min:v,max:h}=a,j=a.constrain(p),C=!u,I=Pn(n,u);return C?h:I||d(v,j)?v:d(h,j)?h:j}).map(p=>parseFloat(p.toFixed(3)))}function m(){if(t<=e+o)return[a.max];if(s==="keepSnaps")return i;const{min:p,max:u}=l;return i.slice(p,u)}return{snapsContained:c,scrollContainLimit:l}}function Wd(e,t,n){const s=t[0],o=n?s-e:Ee(t);return{limit:Je(o,s)}}function Yd(e,t,n,s){const a=t.min+.1,i=t.max+.1,{reachedMin:l,reachedMax:c}=Je(a,i);function d(m){return m===1?c(n.get()):m===-1?l(n.get()):!1}function x(m){if(!d(m))return;const y=e*(m*-1);s.forEach(p=>p.add(y))}return{loop:x}}function Qd(e){const{max:t,length:n}=e;function s(a){const i=a-t;return n?i/-n:0}return{get:s}}function Jd(e,t,n,s,o){const{startEdge:a,endEdge:i}=e,{groupSlides:l}=o,c=f().map(t.measure),d=m(),x=y();function f(){return l(s).map(u=>Ee(u)[i]-u[0][a]).map(X)}function m(){return s.map(u=>n[a]-u[a]).map(u=>-X(u))}function y(){return l(d).map(u=>u[0]).map((u,v)=>u+c[v])}return{snaps:d,snapsAligned:x}}function Xd(e,t,n,s,o,a){const{groupSlides:i}=o,{min:l,max:c}=s,d=x();function x(){const m=i(a),y=!e||t==="keepSnaps";return n.length===1?[a]:y?m:m.slice(l,c).map((p,u,v)=>{const h=!u,j=Pn(v,u);if(h){const C=Ee(v[0])+1;return Pr(C)}if(j){const C=Ct(a)-Ee(v)[0]+1;return Pr(C,Ee(v)[0])}return p})}return{slideRegistry:d}}function Zd(e,t,n,s,o){const{reachedAny:a,removeOffset:i,constrain:l}=s;function c(p){return p.concat().sort((u,v)=>X(u)-X(v))[0]}function d(p){const u=e?i(p):l(p),v=t.map((j,C)=>({diff:x(j-u,0),index:C})).sort((j,C)=>X(j.diff)-X(C.diff)),{index:h}=v[0];return{index:h,distance:u}}function x(p,u){const v=[p,p+n,p-n];if(!e)return p;if(!u)return c(v);const h=v.filter(j=>On(j)===u);return h.length?c(h):Ee(v)-n}function f(p,u){const v=t[p]-o.get(),h=x(v,u);return{index:p,distance:h}}function m(p,u){const v=o.get()+p,{index:h,distance:j}=d(v),C=!e&&a(v);if(!u||C)return{index:h,distance:p};const I=t[h]-j,O=p+x(I,0);return{index:h,distance:O}}return{byDistance:m,byIndex:f,shortcut:x}}function eu(e,t,n,s,o,a,i){function l(f){const m=f.distance,y=f.index!==t.get();a.add(m),m&&(s.duration()?e.start():(e.update(),e.render(1),e.update())),y&&(n.set(t.get()),t.set(f.index),i.emit("select"))}function c(f,m){const y=o.byDistance(f,m);l(y)}function d(f,m){const y=t.clone().set(f),p=o.byIndex(y.get(),m);l(p)}return{distance:c,index:d}}function tu(e,t,n,s,o,a,i,l){const c={passive:!0,capture:!0};let d=0;function x(y){if(!l)return;function p(u){if(new Date().getTime()-d>10)return;i.emit("slideFocusStart"),e.scrollLeft=0;const j=n.findIndex(C=>C.includes(u));En(j)&&(o.useDuration(0),s.index(j,0),i.emit("slideFocus"))}a.add(document,"keydown",f,!1),t.forEach((u,v)=>{a.add(u,"focus",h=>{(qt(l)||l(y,h))&&p(v)},c)})}function f(y){y.code==="Tab"&&(d=new Date().getTime())}return{init:x}}function ut(e){let t=e;function n(){return t}function s(c){t=i(c)}function o(c){t+=i(c)}function a(c){t-=i(c)}function i(c){return En(c)?c:c.get()}return{get:n,set:s,add:o,subtract:a}}function lo(e,t){const n=e.scroll==="x"?i:l,s=t.style;let o=null,a=!1;function i(m){return`translate3d(${m}px,0px,0px)`}function l(m){return`translate3d(0px,${m}px,0px)`}function c(m){if(a)return;const y=kd(e.direction(m));y!==o&&(s.transform=n(y),o=y)}function d(m){a=!m}function x(){a||(s.transform="",t.getAttribute("style")||t.removeAttribute("style"))}return{clear:x,to:c,toggleActive:d}}function nu(e,t,n,s,o,a,i,l,c){const x=xt(o),f=xt(o).reverse(),m=h().concat(j());function y(b,w){return b.reduce((A,k)=>A-o[k],w)}function p(b,w){return b.reduce((A,k)=>y(A,w)>0?A.concat([k]):A,[])}function u(b){return a.map((w,A)=>({start:w-s[A]+.5+b,end:w+t-.5+b}))}function v(b,w,A){const k=u(w);return b.map(T=>{const G=A?0:-n,Y=A?n:0,R=A?"end":"start",z=k[T][R];return{index:T,loopPoint:z,slideLocation:ut(-1),translate:lo(e,c[T]),target:()=>l.get()>z?G:Y}})}function h(){const b=i[0],w=p(f,b);return v(w,n,!1)}function j(){const b=t-i[0]-1,w=p(x,b);return v(w,-n,!0)}function C(){return m.every(({index:b})=>{const w=x.filter(A=>A!==b);return y(w,t)<=.1})}function I(){m.forEach(b=>{const{target:w,translate:A,slideLocation:k}=b,T=w();T!==k.get()&&(A.to(T),k.set(T))})}function O(){m.forEach(b=>b.translate.clear())}return{canLoop:C,clear:O,loop:I,loopPoints:m}}function ru(e,t,n){let s,o=!1;function a(c){if(!n)return;function d(x){for(const f of x)if(f.type==="childList"){c.reInit(),t.emit("slidesChanged");break}}s=new MutationObserver(x=>{o||(qt(n)||n(c,x))&&d(x)}),s.observe(e,{childList:!0})}function i(){s&&s.disconnect(),o=!0}return{init:a,destroy:i}}function su(e,t,n,s){const o={};let a=null,i=null,l,c=!1;function d(){l=new IntersectionObserver(p=>{c||(p.forEach(u=>{const v=t.indexOf(u.target);o[v]=u}),a=null,i=null,n.emit("slidesInView"))},{root:e.parentElement,threshold:s}),t.forEach(p=>l.observe(p))}function x(){l&&l.disconnect(),c=!0}function f(p){return yt(o).reduce((u,v)=>{const h=parseInt(v),{isIntersecting:j}=o[h];return(p&&j||!p&&!j)&&u.push(h),u},[])}function m(p=!0){if(p&&a)return a;if(!p&&i)return i;const u=f(p);return p&&(a=u),p||(i=u),u}return{init:d,destroy:x,get:m}}function ou(e,t,n,s,o,a){const{measureSize:i,startEdge:l,endEdge:c}=e,d=n[0]&&o,x=p(),f=u(),m=n.map(i),y=v();function p(){if(!d)return 0;const j=n[0];return X(t[l]-j[l])}function u(){if(!d)return 0;const j=a.getComputedStyle(Ee(s));return parseFloat(j.getPropertyValue(`margin-${c}`))}function v(){return n.map((j,C,I)=>{const O=!C,_=Pn(I,C);return O?m[C]+x:_?m[C]+f:I[C+1][l]-j[l]}).map(X)}return{slideSizes:m,slideSizesWithGaps:y,startGap:x,endGap:f}}function au(e,t,n,s,o,a,i,l,c){const{startEdge:d,endEdge:x,direction:f}=e,m=En(n);function y(h,j){return xt(h).filter(C=>C%j===0).map(C=>h.slice(C,C+j))}function p(h){return h.length?xt(h).reduce((j,C,I)=>{const O=Ee(j)||0,_=O===0,b=C===Ct(h),w=o[d]-a[O][d],A=o[d]-a[C][x],k=!s&&_?f(i):0,T=!s&&b?f(l):0,G=X(A-T-(w+k));return I&&G>t+c&&j.push(C),b&&j.push(h.length),j},[]).map((j,C,I)=>{const O=Math.max(I[C-1]||0);return h.slice(O,j)}):[]}function u(h){return m?y(h,n):p(h)}return{groupSlides:u}}function iu(e,t,n,s,o,a,i){const{align:l,axis:c,direction:d,startIndex:x,loop:f,duration:m,dragFree:y,dragThreshold:p,inViewThreshold:u,slidesToScroll:v,skipSnaps:h,containScroll:j,watchResize:C,watchSlides:I,watchDrag:O,watchFocus:_}=a,b=2,w=Vd(),A=w.measure(t),k=n.map(w.measure),T=zd(c,d),G=T.measureSize(A),Y=Ud(G),R=Rd(l,G),z=!f&&!!j,le=f||!!j,{slideSizes:ie,slideSizesWithGaps:M,startGap:B,endGap:he}=ou(T,A,k,n,le,o),de=au(T,G,v,f,A,k,B,he,b),{snaps:ue,snapsAligned:be}=Jd(T,R,A,k,de),K=-Ee(ue)+Ee(M),{snapsContained:xe,scrollContainLimit:ae}=qd(G,K,be,j,b),ee=z?xe:be,{limit:P}=Wd(K,ee,f),fe=co(Ct(ee),x,f),te=fe.clone(),H=xt(n),S=({dragHandler:Ce,scrollBody:Ke,scrollBounds:Ge,options:{loop:Me}})=>{Me||Ge.constrain(Ce.pointerDown()),Ke.seek()},V=({scrollBody:Ce,translate:Ke,location:Ge,offsetLocation:Me,previousLocation:Ze,scrollLooper:at,slideLooper:it,dragHandler:ct,animation:lt,eventHandler:Dt,scrollBounds:ho,options:{loop:Tn}},$n)=>{const Fn=Ce.settled(),xo=!ho.shouldConstrain(),kn=Tn?Fn:Fn&&xo,Rn=kn&&!ct.pointerDown();Rn&&lt.stop();const yo=Ge.get()*$n+Ze.get()*(1-$n);Me.set(yo),Tn&&(at.loop(Ce.direction()),it.loop()),Ke.to(Me.get()),Rn&&Dt.emit("settle"),kn||Dt.emit("scroll")},q=Md(s,o,()=>S(ke),Ce=>V(ke,Ce)),ne=.68,pe=ee[fe.get()],ce=ut(pe),ye=ut(pe),ge=ut(pe),ve=ut(pe),re=Kd(ce,ge,ye,ve,m,ne),Fe=Zd(f,ee,K,P,ve),ot=eu(q,fe,te,re,Fe,ve,i),D=Qd(P),E=vt(),Z=su(t,n,i,u),{slideRegistry:se}=Xd(z,j,ee,ae,de,H),me=tu(e,n,se,ot,re,E,i,_),ke={ownerDocument:s,ownerWindow:o,eventHandler:i,containerRect:A,slideRects:k,animation:q,axis:T,dragHandler:Ld(T,e,s,o,ve,Bd(T,o),ce,q,ot,re,Fe,fe,i,Y,y,p,h,ne,O),eventStore:E,percentOfView:Y,index:fe,indexPrevious:te,limit:P,location:ce,offsetLocation:ge,previousLocation:ye,options:a,resizeHandler:Hd(t,i,o,n,T,C,w),scrollBody:re,scrollBounds:Gd(P,ge,ve,re,Y),scrollLooper:Yd(K,P,ge,[ce,ge,ye,ve]),scrollProgress:D,scrollSnapList:ee.map(D.get),scrollSnaps:ee,scrollTarget:Fe,scrollTo:ot,slideLooper:nu(T,G,K,ie,M,ue,ee,ge,n),slideFocus:me,slidesHandler:ru(t,i,I),slidesInView:Z,slideIndexes:H,slideRegistry:se,slidesToScroll:de,target:ve,translate:lo(T,t)};return ke}function cu(){let e={},t;function n(d){t=d}function s(d){return e[d]||[]}function o(d){return s(d).forEach(x=>x(t,d)),c}function a(d,x){return e[d]=s(d).concat([x]),c}function i(d,x){return e[d]=s(d).filter(f=>f!==x),c}function l(){e={}}const c={init:n,emit:o,off:i,on:a,clear:l};return c}const lu={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 du(e){function t(a,i){return io(a,i||{})}function n(a){const i=a.breakpoints||{},l=yt(i).filter(c=>e.matchMedia(c).matches).map(c=>i[c]).reduce((c,d)=>t(c,d),{});return t(a,l)}function s(a){return a.map(i=>yt(i.breakpoints||{})).reduce((i,l)=>i.concat(l),[]).map(e.matchMedia)}return{mergeOptions:t,optionsAtMedia:n,optionsMediaQueries:s}}function uu(e){let t=[];function n(a,i){return t=i.filter(({options:l})=>e.optionsAtMedia(l).active!==!1),t.forEach(l=>l.init(a,e)),i.reduce((l,c)=>Object.assign(l,{[c.name]:c}),{})}function s(){t=t.filter(a=>a.destroy())}return{init:n,destroy:s}}function Ut(e,t,n){const s=e.ownerDocument,o=s.defaultView,a=du(o),i=uu(a),l=vt(),c=cu(),{mergeOptions:d,optionsAtMedia:x,optionsMediaQueries:f}=a,{on:m,off:y,emit:p}=c,u=T;let v=!1,h,j=d(lu,Ut.globalOptions),C=d(j),I=[],O,_,b;function w(){const{container:H,slides:S}=C;_=(mn(H)?e.querySelector(H):H)||e.children[0];const q=mn(S)?_.querySelectorAll(S):S;b=[].slice.call(q||_.children)}function A(H){const S=iu(e,_,b,s,o,H,c);if(H.loop&&!S.slideLooper.canLoop()){const V=Object.assign({},H,{loop:!1});return A(V)}return S}function k(H,S){v||(j=d(j,H),C=x(j),I=S||I,w(),h=A(C),f([j,...I.map(({options:V})=>V)]).forEach(V=>l.add(V,"change",T)),C.active&&(h.translate.to(h.location.get()),h.animation.init(),h.slidesInView.init(),h.slideFocus.init(te),h.eventHandler.init(te),h.resizeHandler.init(te),h.slidesHandler.init(te),h.options.loop&&h.slideLooper.loop(),_.offsetParent&&b.length&&h.dragHandler.init(te),O=i.init(te,I)))}function T(H,S){const V=de();G(),k(d({startIndex:V},H),S),c.emit("reInit")}function G(){h.dragHandler.destroy(),h.eventStore.clear(),h.translate.clear(),h.slideLooper.clear(),h.resizeHandler.destroy(),h.slidesHandler.destroy(),h.slidesInView.destroy(),h.animation.destroy(),i.destroy(),l.clear()}function Y(){v||(v=!0,l.clear(),G(),c.emit("destroy"),c.clear())}function R(H,S,V){!C.active||v||(h.scrollBody.useBaseFriction().useDuration(S===!0?0:C.duration),h.scrollTo.index(H,V||0))}function z(H){const S=h.index.add(1).get();R(S,H,-1)}function le(H){const S=h.index.add(-1).get();R(S,H,1)}function ie(){return h.index.add(1).get()!==de()}function M(){return h.index.add(-1).get()!==de()}function B(){return h.scrollSnapList}function he(){return h.scrollProgress.get(h.offsetLocation.get())}function de(){return h.index.get()}function ue(){return h.indexPrevious.get()}function be(){return h.slidesInView.get()}function K(){return h.slidesInView.get(!1)}function xe(){return O}function ae(){return h}function ee(){return e}function P(){return _}function fe(){return b}const te={canScrollNext:ie,canScrollPrev:M,containerNode:P,internalEngine:ae,destroy:Y,off:y,on:m,emit:p,plugins:xe,previousScrollSnap:ue,reInit:u,rootNode:ee,scrollNext:z,scrollPrev:le,scrollProgress:he,scrollSnapList:B,scrollTo:R,selectedScrollSnap:de,slideNodes:fe,slidesInView:be,slidesNotInView:K};return k(t,n),setTimeout(()=>c.emit("init"),0),te}Ut.globalOptions=void 0;function An(e={},t=[]){const n=g.useRef(e),s=g.useRef(t),[o,a]=g.useState(),[i,l]=g.useState(),c=g.useCallback(()=>{o&&o.reInit(n.current,s.current)},[o]);return g.useEffect(()=>{In(n.current,e)||(n.current=e,c())},[e,c]),g.useEffect(()=>{$d(s.current,t)||(s.current=t,c())},[t,c]),g.useEffect(()=>{if(Td()&&i){Ut.globalOptions=An.globalOptions;const d=Ut(i,n.current,s.current);return a(d),()=>d.destroy()}else a(void 0)},[i,a]),[l,o]}An.globalOptions=void 0;const fu={context:"[@mantine/carousel] Carousel.Slide was rendered outside of Carousel context"},[pu,gu]=Kr(fu.context);var mu=Object.defineProperty,hu=Object.defineProperties,xu=Object.getOwnPropertyDescriptors,Ar=Object.getOwnPropertySymbols,yu=Object.prototype.hasOwnProperty,vu=Object.prototype.propertyIsEnumerable,Nr=(e,t,n)=>t in e?mu(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,sn=(e,t)=>{for(var n in t||(t={}))yu.call(t,n)&&Nr(e,n,t[n]);if(Ar)for(var n of Ar(t))vu.call(t,n)&&Nr(e,n,t[n]);return e},ju=(e,t)=>hu(e,xu(t)),bu=Ve((e,{controlSize:t,controlsOffset:n,orientation:s,height:o,includeGapInSize:a,breakpoints:i=[],slideGap:l})=>{const c=s==="horizontal",d=m=>{if(!a)return{};const y=we({size:m,sizes:e.spacing});return{[s==="horizontal"?"marginRight":"marginBottom"]:`calc(${y} * -1)`}},f=i.some(m=>typeof m.slideGap<"u"||typeof m.slideSize<"u")?cs(e,i).reduce((m,y)=>{const p="maxWidth"in y?"max-width":"min-width",u=we({size:p==="max-width"?y.maxWidth:y.minWidth,sizes:e.breakpoints}),v=typeof y.slideGap>"u"?void 0:$(y.slideGap),h=ls(u)-(p==="max-width"?1:0);return m[`@media (${p}: ${$(h)})`]=d(v),m},{}):null;return{root:{position:"relative"},viewport:{height:$(o),overflow:"hidden"},container:sn(sn({display:"flex",flexDirection:c?"row":"column",height:$(o)},d(l)),f),controls:{position:"absolute",zIndex:1,left:c?0:`calc(50% - ${$(t)} / 2)`,right:c?0:void 0,top:c?`calc(50% - ${$(t)} / 2)`:0,bottom:c?void 0:0,display:"flex",flexDirection:c?"row":"column",alignItems:"center",justifyContent:"space-between",paddingLeft:c?we({size:n,sizes:e.spacing}):void 0,paddingRight:c?we({size:n,sizes:e.spacing}):void 0,paddingTop:c?void 0:we({size:n,sizes:e.spacing}),paddingBottom:c?void 0:we({size:n,sizes:e.spacing}),pointerEvents:"none"},control:ju(sn({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:c?e.spacing.md:0,top:c?void 0:0,left:c?0:void 0,right:c?0:e.spacing.md,display:"flex",flexDirection:c?"row":"column",justifyContent:"center",gap:$(8),pointerEvents:"none"},indicator:{pointerEvents:"all",width:c?$(25):$(5),height:c?$(5):$(25),borderRadius:e.radius.xl,backgroundColor:e.white,boxShadow:e.shadows.sm,opacity:.6,transition:`opacity 150ms ${e.transitionTimingFunction}`,"&[data-active]":{opacity:1}}}}),Cu=Object.defineProperty,Tr=Object.getOwnPropertySymbols,Du=Object.prototype.hasOwnProperty,Su=Object.prototype.propertyIsEnumerable,$r=(e,t,n)=>t in e?Cu(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,on=(e,t)=>{for(var n in t||(t={}))Du.call(t,n)&&$r(e,n,t[n]);if(Tr)for(var n of Tr(t))Su.call(t,n)&&$r(e,n,t[n]);return e},wu=Ve((e,{size:t,gap:n,orientation:s,includeGapInSize:o,breakpoints:a=[]})=>{const i=(d,x)=>{const f=we({size:d,sizes:e.spacing}),m=$(x),y=o?{[s==="horizontal"?"paddingRight":"paddingBottom"]:f}:{[s==="horizontal"?"marginRight":"marginBottom"]:f};return on({flex:`0 0 ${m}`},y)},c=a.some(d=>typeof d.slideGap<"u"||typeof d.slideSize<"u")?cs(e,a).reduce((d,x)=>{const f="maxWidth"in x?"max-width":"min-width",m=we({size:f==="max-width"?x.maxWidth:x.minWidth,sizes:e.breakpoints}),y=typeof x.slideGap>"u"?n:x.slideGap,p=ls(m)-(f==="max-width"?1:0);return d[`@media (${f}: ${$(p)})`]=i(y,x.slideSize),d},{}):null;return{slide:on(on({position:"relative"},i(n,t)),c)}}),_u=Object.defineProperty,Ht=Object.getOwnPropertySymbols,uo=Object.prototype.hasOwnProperty,fo=Object.prototype.propertyIsEnumerable,Fr=(e,t,n)=>t in e?_u(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Iu=(e,t)=>{for(var n in t||(t={}))uo.call(t,n)&&Fr(e,n,t[n]);if(Ht)for(var n of Ht(t))fo.call(t,n)&&Fr(e,n,t[n]);return e},Eu=(e,t)=>{var n={};for(var s in e)uo.call(e,s)&&t.indexOf(s)<0&&(n[s]=e[s]);if(e!=null&&Ht)for(var s of Ht(e))t.indexOf(s)<0&&fo.call(e,s)&&(n[s]=e[s]);return n};const po=g.forwardRef((e,t)=>{var n=e,{children:s,className:o,size:a,gap:i}=n,l=Eu(n,["children","className","size","gap"]);const c=gu(),{classes:d,cx:x}=wu({gap:typeof i>"u"?c.slideGap:i,size:typeof a>"u"?c.slideSize:a,orientation:c.orientation,includeGapInSize:c.includeGapInSize,breakpoints:c.breakpoints},{name:"Carousel",classNames:c.classNames,styles:c.styles,unstyled:c.unstyled,variant:c.variant});return N.createElement(He,Iu({className:x(d.slide,o),ref:t},l),s)});po.displayName="@mantine/carousel/CarouselSlide";function kr({dir:e,orientation:t,direction:n}){return n==="previous"?t==="horizontal"?90*(e==="ltr"?1:-1):-180:t==="horizontal"?90*(e==="ltr"?-1:1):0}var Ou=Object.defineProperty,Kt=Object.getOwnPropertySymbols,go=Object.prototype.hasOwnProperty,mo=Object.prototype.propertyIsEnumerable,Rr=(e,t,n)=>t in e?Ou(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Pu=(e,t)=>{for(var n in t||(t={}))go.call(t,n)&&Rr(e,n,t[n]);if(Kt)for(var n of Kt(t))mo.call(t,n)&&Rr(e,n,t[n]);return e},Au=(e,t)=>{var n={};for(var s in e)go.call(e,s)&&t.indexOf(s)<0&&(n[s]=e[s]);if(e!=null&&Kt)for(var s of Kt(e))t.indexOf(s)<0&&mo.call(e,s)&&(n[s]=e[s]);return n};const Nu={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},Nn=g.forwardRef((e,t)=>{const n=Ue("Carousel",Nu,e),{children:s,className:o,getEmblaApi:a,onNextSlide:i,onPreviousSlide:l,onSlideChange:c,nextControlLabel:d,previousControlLabel:x,controlSize:f,controlsOffset:m,classNames:y,styles:p,unstyled:u,slideSize:v,slideGap:h,orientation:j,height:C,align:I,slidesToScroll:O,includeGapInSize:_,draggable:b,dragFree:w,loop:A,speed:k,initialSlide:T,inViewThreshold:G,withControls:Y,withIndicators:R,plugins:z,nextControlIcon:le,previousControlIcon:ie,breakpoints:M,skipSnaps:B,containScroll:he,withKeyboardEvents:de,variant:ue}=n,be=Au(n,["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:K,cx:xe,theme:ae}=bu({controlSize:f,controlsOffset:m,orientation:j,height:C,includeGapInSize:_,breakpoints:M,slideGap:h},{name:"Carousel",classNames:y,styles:p,unstyled:u,variant:ue}),[ee,P]=An({axis:j==="horizontal"?"x":"y",direction:j==="horizontal"?ae.dir:void 0,startIndex:T,loop:A,align:I,slidesToScroll:O,draggable:b,dragFree:w,speed:k,inViewThreshold:G,skipSnaps:B,containScroll:he},z),[fe,te]=g.useState(0),[H,S]=g.useState(0),V=g.useCallback(re=>P&&P.scrollTo(re),[P]),q=g.useCallback(()=>{if(!P)return;const re=P.selectedScrollSnap();te(re),c?.(re)},[P,te]),ne=g.useCallback(()=>{P?.scrollPrev(),l?.()},[P]),pe=g.useCallback(()=>{P?.scrollNext(),i?.()},[P]),ce=g.useCallback(re=>{de&&(re.key==="ArrowRight"&&(re.preventDefault(),pe()),re.key==="ArrowLeft"&&(re.preventDefault(),ne()))},[P]);g.useEffect(()=>{if(P)return a?.(P),q(),S(P.scrollSnapList().length),P.on("select",q),()=>{P.off("select",q)}},[P,O]),g.useEffect(()=>{P&&(P.reInit(),S(P.scrollSnapList().length),te(re=>ga(re,0,g.Children.toArray(s).length-1)))},[g.Children.toArray(s).length,O]);const ye=P?.canScrollPrev()||!1,ge=P?.canScrollNext()||!1,ve=Array(H).fill(0).map((re,Fe)=>N.createElement(Yt,{key:Fe,"data-active":Fe===fe||void 0,className:K.indicator,"aria-hidden":!0,tabIndex:-1,onClick:()=>V(Fe)}));return N.createElement(pu,{value:{slideGap:h,slideSize:v,embla:P,orientation:j,includeGapInSize:_,breakpoints:M,classNames:y,styles:p,unstyled:u,variant:ue}},N.createElement(He,Pu({className:xe(K.root,o),ref:t,onKeyDownCapture:ce},be),N.createElement("div",{className:K.viewport,ref:ee},N.createElement("div",{className:K.container},s)),R&&N.createElement("div",{className:K.indicators},ve),Y&&N.createElement("div",{className:K.controls},N.createElement(Yt,{onClick:ne,className:K.control,"aria-label":x,"data-inactive":!ye||void 0,tabIndex:ye?0:-1},typeof ie<"u"?ie:N.createElement(Bn,{style:{transform:`rotate(${kr({dir:ae.dir,orientation:j,direction:"previous"})}deg)`}})),N.createElement(Yt,{onClick:pe,className:K.control,"aria-label":d,"data-inactive":!ge||void 0,tabIndex:ge?0:-1},typeof le<"u"?le:N.createElement(Bn,{style:{transform:`rotate(${kr({dir:ae.dir,orientation:j,direction:"next"})}deg)`}})))))});Nn.Slide=po;Nn.displayName="@mantine/carousel/Carousel";const Mr=Nn,Tu=({chargeProps:e,onChange:t})=>{const{additionalDocuments:n}=L(ds,e),[s,o]=g.useState(void 0);return r.jsx("div",{className:"container mx-auto text-gray-600 body-font",children:n?.length>0?r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"flex flex-wrap",children:r.jsx(Mr,{sx:{maxWidth:320},mx:"auto",align:"center",withControls:n.length>1,slideGap:0,withIndicators:!0,className:"[&>*>.mantine-Carousel-indicator]:bg-gray-500",children:n.map(a=>r.jsx(Mr.Slide,{children:r.jsxs("div",{className:"flex flex-col items-center",children:[r.jsx("h2",{className:"text-gray-900 text-base font-medium",children:"documentType"in a?a.documentType:"Unprocessed"}),r.jsx("button",{className:"mx-10",onClick:()=>o(a.id),children:r.jsx("div",{className:"flex rounded-lg h-full bg-gray-100 p-2 m-2 flex-col",children:r.jsx(ma,{src:a.image?.toString(),withPlaceholder:!0})})})]})},a.id))})}),r.jsx(ha,{documentId:s,onDone:()=>o(void 0),onChange:t})]}):r.jsx(ln,{color:"red",children:"No Documents Related"})})},Et=({foreignAmount:e,localAmount:t,diff:n})=>{const s=e!=null&&e.currency!==Dn.Ils,o=n&&n.localAmount?.formatted!==t?.formatted,a=n&&n.foreignAmount?.formatted!==e?.formatted;return r.jsx("div",{className:"flex flex-col",children:(t||o)&&r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"flex gap-2 items-center",children:[s&&r.jsx("p",{className:a?"line-through":"",children:e.formatted}),a&&n.foreignAmount&&r.jsx("p",{className:"border-2 border-yellow-500 rounded-md",children:n.foreignAmount.formatted})]}),r.jsxs("div",{className:"flex gap-2 items-center",children:[t!=null&&r.jsx("p",{className:o?"line-through":"",children:t.formatted}),o&&n.localAmount&&r.jsx("p",{className:"border-2 border-yellow-500 rounded-md",children:n.localAmount.formatted})]})]})})},Ot=({account:e,diffAccount:t})=>{const n=t&&t?.id!==e?.id;return r.jsx("div",{className:"flex flex-col whitespace-normal",children:(e||n)&&r.jsxs(r.Fragment,{children:[e&&r.jsx(At,{to:mt.BUSINESSES.DETAIL(e.id),target:"_blank",rel:"noreferrer",onClick:s=>s.stopPropagation(),className:`inline-flex items-center font-semibold ${n?"line-through":""}`,children:e.name}),n&&t&&r.jsx("div",{className:"border-2 border-yellow-500 rounded-md",children:r.jsx(At,{to:mt.BUSINESSES.DETAIL(t.id),target:"_blank",rel:"noreferrer",onClick:s=>s.stopPropagation(),className:"inline-flex items-center font-semibold",children:t.name})})]})})},zr=({date:e,diff:t})=>{const n=e?Be(new Date(e),"dd/MM/yy"):void 0,s=t?Be(new Date(t),"dd/MM/yy"):void 0,o=s&&n!==s;return r.jsxs(r.Fragment,{children:[r.jsx("p",{className:o?"line-through":"",children:n??"Missing Data"}),o&&r.jsx("div",{className:"flex flex-col border-2 border-yellow-500 rounded-md",children:s})]})},Lr=[{accessorKey:"invoiceDate",header:({column:e})=>r.jsxs(Q,{variant:"ghost",onClick:()=>e.toggleSorting(e.getIsSorted()==="asc"),children:["Invoice Date",e.getIsSorted()&&(e.getIsSorted()==="asc"?r.jsx(De,{className:"ml-2 h-4 w-4"}):r.jsx(Se,{className:"ml-2 h-4 w-4"}))]}),cell:({row:e})=>r.jsx(zr,{date:e.original.invoiceDate,diff:e.original.diff?.invoiceDate})},{accessorKey:"valueDate",header:({column:e})=>r.jsxs(Q,{variant:"ghost",onClick:()=>e.toggleSorting(e.getIsSorted()==="asc"),children:["Value Date",e.getIsSorted()&&(e.getIsSorted()==="asc"?r.jsx(De,{className:"ml-2 h-4 w-4"}):r.jsx(Se,{className:"ml-2 h-4 w-4"}))]}),cell:({row:e})=>r.jsx(zr,{date:e.original.valueDate,diff:e.original.diff?.valueDate})},{header:"Debit Account (Main)",columns:[{accessorKey:"debitAccount1.name",header:({column:e})=>r.jsxs(Q,{variant:"ghost",onClick:()=>e.toggleSorting(e.getIsSorted()==="asc"),children:["Account",e.getIsSorted()&&(e.getIsSorted()==="asc"?r.jsx(De,{className:"ml-2 h-4 w-4"}):r.jsx(Se,{className:"ml-2 h-4 w-4"}))]}),cell:({row:e})=>r.jsx(Ot,{account:e.original.debitAccount1,diffAccount:e.original.diff?.debitAccount1})},{accessorKey:"localCurrencyDebitAmount1.raw",header:({column:e})=>r.jsxs(Q,{variant:"ghost",onClick:()=>e.toggleSorting(e.getIsSorted()==="asc"),children:["Amount",e.getIsSorted()&&(e.getIsSorted()==="asc"?r.jsx(De,{className:"ml-2 h-4 w-4"}):r.jsx(Se,{className:"ml-2 h-4 w-4"}))]}),cell:({row:e})=>r.jsx(Et,{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})=>r.jsxs(Q,{variant:"ghost",onClick:()=>e.toggleSorting(e.getIsSorted()==="asc"),children:["Account",e.getIsSorted()&&(e.getIsSorted()==="asc"?r.jsx(De,{className:"ml-2 h-4 w-4"}):r.jsx(Se,{className:"ml-2 h-4 w-4"}))]}),cell:({row:e})=>r.jsx(Ot,{account:e.original.creditAccount1,diffAccount:e.original.diff?.creditAccount1})},{accessorKey:"localCurrencyCreditAmount1.raw",header:({column:e})=>r.jsxs(Q,{variant:"ghost",onClick:()=>e.toggleSorting(e.getIsSorted()==="asc"),children:["Amount",e.getIsSorted()&&(e.getIsSorted()==="asc"?r.jsx(De,{className:"ml-2 h-4 w-4"}):r.jsx(Se,{className:"ml-2 h-4 w-4"}))]}),cell:({row:e})=>r.jsx(Et,{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})=>r.jsxs(Q,{variant:"ghost",onClick:()=>e.toggleSorting(e.getIsSorted()==="asc"),children:["Account",e.getIsSorted()&&(e.getIsSorted()==="asc"?r.jsx(De,{className:"ml-2 h-4 w-4"}):r.jsx(Se,{className:"ml-2 h-4 w-4"}))]}),cell:({row:e})=>r.jsx(Ot,{account:e.original.debitAccount2,diffAccount:e.original.diff?.debitAccount2})},{accessorKey:"localCurrencyDebitAmount2.raw",header:({column:e})=>r.jsxs(Q,{variant:"ghost",onClick:()=>e.toggleSorting(e.getIsSorted()==="asc"),children:["Amount",e.getIsSorted()&&(e.getIsSorted()==="asc"?r.jsx(De,{className:"ml-2 h-4 w-4"}):r.jsx(Se,{className:"ml-2 h-4 w-4"}))]}),cell:({row:e})=>r.jsx(Et,{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})=>r.jsxs(Q,{variant:"ghost",onClick:()=>e.toggleSorting(e.getIsSorted()==="asc"),children:["Account",e.getIsSorted()&&(e.getIsSorted()==="asc"?r.jsx(De,{className:"ml-2 h-4 w-4"}):r.jsx(Se,{className:"ml-2 h-4 w-4"}))]}),cell:({row:e})=>r.jsx(Ot,{account:e.original.creditAccount2,diffAccount:e.original.diff?.creditAccount2})},{accessorKey:"localCurrencyCreditAmount2.raw",header:({column:e})=>r.jsxs(Q,{variant:"ghost",onClick:()=>e.toggleSorting(e.getIsSorted()==="asc"),children:["Amount",e.getIsSorted()&&(e.getIsSorted()==="asc"?r.jsx(De,{className:"ml-2 h-4 w-4"}):r.jsx(Se,{className:"ml-2 h-4 w-4"}))]}),cell:({row:e})=>r.jsx(Et,{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})=>r.jsxs(Q,{variant:"ghost",onClick:()=>e.toggleSorting(e.getIsSorted()==="asc"),children:["Details",e.getIsSorted()&&(e.getIsSorted()==="asc"?r.jsx(De,{className:"ml-2 h-4 w-4"}):r.jsx(Se,{className:"ml-2 h-4 w-4"}))]}),cell:({row:{original:e}})=>{const t=e.diff&&e.diff.description!==e.description;return r.jsxs("div",{className:"flex flex-col whitespace-normal",children:[r.jsx("p",{className:t?"line-through":"",children:e.description}),t&&r.jsx("div",{className:"border-2 border-yellow-500 rounded-md",children:e.diff?.description})]})}},{accessorKey:"reference",header:({column:e})=>r.jsxs(Q,{variant:"ghost",onClick:()=>e.toggleSorting(e.getIsSorted()==="asc"),children:["Reference",e.getIsSorted()&&(e.getIsSorted()==="asc"?r.jsx(De,{className:"ml-2 h-4 w-4"}):r.jsx(Se,{className:"ml-2 h-4 w-4"}))]}),cell:({row:{original:e}})=>{const t=e.diff&&e.diff.reference!==e.reference;return r.jsxs("div",{className:"flex flex-col whitespace-normal",children:[r.jsx("p",{className:t?"line-through":"",children:e.reference}),t&&r.jsx("div",{className:"border-2 border-yellow-500 rounded-md",children:e.diff?.reference})]})}},{accessorKey:"matchingStatus",header:({column:e})=>r.jsxs(Q,{variant:"ghost",onClick:()=>e.toggleSorting(e.getIsSorted()==="asc"),children:["Status",e.getIsSorted()&&(e.getIsSorted()==="asc"?r.jsx(De,{className:"ml-2 h-4 w-4"}):r.jsx(Se,{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 r.jsx(us,{variant:"default",className:t,children:e})}return null}}];function $u(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 Fu=({ledgerRecordsData:e,ledgerDiffData:t,matches:n})=>{const[s,o]=g.useState([]),a=g.useMemo(()=>{const l=e.map(f=>L(Vn,f)),c=t?.map(f=>L(Vn,f)),d=l.map(f=>{const m=c?.find(y=>y.id===f.id);return{...f,matchingStatus:!n||n?.includes(f.id)?void 0:m?"Diff":"Deleted",diff:m}}),x=c?.filter(f=>f.id===xa).map(f=>({...f,matchingStatus:"New"}))??[];return d.push(...x),d},[e,t,n]),i=qr({data:a,columns:Lr,getCoreRowModel:Yr(),onSortingChange:o,getSortedRowModel:Wr(),getPaginationRowModel:ya(),state:{sorting:s},initialState:{pagination:{pageIndex:0,pageSize:10},sorting:[{id:"invoiceDate",desc:!0}]}});return r.jsxs(r.Fragment,{children:[r.jsxs(jn,{children:[r.jsx(bn,{children:i.getHeaderGroups().map(l=>r.jsx(Ye,{children:l.headers.map(c=>r.jsx(Te,{className:"text-center",colSpan:c.colSpan,children:c.isPlaceholder?null:Pt(c.column.columnDef.header,c.getContext())},c.id))},l.id))}),r.jsx(Cn,{children:i.getRowModel().rows?.length?i.getRowModel().rows.map(l=>r.jsx(Ye,{"data-state":l.getIsSelected()&&"selected",className:$u(l.original.matchingStatus),children:l.getVisibleCells().map(c=>r.jsx(Ie,{children:Pt(c.column.columnDef.cell,c.getContext())},c.id))},l.id)):r.jsx(Ye,{children:r.jsx(Ie,{colSpan:Lr.length,className:"h-24 text-center",children:"No results."})})})]}),r.jsx("div",{className:"flex items-center justify-end space-x-2 py-4",children:r.jsx(va,{value:i.getState().pagination.pageIndex,total:i.getPageCount(),onChange:l=>i.setPageIndex(l)})})]})},ku=({data:e})=>{const t=L(ps,e);return t?.errorsLedger?.validate?.errors?.length?r.jsxs(fs,{shadow:"xs",p:"md",children:[r.jsx(Qe,{c:"red",children:"Errors:"}),r.jsx(Hn,{size:"sm",withPadding:!0,children:t.errorsLedger.validate.errors.map((n,s)=>r.jsx(Hn.Item,{children:r.jsx(Qe,{c:"red",children:n})},s))})]}):null},Ru=({transactionsProps:e,onChange:t})=>{const{transactions:n}=L(gs,e);return r.jsx(bs,{transactionsProps:n,onChange:t,enableEdit:!0})},Mu=({chargeId:e})=>{const[{data:t,fetching:n}]=Xe({query:ja,variables:{chargeId:e}}),s=g.useMemo(()=>t?.depositByCharge?.transactions?.filter(o=>o.chargeId!==e)??[],[t?.depositByCharge?.transactions,e]);return n?r.jsx(is,{className:"h-10 w-10 animate-spin"}):t?.depositByCharge?r.jsxs("div",{children:[r.jsxs("div",{className:"text-lg font-semibold mb-4",children:['Bank Deposit "',t?.depositByCharge?.id,'" Balance:'," ",t?.depositByCharge?.balance.formatted]}),r.jsx("div",{className:"mb-4",children:r.jsx("span",{className:"text-sm text-gray-500",children:t?.depositByCharge?.isOpen?"Deposit is open":"Deposit is closed"})}),s.length===0?r.jsx("div",{className:"text-sm text-gray-500",children:"No transactions found for this deposit."}):r.jsx(bs,{transactionsProps:s,enableChargeLink:!0})]}):r.jsx("div",{className:"text-sm text-gray-500",children:"No bank deposit found for this charge."})},zu=({chargeProps:e})=>{const t=L(ms,e);if(t.__typename!=="ConversionCharge")return r.jsx(r.Fragment,{});const{eventRate:n,officialRate:s}=t;return r.jsxs(Qt,{justify:"center",children:[s&&r.jsx(Qt.Col,{span:"content",children:r.jsx(Kn,{shadow:"sm",padding:"xs",radius:"md",withBorder:!0,children:r.jsxs(an,{position:"apart",children:[r.jsx(Qe,{weight:500,children:"Official Conversion Rate"}),r.jsx(ln,{color:"green",variant:"light",children:`${Number(s.rate)} ${tt(s.from)} => ${tt(s.to)}`})]})})}),n&&r.jsx(Qt.Col,{span:"content",children:r.jsx(Kn,{shadow:"sm",padding:"xs",radius:"md",withBorder:!0,children:r.jsxs(an,{position:"apart",children:[r.jsx(Qe,{weight:500,children:"Bank Conversion Rate"}),r.jsx(ln,{color:"green",variant:"light",children:`${Number(n.rate)} ${tt(n.from)} => ${tt(n.to)}`})]})})})]})},Lu=({chargeProps:e})=>{const t=L(hs,e),n=g.useMemo(()=>t.__typename==="CreditcardBankCharge"&&t.creditCardTransactions?t.creditCardTransactions.map(s=>L(ba,s)):[],[t]);return n.length?r.jsxs(jn,{children:[r.jsx(bn,{children:r.jsxs(Ye,{children:[r.jsx(Te,{children:"Event Date"}),r.jsx(Te,{children:"Debit Date"}),r.jsx(Te,{children:"Amount"}),r.jsx(Te,{children:"Account"}),r.jsx(Te,{children:"Description"}),r.jsx(Te,{children:"Reference#"}),r.jsx(Te,{children:"Counterparty"}),r.jsx(Te,{children:"Charge"})]})}),r.jsx(Cn,{children:n.map(s=>{const o={...s,onUpdate:()=>{},editTransaction:()=>{},enableEdit:!1,enableChargeLink:!1};return r.jsxs(Ye,{children:[r.jsx(Ie,{children:r.jsx(Ta,{transaction:o})}),r.jsx(Ie,{children:r.jsx($a,{transaction:o})}),r.jsx(Ie,{children:r.jsx(Fa,{transaction:o})}),r.jsx(Ie,{children:r.jsx(ka,{transaction:o})}),r.jsx(Ie,{children:r.jsx(Ra,{transaction:o})}),r.jsx(Ie,{children:r.jsx(Ma,{transaction:o})}),r.jsx(Ie,{children:r.jsx(za,{transaction:o})}),r.jsx(Ie,{children:r.jsx(La,{chargeId:s.chargeId})})]},s.id)})})]}):null},Bu=({chargeProps:e})=>{const t=L(xs,e),n=g.useMemo(()=>t.__typename!=="FinancialCharge"?[]:Object.entries(t.exchangeRates??{}).sort((s,o)=>s[0].localeCompare(o[0])),[t]);return t.__typename!=="FinancialCharge"?r.jsx(r.Fragment,{}):r.jsx("div",{className:"flex flex-row flex-wrap gap-2 px-2",children:n.map(([s,o])=>r.jsx(Qr,{className:"gap-0 py-2",children:r.jsxs(Ca,{className:"flex flex-col px-2",children:[r.jsx(Da,{className:"text-xl font-semibold",children:s.toLocaleUpperCase()}),r.jsxs("div",{className:"flex items-center space-x-2",children:[r.jsxs("span",{className:"whitespace-nowrap",children:[tt(s.toLocaleUpperCase()),"1="]}),r.jsxs(us,{variant:"default",className:"flex gap-1 rounded-lg text-md",children:[tt(Dn.Ils),o]})]})]})},s))})},Vu="deleteMiscExpense",Uu=()=>{const[{fetching:e},t]=Pe(Sa),n=g.useCallback(async s=>{const o="Error deleting misc expense",a=`${Vu}-${s.id}`;F.loading("Deleting misc expense",{id:a});try{const i=await t(s),l=Ae(i,o,a);if(l)return F.success("Success",{id:a,description:"Misc expense was deleted successfully"}),l.deleteMiscExpense}catch(i){console.error(`${o}: ${i}`),F.error("Error",{id:a,description:o,duration:1e5,closeButton:!0})}},[t]);return{fetching:e,deleteMiscExpense:n}};function Hu({miscExpenseId:e,onChange:t}){const{deleteMiscExpense:n}=Uu();async function s(){try{await n({id:e}),t?.()}catch(o){const a="Failed to delete misc expense";console.error(`${a}: ${o}`),F.error("Error",{description:a})}}return r.jsx(Gt,{onConfirm:s,title:"Are you sure you want to delete this expense?",children:r.jsx(Q,{className:"size-7.5 text-red-500",variant:"ghost",children:r.jsx(Sn,{className:"size-5"})})})}const Ku=({miscExpensesData:e,onChange:t})=>{const n=L(ys,e),{miscExpenses:s}=n;return r.jsxs("table",{className:"w-full h-full",children:[r.jsx("thead",{children:r.jsxs("tr",{children:[r.jsx("th",{children:"Creditor"}),r.jsx("th",{children:"Debtor"}),r.jsx("th",{children:"Amount"}),r.jsx("th",{children:"Invoice Date"}),r.jsx("th",{children:"Value Date"}),r.jsx("th",{children:"Description"}),r.jsx("th",{children:"Actions"})]})}),r.jsx("tbody",{children:s?.map(o=>r.jsxs("tr",{children:[r.jsx("td",{children:r.jsx("div",{children:o.creditor?.name})}),r.jsx("td",{children:r.jsx("div",{children:o.debtor?.name})}),r.jsx("td",{children:r.jsx("div",{children:o.amount?.formatted})}),r.jsx("td",{children:r.jsx("div",{children:o.invoiceDate})}),r.jsx("td",{children:r.jsx("div",{children:o.valueDate&&Be(new Date(o.valueDate),"yyyy-MM-dd")})}),r.jsx("td",{children:r.jsx("div",{children:o.description})}),r.jsxs("td",{children:[r.jsx(rd,{onDone:t,data:o}),r.jsx(Hu,{miscExpenseId:o.id,onChange:t})]})]},o?.id))})]})},Gu=({salaryRecordsProps:e})=>{const t=L(vs,e);if(t.__typename!=="SalaryCharge")return r.jsx(r.Fragment,{});const{salaryRecords:n}=t;return r.jsxs("table",{className:"w-full h-full",children:[r.jsx("thead",{children:r.jsxs("tr",{children:[r.jsx("th",{children:"Employee"}),r.jsx("th",{children:"Direct Salary"}),r.jsx("th",{children:"Base Salary"}),r.jsx("th",{children:"Pension"}),r.jsx("th",{children:"Training Fund"}),r.jsx("th",{children:"Social Security"}),r.jsx("th",{children:"Tax"})]})}),r.jsx("tbody",{children:n?.map(s=>r.jsxs("tr",{children:[r.jsx("td",{children:r.jsx("div",{children:s.employee?.name??"Missing"})}),r.jsx("td",{children:r.jsx("div",{children:s.directAmount.formatted})}),r.jsx("td",{children:r.jsx("div",{children:s.baseAmount?.formatted})}),r.jsxs("td",{children:[r.jsx("div",{children:s.pensionFund?.name}),r.jsxs("div",{children:["Employee: ",s.pensionEmployeeAmount?.formatted]}),r.jsxs("div",{children:["Employer: ",s.pensionEmployerAmount?.formatted]}),r.jsxs("div",{children:["Compensation: ",s.compensationsAmount?.formatted]})]}),r.jsxs("td",{children:[r.jsx("div",{children:s.trainingFund?.name}),r.jsxs("div",{children:["Employee: ",s.trainingFundEmployeeAmount?.formatted]}),r.jsxs("div",{children:["Employer: ",s.trainingFundEmployerAmount?.formatted]})]}),r.jsxs("td",{children:[r.jsxs("div",{children:["Employee: ",s.socialSecurityEmployeeAmount?.formatted]}),r.jsxs("div",{children:["Employer: ",s.socialSecurityEmployerAmount?.formatted]}),r.jsxs("div",{children:["Health: ",s.healthInsuranceAmount?.formatted]})]}),r.jsx("td",{children:r.jsx("div",{children:s.incomeTaxAmount?.formatted})})]},`${s.employee?.name}-${s.baseAmount}`))})]})};function qu({chargeID:e,onChange:t=()=>{},fetching:n}){const[s,o]=g.useState([]),[a,i]=g.useState(e),[l,{toggle:c}]=gt(!1),[d,x]=g.useState(void 0),[{data:f,fetching:m},y]=Xe({query:_e,variables:{chargeId:a}}),p=g.useCallback(()=>{y(),t()},[y,t]);g.useEffect(()=>{f?.charge&&x(f.charge)},[f]),g.useEffect(()=>{n&&y()},[n,y]),g.useEffect(()=>{e!==a&&(i(e),y())},[e,a,y]);const u=d?.__typename,v=!!d?.metadata?.ledgerCount,h=!!d?.metadata?.transactionsCount,j=!!d?.metadata?.documentsCount,C=!!d?.metadata?.receiptsCount,I=u==="SalaryCharge",O=!!d?.miscExpenses?.length,_=d?.metadata?.openDocuments,b=(d?.totalAmount?.raw??0)>0&&!C;g.useEffect(()=>{const M=[];h&&M.push("transactions"),j&&M.push("documents"),v&&M.push("ledger"),I&&M.push("salaries"),O&&M.push("miscExpenses"),u==="BankDepositCharge"&&M.push("bankDeposit"),o(M)},[h,j,v,I,O,u]);function w(M){s.includes(M)?o(B=>B.filter(he=>he!==M)):o(B=>[...B,M])}const A=je(_e,ds,d),k=je(_e,Un,d),T=je(_e,js,d),G=je(_e,gs,d),Y=je(_e,ys,d),R=g.useMemo(()=>u==="ConversionCharge"&&je(_e,ms,d),[d,u]),z=g.useMemo(()=>u==="FinancialCharge"&&je(_e,xs,d),[d,u]),le=u==="SalaryCharge"&&je(_e,vs,d),ie=g.useMemo(()=>u==="CreditcardBankCharge"&&je(_e,hs,d),[d,u]);return r.jsxs("div",{className:"flex flex-col gap-5",children:[m&&r.jsx(jt,{className:"flex self-center my-5",color:"dark",size:"xl",variant:"dots"}),je(_e,ps,d)&&r.jsx(ku,{data:d}),d&&r.jsxs("div",{className:"flex flex-row",children:[r.jsxs(U,{className:"w-full",multiple:!0,value:s,chevron:r.jsx(ns,{size:"1rem"}),styles:{chevron:{"&[data-rotate]":{transform:"rotate(45deg)"}}},children:[u==="ConversionCharge"&&r.jsxs(U.Item,{value:"conversion",children:[r.jsx(U.Control,{disabled:!h,onClick:()=>w("conversion"),children:"Conversion Info"}),r.jsx(U.Panel,{children:R&&r.jsx(zu,{chargeProps:d})})]}),u==="FinancialCharge"&&r.jsxs(U.Item,{value:"exchangeRates",children:[r.jsx(U.Control,{disabled:!z,onClick:()=>w("exchangeRates"),children:"Exchange Rates"}),r.jsx(U.Panel,{children:z&&r.jsx(Bu,{chargeProps:d})})]}),h&&r.jsxs(U.Item,{value:"transactions",children:[r.jsx(U.Control,{disabled:!h,onClick:()=>w("transactions"),children:r.jsxs("div",{className:"flex flex-row items-center gap-2 justify-between w-full",children:["Transactions",b&&r.jsx(cn,{chargeId:d.id})]})}),r.jsx(U.Panel,{children:G&&r.jsx(Ru,{transactionsProps:d,onChange:p})})]}),O&&r.jsxs(U.Item,{value:"miscExpenses",children:[r.jsx(U.Control,{disabled:!O,onClick:()=>w("miscExpenses"),children:"Misc Expenses"}),r.jsx(U.Panel,{children:Y&&r.jsx(Ku,{miscExpensesData:d,onChange:p})})]}),j&&r.jsxs(U.Item,{value:"documents",children:[r.jsx(U.Control,{disabled:!j,onClick:()=>w("documents"),children:r.jsxs("div",{className:"flex flex-row items-center gap-2 justify-between w-full",children:[r.jsxs("div",{className:"flex flex-row items-center gap-2 justify-start",children:[j&&r.jsx(Le,{label:"Documents Gallery",children:r.jsx(Q,{onClick:M=>{M.stopPropagation(),c()},variant:"outline",disabled:!A,size:"icon",className:"size-7.5 text-gray-500",children:r.jsx(wa,{className:"size-5"})})}),"Documents"]}),_&&r.jsx(cn,{chargeId:d.id})]})}),r.jsx(U.Panel,{children:k&&r.jsx(_a,{documentsProps:L(Un,d)?.additionalDocuments,onChange:p})})]}),u==="SalaryCharge"&&r.jsxs(U.Item,{value:"salaries",children:[r.jsx(U.Control,{disabled:!I,onClick:()=>w("salaries"),children:"Salaries"}),r.jsx(U.Panel,{children:le&&r.jsx(Gu,{salaryRecordsProps:d})})]}),d.__typename==="BusinessTripCharge"&&r.jsxs(U.Item,{value:"businessTrip",children:[r.jsx(U.Control,{onClick:()=>w("businessTrip"),children:"Business Trip"}),r.jsx(U.Panel,{children:r.jsx(pc,{data:d.businessTrip})})]}),u==="CreditcardBankCharge"&&r.jsxs(U.Item,{value:"creditcard",children:[r.jsx(U.Control,{onClick:()=>w("creditcard"),children:"CreditCard Transactions"}),r.jsx(U.Panel,{children:ie&&r.jsx(Lu,{chargeProps:d})})]}),u==="BankDepositCharge"&&r.jsxs(U.Item,{value:"bankDeposit",children:[r.jsx(U.Control,{onClick:()=>w("bankDeposit"),children:"Bank Deposit"}),r.jsx(U.Panel,{children:r.jsx(Mu,{chargeId:d.id})})]}),v&&r.jsxs(U.Item,{value:"ledger",children:[r.jsx(U.Control,{disabled:!v,onClick:M=>{M.stopPropagation(),w("ledger")},children:r.jsxs("div",{className:"flex flex-row items-center gap-2 justify-start w-full",children:[!d.metadata?.isLedgerLocked&&r.jsx(yc,{chargeId:d.id,onChange:p,variant:"outline"}),"Ledger Records"]})}),r.jsx(U.Panel,{children:T&&r.jsx(Wu,{data:d})})]})]}),A&&r.jsx(He,{maw:"1/6",children:r.jsx(Ha,{in:l,transitionDuration:500,transitionTimingFunction:"linear",children:r.jsx(Tu,{chargeProps:d,onChange:p})})})]}),!m&&!d&&r.jsx("p",{children:"Error fetching extended information for this charge"})]})}const Wu=({data:e})=>{const{ledger:t}=L(js,e);return r.jsx(Fu,{ledgerRecordsData:t.records,ledgerDiffData:t.validate?.differences,matches:t.validate?.matches})},Yu=({setEditCharge:e,setInsertDocument:t,setMatchDocuments:n,toggleMergeCharge:s,isSelectedForMerge:o,data:a,isAllOpened:i})=>{const[l,c]=g.useState(!1),[d,x]=g.useState(L(qe,a)),[{data:f,fetching:m},y]=Xe({query:Ia,pause:!0,variables:{chargeId:a.id}}),p=y;g.useEffect(()=>{const h=f?.charge;h&&x(L(qe,h))},[f]),g.useEffect(()=>{x(L(qe,a))},[a]),g.useEffect(()=>{c(i)},[i]);const u=g.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]),v=(d?.totalAmount?.raw??0)>0;return r.jsxs(r.Fragment,{children:[r.jsxs("tr",{onClick:()=>{u&&(c(h=>!h),p())},children:[r.jsx(vd,{data:d}),r.jsx(gd,{data:d}),r.jsx(ud,{data:d}),r.jsx(jd,{data:d}),je(qe,Xr,d)?r.jsx(pd,{data:d}):r.jsx("td",{}),r.jsx(md,{data:d,onChange:p}),je(qe,es,d)?r.jsx(xd,{data:d,onChange:p}):r.jsx("td",{}),je(qe,ts,d)?r.jsx(yd,{data:d}):r.jsx("td",{}),je(qe,Jr,d)?r.jsx(fd,{data:d}):r.jsx("td",{}),r.jsx(hd,{data:d}),r.jsx(dd,{data:d,onChange:p}),r.jsx("td",{children:r.jsxs("div",{className:"flex flex-col gap-2",children:[e&&r.jsx(Ea,{onClick:h=>{h.stopPropagation(),e(p)}}),s&&r.jsx(vc,{toggleMergeSelected:()=>s(p),mergeSelected:o})]})}),r.jsx("td",{children:r.jsxs("div",{className:"flex flex-col gap-2",children:[r.jsx(Ad,{chargeId:d.id,chargeType:d.__typename,setInsertDocument:t?()=>t(p):void 0,setMatchDocuments:n,onChange:p,isIncome:v}),u&&r.jsx(Pa,{toggleExpansion:c,isExpanded:l,onClickAction:()=>p()})]})})]}),u&&l&&r.jsx("tr",{children:r.jsx("td",{colSpan:13,children:r.jsx(fs,{style:{width:"100%"},withBorder:!0,shadow:"lg",children:r.jsx(qu,{chargeID:d.id,onChange:p,fetching:m})})})})]})},nf=({setEditChargeId:e,setInsertDocument:t,setMatchDocuments:n,toggleMergeCharge:s,mergeSelectedCharges:o,data:a,isAllOpened:i})=>{const l=a?.map(c=>L(Oa,c))??[];return r.jsxs(Cs,{striped:!0,highlightOnHover:!0,children:[r.jsx("thead",{className:"sticky top-0 z-20",children:r.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:[r.jsx("th",{children:"Type"}),r.jsx("th",{children:"Date"}),r.jsx("th",{children:"Amount"}),r.jsx("th",{children:"Vat"}),r.jsx("th",{children:"Counterparty"}),r.jsx("th",{children:"Description"}),r.jsx("th",{children:"Tags"}),r.jsx("th",{children:"Tax Category"}),r.jsx("th",{children:"Business Trip"}),r.jsx("th",{children:"More Info"}),r.jsx("th",{children:"Accountant Approval"}),r.jsx("th",{children:"Edit"}),r.jsx("th",{children:"More Info"})]})}),r.jsx("tbody",{children:l?.map(c=>r.jsx(Yu,{data:c,setEditCharge:e?d=>e({id:c.id,onChange:d}):void 0,setInsertDocument:t?d=>t({id:c.id,onChange:d}):void 0,setMatchDocuments:n?()=>n({id:c.id,ownerId:c.owner.id}):void 0,toggleMergeCharge:s?d=>s(c.id,d):void 0,isSelectedForMerge:o?.has(c.id)??!1,isAllOpened:i},c.id))})]})};export{nf as C,Fu as L,id as S,zs as T,vc as a,qu as b,so as c,Ls as d,oo as e,Ds as f,ld as u};