@accounter/client 0.0.8-alpha-20251029111239-192c5afd2d66a4d11ea8217039b86666b6fff216 → 0.0.8-alpha-20251029124448-6b4f8bc975a23de63429b68d0806022dbfc5b226

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 (115) hide show
  1. package/CHANGELOG.md +1 -1
  2. package/dist/assets/{Checkbox-BfB2aYmM.js → Checkbox-Ddw01d64.js} +2 -2
  3. package/dist/assets/{MultiSelect-CGvaXcuH.js → MultiSelect-CBtq6WUv.js} +1 -1
  4. package/dist/assets/{Pagination-D4fkmYTl.js → Pagination-BM-86UO5.js} +1 -1
  5. package/dist/assets/{Progress-CQs7EuQ2.js → Progress-Bda-J3ZH.js} +1 -1
  6. package/dist/assets/{Table-C2EjuqpH.js → Table-CYqAEQfS.js} +1 -1
  7. package/dist/assets/{Typography-bz4ZX5sI.js → Typography--U0GsZ21.js} +1 -1
  8. package/dist/assets/{YearPickerInput-CURoIYu6.js → YearPickerInput-CgU-feeq.js} +1 -1
  9. package/dist/assets/{accordion-DWmBRtUi.js → accordion-B8kebokE.js} +1 -1
  10. package/dist/assets/{accountant-approvals-C9FCfRoL.js → accountant-approvals-CUluc3sH.js} +1 -1
  11. package/dist/assets/{accounter-table-C70NKDaW.js → accounter-table-CM6PQ9Aw.js} +1 -1
  12. package/dist/assets/{addDays-BGYF7FkS.js → addDays-DGlDD_vj.js} +1 -1
  13. package/dist/assets/{all-charges-CkPb7TjD.js → all-charges-DpQS6Xp3.js} +1 -1
  14. package/dist/assets/{arrow-up-down-B-KqfJyD.js → arrow-up-down-C61ge4J5.js} +1 -1
  15. package/dist/assets/{building-2-BAwr8r-2.js → building-2-3KauBrnS.js} +1 -1
  16. package/dist/assets/{business-DLu0ofgu.js → business-RCuQN-RO.js} +7 -17
  17. package/dist/assets/business-extended-info-DmQ7B7-Z.js +13 -0
  18. package/dist/assets/{business-header-B_qcrJW_.js → business-header-B-uHcc1D.js} +1 -1
  19. package/dist/assets/business-transactions-filters-D-Y8vZwZ.js +1 -0
  20. package/dist/assets/business-transactions-single-CEE249QN.js +1 -0
  21. package/dist/assets/business-trip-3kCBQ5MD.js +1 -0
  22. package/dist/assets/{charge-aBSxCGi3.js → charge-D19rkm2C.js} +1 -1
  23. package/dist/assets/{charges-filters-BRuJ3XbB.js → charges-filters-BUFmsiTq.js} +1 -1
  24. package/dist/assets/{charges-ledger-validation-DjuvGES2.js → charges-ledger-validation-OPtbHzXu.js} +1 -1
  25. package/dist/assets/charges-table-D_GDHvFS.js +62 -0
  26. package/dist/assets/{chart-BSh0rsm7.js → chart-iyOBgiH0.js} +1 -1
  27. package/dist/assets/{data-table-pagination-BCuaIseR.js → data-table-pagination-CKN0E29f.js} +1 -1
  28. package/dist/assets/download-csv-button-DZ5cKqkV.js +1 -0
  29. package/dist/assets/{editable-business-trip-BLWzKbN3.js → editable-business-trip-CRiuNdbP.js} +1 -1
  30. package/dist/assets/{funnel-XiON1wPY.js → funnel-BlaCusqP.js} +1 -1
  31. package/dist/assets/{index-BdnLryTF.js → index-B2_EbsaK.js} +191 -191
  32. package/dist/assets/index-B8pzYiEH.js +1 -0
  33. package/dist/assets/{index-DOSLXKPY.js → index-BAGVbiiM.js} +1 -1
  34. package/dist/assets/{index-D7GKOJU4.js → index-BD86tRnn.js} +2 -2
  35. package/dist/assets/{index-C_nLGgCr.js → index-BGh0NOfw.js} +1 -1
  36. package/dist/assets/{index-CtDDVAsw.js → index-BKiLhEyi.js} +1 -1
  37. package/dist/assets/{index-D9RA6cVt.js → index-BNAjS3Tn.js} +2 -2
  38. package/dist/assets/{index-DbbPcdZ7.js → index-BRSlJnxd.js} +2 -2
  39. package/dist/assets/{index-CA6LHUxs.js → index-BoL57v1D.js} +1 -1
  40. package/dist/assets/{index-C-RIsd1H.js → index-C2GP2DWO.js} +2 -2
  41. package/dist/assets/{index-CJP0f2Bm.js → index-CM60VmgR.js} +1 -1
  42. package/dist/assets/index-CRLPoT61.js +6 -0
  43. package/dist/assets/index-CRooGu6R.js +1 -0
  44. package/dist/assets/{index-CxE91GPE.js → index-C_OSDuUb.js} +1 -1
  45. package/dist/assets/{index-CVNgfFi3.js → index-Cc7exUI5.js} +1 -1
  46. package/dist/assets/{index-BwrF7ixX.js → index-Co66MgF6.js} +2 -2
  47. package/dist/assets/{index-BPLQ_Cjg.js → index-CyBAoT0l.js} +1 -1
  48. package/dist/assets/{index-BYCdqffp.js → index-D5tmtR-a.js} +7 -7
  49. package/dist/assets/{index-3Fyx3NBp.js → index-DINxWoMX.js} +1 -1
  50. package/dist/assets/{index-BdzdEbUC.js → index-DIiuo0-v.js} +1 -1
  51. package/dist/assets/{index-Diqx01g3.js → index-DtrRL2jA.js} +1 -1
  52. package/dist/assets/{index-BVTpNGNk.js → index-EaY6ZYvr.js} +2 -2
  53. package/dist/assets/{index-DaSx2wiU.js → index-mMqWkzUL.js} +1 -1
  54. package/dist/assets/{index-pjJUDHWQ.js → index-xLWv_qf6.js} +1 -1
  55. package/dist/assets/{index-By2sHbGk.js → index-yOhbO3fy.js} +1 -1
  56. package/dist/assets/{index.es-BWSz-k0E.js → index.es-CaOIcY7v.js} +1 -1
  57. package/dist/assets/{insert-business-trip-modal-Bk-kugZI.js → insert-business-trip-modal-BwOnvw7X.js} +2 -2
  58. package/dist/assets/issue-document-CzBtBCCO.js +1 -0
  59. package/dist/assets/{list-plus-DINtfnSi.js → list-plus-CGvSlslE.js} +1 -1
  60. package/dist/assets/{login-page-DVwxXAvd.js → login-page-BTcklqv4.js} +1 -1
  61. package/dist/assets/{match-document-modal--iAusdTp.js → match-document-modal-DcL0siQq.js} +4 -4
  62. package/dist/assets/{missing-info-charges-CQNTClQ3.js → missing-info-charges-DfwRkzNe.js} +1 -1
  63. package/dist/assets/{modal-BzwJJ2TM.js → modal-B0uNLang.js} +1 -1
  64. package/dist/assets/{page-layout-NF77oib6.js → page-layout-C0GJoVTR.js} +1 -1
  65. package/dist/assets/{page-not-found-Cu_0zp5u.js → page-not-found-9UX5vsGE.js} +1 -1
  66. package/dist/assets/{panel-top-open-BApXXBMD.js → panel-top-open-BFNhAe3f.js} +1 -1
  67. package/dist/assets/{pencil-CLaFsm6E.js → pencil-9Th5X-OY.js} +1 -1
  68. package/dist/assets/{report-commentary-row-BGN_tI-P.js → report-commentary-row-CNIlhboC.js} +1 -1
  69. package/dist/assets/{save-DsE11_Et.js → save-qtyyZLc5.js} +1 -1
  70. package/dist/assets/{similar-transactions-modal-CoZU6FU3.js → similar-transactions-modal-nk8VHEtX.js} +1 -1
  71. package/dist/assets/sub-fkVv9ghZ.js +1 -0
  72. package/dist/assets/subMonths-5wFmciT1.js +1 -0
  73. package/dist/assets/{summary-BasZ3QlN.js → summary-DuWhfNdL.js} +1 -1
  74. package/dist/assets/{toggle-expansion-button-DPcDIe-2.js → toggle-expansion-button-41Ejffq3.js} +1 -1
  75. package/dist/assets/tooltip-lhMCop8U.js +1 -0
  76. package/dist/assets/{use-url-query-Bp_LkJaa.js → use-url-query-BPzyQB93.js} +1 -1
  77. package/dist/index.html +1 -1
  78. package/package.json +1 -1
  79. package/src/app.tsx +108 -0
  80. package/src/components/business/index.tsx +1 -31
  81. package/src/components/business/transactions-section.tsx +2 -24
  82. package/src/components/{business-ledger → business-transactions}/business-extended-info.tsx +27 -25
  83. package/src/components/{business-ledger/business-ledger-filters.tsx → business-transactions/business-transactions-filters.tsx} +12 -12
  84. package/src/components/{business-ledger/business-ledger-single.tsx → business-transactions/business-transactions-single.tsx} +13 -13
  85. package/src/components/{business-ledger → business-transactions}/download-csv.tsx +25 -25
  86. package/src/components/{business-ledger → business-transactions}/index.tsx +15 -15
  87. package/src/components/charges/charge-extended-info.tsx +4 -45
  88. package/src/components/layout/sidelinks.tsx +2 -2
  89. package/src/components/ledger-table/columns.tsx +4 -4
  90. package/src/components/ledger-table/index.tsx +181 -152
  91. package/src/components/reports/conto/custom-node.tsx +1 -1
  92. package/src/components/reports/trial-balance-report/trial-balance-report-account.tsx +1 -1
  93. package/src/components/transactions-table/columns.tsx +9 -9
  94. package/src/components/transactions-table/index.tsx +21 -56
  95. package/src/gql/gql.ts +12 -30
  96. package/src/gql/graphql.ts +406 -181
  97. package/src/providers/index.ts +4 -0
  98. package/src/router/config.tsx +14 -14
  99. package/src/router/routes.ts +2 -2
  100. package/dist/assets/business-extended-info-vAiMQKwm.js +0 -13
  101. package/dist/assets/business-ledger-filters-CNjRVS0K.js +0 -1
  102. package/dist/assets/business-ledger-single-BrattJvc.js +0 -1
  103. package/dist/assets/business-trip-DZqft86E.js +0 -1
  104. package/dist/assets/charges-table--gOKotyF.js +0 -62
  105. package/dist/assets/download-csv-button-B0eh9bzg.js +0 -1
  106. package/dist/assets/index-B05N38w4.js +0 -6
  107. package/dist/assets/index-BS5IhG6A.js +0 -1
  108. package/dist/assets/index-Ci8Rcu9T.js +0 -1
  109. package/dist/assets/issue-document-BcWeUsrG.js +0 -1
  110. package/dist/assets/sub-DLRNYZyc.js +0 -1
  111. package/dist/assets/subMonths-Bc9skHhr.js +0 -1
  112. package/dist/assets/tooltip-CICdw5IX.js +0 -1
  113. package/src/components/business/balance-section.tsx +0 -26
  114. package/src/components/business/ledger-section.tsx +0 -49
  115. package/src/providers/index.tsx +0 -56
@@ -0,0 +1,4 @@
1
+ export { AuthContext, AuthGuard, AuthProvider } from './auth-guard.jsx';
2
+ export { UrqlProvider } from './urql.jsx';
3
+ export { UserContext, UserProvider, type UserInfo } from './user-provider.jsx';
4
+ export { FiltersContext } from './filters-context.js';
@@ -37,14 +37,14 @@ const Businesses = lazy(() =>
37
37
  const BusinessScreen = lazy(() =>
38
38
  import('../components/screens/businesses/business.js').then(m => ({ default: m.BusinessScreen })),
39
39
  );
40
- const BusinessLedgerRecordsSummary = lazy(() =>
41
- import('../components/business-ledger/index.js').then(m => ({
42
- default: m.BusinessLedgerRecordsSummery,
40
+ const BusinessTransactionsSummery = lazy(() =>
41
+ import('../components/business-transactions/index.js').then(m => ({
42
+ default: m.BusinessTransactionsSummery,
43
43
  })),
44
44
  );
45
- const BusinessLedgerRecordsSingle = lazy(() =>
46
- import('../components/business-ledger/business-ledger-single.js').then(m => ({
47
- default: m.BusinessLedgerRecordsSingle,
45
+ const BusinessTransactionsSingle = lazy(() =>
46
+ import('../components/business-transactions/business-transactions-single.js').then(m => ({
47
+ default: m.BusinessTransactionsSingle,
48
48
  })),
49
49
  );
50
50
 
@@ -264,11 +264,11 @@ export const routes: RouteObject[] = [
264
264
  handle: { title: 'All Businesses' },
265
265
  },
266
266
  {
267
- path: 'ledger-records',
268
- element: withSuspense(BusinessLedgerRecordsSummary, <TableSkeleton />),
267
+ path: 'transactions',
268
+ element: withSuspense(BusinessTransactionsSummery, <TableSkeleton />),
269
269
  handle: {
270
- title: 'Business Ledger Records Summary',
271
- breadcrumb: 'Ledger',
270
+ title: 'Business Transactions Summary',
271
+ breadcrumb: 'Transactions',
272
272
  },
273
273
  },
274
274
  {
@@ -281,11 +281,11 @@ export const routes: RouteObject[] = [
281
281
  },
282
282
  },
283
283
  {
284
- path: ':businessId/ledger',
285
- element: withSuspense(BusinessLedgerRecordsSingle, <TableSkeleton />),
284
+ path: ':businessId/transactions',
285
+ element: withSuspense(BusinessTransactionsSingle, <TableSkeleton />),
286
286
  handle: {
287
- title: 'Business Ledger',
288
- breadcrumb: 'Ledger',
287
+ title: 'Business Transactions',
288
+ breadcrumb: 'Transactions',
289
289
  },
290
290
  },
291
291
  ],
@@ -22,9 +22,9 @@ export const ROUTES = {
22
22
  BUSINESSES: {
23
23
  ROOT: '/businesses',
24
24
  ALL: '/businesses',
25
- LEDGER: '/businesses/ledger',
25
+ TRANSACTIONS: '/businesses/transactions',
26
26
  DETAIL: (businessId: string) => `/businesses/${businessId}`,
27
- DETAIL_LEDGER: (businessId: string) => `/businesses/${businessId}/ledger`,
27
+ DETAIL_TRANSACTIONS: (businessId: string) => `/businesses/${businessId}/transactions`,
28
28
  },
29
29
 
30
30
  BUSINESS_TRIPS: {
@@ -1,13 +0,0 @@
1
- import{v as T,bA as G,r as D,bC as J,ab as V,bE as H,j as e,cO as K,x as v,u as Y,dS as q,aN as o,c as Q,T as W,B as X,bU as P,R as b,a$ as A,bn as Z}from"./index-BdnLryTF.js";import{D as ee}from"./download-csv-button-B0eh9bzg.js";import{T as ne}from"./Table-C2EjuqpH.js";/**
2
- * @license lucide-react v0.548.0 - ISC
3
- *
4
- * This source code is licensed under the ISC license.
5
- * See the LICENSE file in the root directory of this source tree.
6
- */const te=[["path",{d:"M12 12h.01",key:"1mp3jc"}],["path",{d:"M16 12h.01",key:"1l6xoz"}],["path",{d:"m17 7 5 5-5 5",key:"1xlxn0"}],["path",{d:"m7 7-5 5 5 5",key:"19njba"}],["path",{d:"M8 12h.01",key:"czm47f"}]],se=T("chevrons-left-right-ellipsis",te);/**
7
- * @license lucide-react v0.548.0 - ISC
8
- *
9
- * This source code is licensed under the ISC license.
10
- * See the LICENSE file in the root directory of this source tree.
11
- */const re=[["path",{d:"m20 17-5-5 5-5",key:"30x0n2"}],["path",{d:"m4 17 5-5-5-5",key:"16spf4"}]],ae=T("chevrons-right-left",re);var oe=G((n,{color:s})=>({root:{backgroundColor:n.fn.themeColor(s,n.colorScheme==="dark"?5:2),color:n.colorScheme==="dark"?n.colors.dark[9]:"inherit"}})),ce=Object.defineProperty,C=Object.getOwnPropertySymbols,M=Object.prototype.hasOwnProperty,U=Object.prototype.propertyIsEnumerable,O=(n,s,t)=>s in n?ce(n,s,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[s]=t,ie=(n,s)=>{for(var t in s||(s={}))M.call(s,t)&&O(n,t,s[t]);if(C)for(var t of C(s))U.call(s,t)&&O(n,t,s[t]);return n},le=(n,s)=>{var t={};for(var a in n)M.call(n,a)&&s.indexOf(a)<0&&(t[a]=n[a]);if(n!=null&&C)for(var a of C(n))s.indexOf(a)<0&&U.call(n,a)&&(t[a]=n[a]);return t};const de={color:"yellow"},p=D.forwardRef((n,s)=>{const t=J("Mark",de,n),{color:a,className:i,unstyled:u,variant:h}=t,x=le(t,["color","className","unstyled","variant"]),{classes:f,cx:l}=oe({color:a},{unstyled:u,name:"Mark",variant:h});return V.createElement(H,ie({component:"mark",ref:s,className:l(f.root,i)},x))});p.displayName="@mantine/core/Mark";const ue=({ledgerRecords:n,businessName:s,fromDate:t,toDate:a})=>{const i=D.useCallback(async()=>{const u=me(n);return{fileName:`business_${s}_ledger_records${t?`_${t}`:""}${a?`_${a}`:""}`,fileContent:u}},[n,s,t,a]);return e.jsx(ee,{createFileVariables:i})},me=n=>{let s="";const t=Array.from(new Set(n.filter(a=>a.foreignAmount?.currency).map(a=>a.foreignAmount.currency)));s+=`Sorting Date,Date,Amount,Amount Balance,${he(t)}Reference,Details,Counter Account\r
12
- `;for(const a of n){const i=fe(a,t);s+=i}return s};function he(n){let s="";return n.map(t=>{const a=K(t);s+=`${t}(${a}) Amount,${t}(${a}) Balance,`}),s}function xe(n,s){let t="";return s.map(a=>{n.foreignAmount&&n.foreignAmount.currency===a?t+=`${n.foreignAmount.raw},${n[`${a.toLowerCase()}Balance`]??0},`:t+=",,"}),t}function fe(n,s){let t="";const a=n.invoiceDate?v(new Date(n.invoiceDate),"yyy-MM-dd"):null,i=n.invoiceDate?v(new Date(n.invoiceDate),"dd/MM/yy"):null,u=n.amount.raw,{ilsBalance:h,reference:x,details:f}=n,l=n.counterAccount?.name??"";return t+=`${a},${i},${u},${h},${xe(n,s)}${S(x??"")},${S(f??"")},${S(l)},\r
13
- `,t}function S(n){return n===""?"":Number.isNaN(Number(n))?String(n).replace(/"/g,'""').replace(/,/g,"."):Number(n).toFixed(2).toString()}function Ae({businessID:n,filter:s}){const[t,a]=D.useState(!1),{fromDate:i,ownerIds:u,toDate:h}=s??{},[{data:x,fetching:f}]=Y({query:q,variables:{filters:{fromDate:i,ownerIds:u,toDate:h,businessIDs:[n]}}}),l=x?.businessTransactionsFromLedgerRecords.__typename==="CommonError"?[]:x?.businessTransactionsFromLedgerRecords.businessTransactions.sort((r,g)=>r.invoiceDate>g.invoiceDate?1:-1)??[],j=[];for(let r=0;r<l.length;r++){const{__typename:g,...c}=l[r],z=r===0?c.amount.raw:(j[r-1].ilsBalance??0)+c.amount.raw,I={};Object.values(o).map(y=>{if(y!==o.Ils){const L=`${y.toLowerCase()}Balance`;I[L]=r===0?(c.foreignAmount?.currency===y?c.foreignAmount?.raw:0)??0:(j[r-1]?.[L]??0)+(c.foreignAmount?.currency===y?c.foreignAmount?.raw:0)}}),j.push({...c,ilsBalance:z,...I})}const m=new Set(l.filter(r=>r.foreignAmount?.currency).map(r=>r.foreignAmount.currency)),B=t||m.has(o.Eur),E=t||m.has(o.Usd),_=t||m.has(o.Gbp),k=t||m.has(o.Cad),N=t||m.has(o.Jpy),$=t||m.has(o.Aud),F=t||m.has(o.Sek),R=l[0]?.business.name??"unknown";return e.jsx("div",{className:"flex flex-row gap-5",children:f?e.jsx(Q,{}):e.jsxs(ne,{striped:!0,highlightOnHover:!0,children:[e.jsx("thead",{style:{position:"sticky",top:0,zIndex:20},children:e.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:[e.jsx("th",{children:"Business Name"}),e.jsx("th",{children:"Date"}),e.jsx("th",{children:"Amount"}),e.jsx("th",{children:"Amount Balance"}),B&&e.jsxs(e.Fragment,{children:[e.jsx("th",{children:"EUR Amount"}),e.jsx("th",{children:"EUR Balance"})]}),E&&e.jsxs(e.Fragment,{children:[e.jsx("th",{children:"USD Amount"}),e.jsx("th",{children:"USD Balance"})]}),_&&e.jsxs(e.Fragment,{children:[e.jsx("th",{children:"GBP Amount"}),e.jsx("th",{children:"GBP Balance"})]}),k&&e.jsxs(e.Fragment,{children:[e.jsx("th",{children:"CAD Amount"}),e.jsx("th",{children:"CAD Balance"})]}),N&&e.jsxs(e.Fragment,{children:[e.jsx("th",{children:"JPY Amount"}),e.jsx("th",{children:"JPY Balance"})]}),$&&e.jsxs(e.Fragment,{children:[e.jsx("th",{children:"AUD Amount"}),e.jsx("th",{children:"AUD Balance"})]}),F&&e.jsxs(e.Fragment,{children:[e.jsx("th",{children:"SEK Amount"}),e.jsx("th",{children:"SEK Balance"})]}),e.jsx("th",{children:e.jsx(W,{label:"Expand all currencies",children:e.jsx(X,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>a(r=>!r),children:t?e.jsx(ae,{className:"size-5"}):e.jsx(se,{className:"size-5"})})})}),t&&e.jsx(e.Fragment,{children:w.map(r=>e.jsxs(e.Fragment,{children:[e.jsxs("th",{children:[r," Amount"]}),e.jsxs("th",{children:[r," Balance"]})]}))}),e.jsx("th",{children:"Reference"}),e.jsx("th",{children:"Details"}),e.jsx("th",{children:"Counter Account"}),e.jsx("th",{children:e.jsx(ue,{ledgerRecords:j,businessName:R,fromDate:s?.fromDate??void 0,toDate:s?.toDate??void 0})})]})}),e.jsx("tbody",{children:j.map((r,g)=>e.jsxs("tr",{className:"cursor-pointer",onClick:c=>{c.stopPropagation(),window.open(b.CHARGES.DETAIL(r.chargeId),"_blank","noreferrer")},children:[e.jsx("td",{children:e.jsx(P,{to:b.BUSINESSES.DETAIL(r.business.id),target:"_blank",rel:"noreferrer",onClick:c=>c.stopPropagation(),className:"inline-flex items-center font-semibold",children:r.business.name})}),e.jsx("td",{children:r.invoiceDate?v(new Date(r.invoiceDate),"dd/MM/yy"):null}),e.jsx("td",{style:{whiteSpace:"nowrap"},children:r.amount&&r.amount.raw!==0&&e.jsx(p,{color:r.amount.raw>0?"green":"red",children:r.amount.formatted})}),e.jsx("td",{children:r.ilsBalance===0?A(r.ilsBalance,o.Ils):e.jsx(p,{color:r.ilsBalance>0?"green":"red",children:A(r.ilsBalance,o.Ils)})}),B&&e.jsx(d,{data:r,currency:o.Eur}),E&&e.jsx(d,{data:r,currency:o.Usd}),_&&e.jsx(d,{data:r,currency:o.Gbp}),k&&e.jsx(d,{data:r,currency:o.Cad}),N&&e.jsx(d,{data:r,currency:o.Jpy}),$&&e.jsx(d,{data:r,currency:o.Aud}),F&&e.jsx(d,{data:r,currency:o.Sek}),e.jsx("td",{}),t&&e.jsx(je,{data:r}),e.jsx("td",{children:r.reference}),e.jsx("td",{children:r.details}),e.jsx("td",{children:r.counterAccount&&e.jsx(P,{to:b.BUSINESSES.DETAIL(r.counterAccount.id),target:"_blank",rel:"noreferrer",onClick:c=>c.stopPropagation(),className:"inline-flex items-center font-semibold",children:r.counterAccount.name})}),e.jsx("td",{})]},g))})]})})}function d({currency:n,data:s}){const t=s.foreignAmount&&s.foreignAmount.currency===n?s.foreignAmount:null,a=`${n.toLowerCase()}Balance`;return e.jsxs(e.Fragment,{children:[e.jsx("td",{style:{whiteSpace:"nowrap"},children:!!t&&t.raw!==0&&e.jsx(p,{color:t.raw>0?"green":"red",children:t.formatted})}),e.jsx("td",{children:(s[a]??0)!==0&&(s[a]===0?A(s[a],n):e.jsx(p,{color:s[a]>0?"green":"red",children:A(s[a],n)}))})]})}const w=Object.values(o).filter(n=>!Z.includes(n));function je({data:n}){return e.jsx(e.Fragment,{children:w.map(s=>e.jsx(d,{currency:s,data:n},s))})}export{Ae as B,ae as C,p as M,se as a};
@@ -1 +0,0 @@
1
- import{r as x,bo as v,j as e,bp as C,B as S,G as I,bq as F,a8 as B,br as m,bs as y,bt as j,x as f,bu as E,bv as N}from"./index-BdnLryTF.js";import{u as w}from"./use-url-query-Bp_LkJaa.js";import{P as L}from"./modal-BzwJJ2TM.js";import{F as R}from"./funnel-XiON1wPY.js";import{M as D}from"./MultiSelect-CGvaXcuH.js";function A({filter:r,setFilter:b,closeModal:u,single:l=!1}){const{control:n,handleSubmit:p}=I({defaultValues:{...r}}),{selectableBusinesses:d,fetching:i}=F(),{userContext:g}=x.useContext(B),h=s=>{b(s),u()};function o(){b({businessIDs:l?r.businessIDs:void 0}),u()}return e.jsxs(e.Fragment,{children:[i?e.jsx("div",{children:"Loading..."}):e.jsx("div",{}),e.jsxs("form",{onSubmit:p(h),children:[e.jsx(m,{name:"ownerIds",control:n,defaultValue:r.ownerIds,render:({field:s,fieldState:a})=>e.jsx(D,{...s,data:d,value:s.value??(g?.context.adminBusinessId?[g.context.adminBusinessId]:void 0),disabled:i,label:"Owners",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:a.error?.message})}),!l&&e.jsx(m,{name:"businessIDs",control:n,defaultValue:r.businessIDs,render:({field:s,fieldState:a})=>e.jsx(D,{...s,data:d,value:s.value??void 0,disabled:i,label:"Businesses",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:a.error?.message})}),e.jsx(m,{name:"fromDate",control:n,defaultValue:r.fromDate,rules:{pattern:{value:y,message:"Date must be im format yyyy-mm-dd"}},render:({field:s,fieldState:a})=>e.jsx(j,{...s,onChange:t=>{const c=t?typeof t=="string"?t:f(t,"yyyy-MM-dd"):void 0;c!==s.value&&s.onChange(c)},value:s.value?new Date(s.value):void 0,error:a.error?.message,label:"From Date",popoverProps:{withinPortal:!0}})}),e.jsx(m,{name:"toDate",control:n,defaultValue:r.toDate,rules:{pattern:{value:y,message:"Date must be im format yyyy-mm-dd"}},render:({field:s,fieldState:a})=>e.jsx(j,{...s,onChange:t=>{const c=t?typeof t=="string"?t:f(t,"yyyy-MM-dd"):void 0;c!==s.value&&s.onChange(c)},value:s.value?new Date(s.value):void 0,error:a.error?.message,label:"To Date",popoverProps:{withinPortal:!0}})}),e.jsx(m,{name:"type",control:n,defaultValue:null,render:({field:s,fieldState:a})=>e.jsx(E,{...s,onChange:t=>s.onChange(t==="NULL"?null:t),data:[{value:"NULL",label:"All"},{value:"BUSINESS",label:"Business"},{value:"TAX_CATEGORY",label:"Tax Category"}],error:a.error?.message,label:"Type"})}),e.jsxs("div",{className:"flex justify-center mt-5 gap-3",children:[e.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:"Filter"}),e.jsx("button",{type:"button",className:"text-white bg-orange-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-orange-600 rounded-sm text-lg",onClick:o,children:"Clear"}),e.jsx("button",{type:"button",className:"text-white bg-rose-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-rose-600 rounded-sm text-lg",onClick:u,children:"Cancel"})]})]})]})}function V({filter:r,setFilter:b}){const[u,l]=x.useState(!1),[n,p]=x.useState(!v(r)),{get:d,set:i}=w();function g(o){return Object.entries(o??{}).filter(([a,t])=>t!==void 0&&Array.isArray(t)&&t.length>0).length>0}function h(o){o.fromDate?.trim()===""&&(o.fromDate=void 0),o.toDate?.trim()===""&&(o.toDate=void 0),N(o,r)||(b(o),p(g(o)))}return x.useEffect(()=>{const o=v(r)?null:encodeURIComponent(JSON.stringify(r)),s=d("ledgerRecordsFilters");o!==s&&i("ledgerRecordsFilters",o)},[r,d,i]),e.jsxs(e.Fragment,{children:[e.jsx(L,{opened:u,onClose:()=>l(!1),content:e.jsx(A,{single:!0,filter:r,setFilter:h,closeModal:()=>l(!1)})}),e.jsx(C,{inline:!0,size:16,disabled:!n,children:e.jsx(S,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>l(!0),children:e.jsx(R,{className:"size-5"})})})]})}export{V as B};
@@ -1 +0,0 @@
1
- import{a as S,r as c,F as w,u as C,j as n,c as x,aN as o,bm as y}from"./index-BdnLryTF.js";import{u as h}from"./use-url-query-Bp_LkJaa.js";import{a as F}from"./accounter-table-C70NKDaW.js";import{M as p,B as R}from"./business-extended-info-vAiMQKwm.js";import{B as v}from"./business-ledger-filters-CNjRVS0K.js";import"./Pagination-D4fkmYTl.js";import"./create-event-handler-BiA-1lGu.js";import"./Table-C2EjuqpH.js";import"./download-csv-button-B0eh9bzg.js";import"./modal-BzwJJ2TM.js";import"./funnel-XiON1wPY.js";import"./MultiSelect-CGvaXcuH.js";const $=({businessId:t})=>{const{businessId:r}=S(),{get:s}=h(),{setFiltersContext:u}=c.useContext(w),l=t||r,[m,d]=c.useState(s("ledgerRecordsFilters")?{...JSON.parse(decodeURIComponent(s("ledgerRecordsFilters"))),businessIDs:l?[l]:[]}:{businessIDs:l?[l]:[]}),[{data:a,fetching:f}]=C({query:y,variables:{filters:m}});c.useEffect(()=>{u(n.jsx(v,{filter:m,setFilter:d}))},[a,m,u,d]);const b=c.useMemo(()=>a?.businessTransactionsSumFromLedgerRecords.__typename==="CommonError"?[]:a?.businessTransactionsSumFromLedgerRecords.businessTransactionsSum?a.businessTransactionsSumFromLedgerRecords.businessTransactionsSum.sort((e,g)=>e.business.name.localeCompare(g.business.name)):[],[a?.businessTransactionsSumFromLedgerRecords]);return f?n.jsx(x,{}):n.jsx(F,{moreInfo:e=>n.jsx(R,{businessID:e.business.id,filter:m}),striped:!0,highlightOnHover:!0,stickyHeader:!0,items:b,columns:[{title:"Business Name",value:e=>e.business.name},{title:"Debit",value:e=>e.debit.formatted,style:{whiteSpace:"nowrap"}},{title:"Credit",value:e=>e.credit.formatted,style:{whiteSpace:"nowrap"}},{title:"Total",value:e=>e.total.raw&&(e.total.raw<-1e-4||e.total.raw>1e-4)?n.jsx(p,{color:e.total.raw>0?"green":"red",children:e.total.formatted}):e.total.formatted,style:{whiteSpace:"nowrap"}},...i(o.Eur),...i(o.Usd),...i(o.Gbp),...i(o.Cad),...i(o.Jpy),...i(o.Aud),...i(o.Sek)]})};function i(t){return[{title:`${t} Debit`,value:r=>r.foreignCurrenciesSum.find(s=>s.currency===t)?.debit?.formatted,style:{whiteSpace:"nowrap"}},{title:`${t} Credit`,value:r=>r.foreignCurrenciesSum.find(s=>s.currency===t)?.credit?.formatted,style:{whiteSpace:"nowrap"}},{title:`${t} Total`,value:r=>{const s=r.foreignCurrenciesSum.find(u=>u.currency===t);return s?.total?.raw&&(s.total.raw<-1e-4||s.total.raw>1e-4)?n.jsx(p,{color:s.total.raw>0?"green":"red",children:s.total.formatted}):s?.total?.formatted},style:{whiteSpace:"nowrap"}}]}export{$ as BusinessLedgerRecordsSingle};
@@ -1 +0,0 @@
1
- import{a as p,r as n,F as u,u as m,j as s,c,bz as x}from"./index-BdnLryTF.js";import{P as d,C as l,E as b}from"./editable-business-trip-BLWzKbN3.js";import{P as f}from"./page-layout-NF77oib6.js";import"./list-plus-DINtfnSi.js";import"./summary-BasZ3QlN.js";import"./create-event-handler-BiA-1lGu.js";import"./Table-C2EjuqpH.js";import"./toggle-expansion-button-DPcDIe-2.js";import"./panel-top-open-BApXXBMD.js";import"./MultiSelect-CGvaXcuH.js";import"./similar-transactions-modal-CoZU6FU3.js";import"./tooltip-CICdw5IX.js";const L=({businessTripId:o})=>{const{businessTripId:a}=p(),{setFiltersContext:i}=n.useContext(u),e=o??a??"",[{data:r,fetching:t}]=m({query:x,variables:{businessTripId:e}});return n.useEffect(()=>{i(s.jsx("div",{className:"flex flex-row gap-x-5",children:s.jsx(d,{filename:"business_trip_report"})}))},[r,t,i]),t||!r?.businessTrip?s.jsx(c,{}):s.jsx(f,{title:`Business Trip: ${r.businessTrip.name}`,description:"Manage business trip",children:s.jsx(l,{className:"mt-5",children:e&&s.jsx(b,{tripId:e,isExtended:!0})})})};export{L as BusinessTrip};
@@ -1,62 +0,0 @@
1
- import{v as Oe,j as r,eq as vo,er as jo,es as bo,aC as Co,bA as Ve,bD as $,bB as we,et as Do,r as g,bC as Ue,ab as N,bE as He,eu as Br,ev as So,ew as wo,ek as _o,ex as Io,el as Wt,bl as Qe,ey as Vr,ez as Eo,d as jt,bN as Ur,J as L,eA as Oo,g as Pe,eB as Po,t as F,i as Ae,eC as Ao,bS as Gt,T as Le,B as Y,m as Hr,eD as No,eE as To,G as xn,V as $o,eF as Fo,eG as ko,eH as nt,eI as rt,eJ as Mn,eK as zn,dx as Ro,eL as Kr,eM as Mo,l as gt,eN as zo,eO as Lo,D as yn,aO as Bo,bW as Gr,z as vn,eP as Vo,eQ as Uo,cS as qr,d5 as Wr,d7 as Yr,aP as Ho,aQ as Ko,K as Qr,cV as jn,cW as bn,cX as Ye,cY as Te,cZ as Pt,c_ as Cn,c$ as Ie,p as Ln,x as Be,u as Xe,eR as Go,E as qo,c as Wo,eS as Yo,dV as Qo,eT as Jo,bp as Re,eU as Xo,bU as At,R as mt,eV as Jr,eW as Xr,eX as ze,eY as Zo,eZ as Zr,e_ as ea,e$ as ta,f0 as es,f1 as an,f2 as ts,f3 as na,f4 as ra,aN as Dn,f5 as sa,au as ns,f6 as rs,n as ft,br as $e,bs as ss,bt as os,bM as as,bu as Nt,f7 as oa,f8 as aa,bT as Sn,e as ia,f9 as ca,a5 as la,fa as da,L as is,fb as ua,fc as fa,cT as pa,fd as cn,fe as cs,ff as ls,fg as ga,fh as Yt,fi as Bn,fj as ds,cU as ma,fk as ha,dp as De,dq as Se,av as us,fl as Vn,e8 as xa,d6 as ya,dW as fs,fm as ps,fn as gs,fo as va,cO as tt,fp as ms,fq as ja,fr as hs,W as ba,P as Ca,fs as xs,ft as Da,fu as ys,fv as vs,fw as _e,fx as je,fy as Un,fz as js,fA as Sa,fB as wa,fC as qe,fD as _a,fE as Ia,fF as Ea}from"./index-BdnLryTF.js";import{T as Oa}from"./toggle-expansion-button-DPcDIe-2.js";import{M as Pa,P as W,I as Aa,T as bs,a as Na,D as Ta,A as $a,b as Fa,c as ka,S as Ra,C as Ma,d as za}from"./index-B05N38w4.js";import{T as Cs}from"./Table-C2EjuqpH.js";import{R as La,S as Ba,M as oe,B as Va,L as Hn,G as Qt,C as Kn,A as U,a as Ua}from"./summary-BasZ3QlN.js";import{L as Jt}from"./list-plus-DINtfnSi.js";/**
2
- * @license lucide-react v0.548.0 - ISC
3
- *
4
- * This source code is licensed under the ISC license.
5
- * See the LICENSE file in the root directory of this source tree.
6
- */const Ha=[["path",{d:"m3 16 4 4 4-4",key:"1co6wj"}],["path",{d:"M7 20V4",key:"1yoxec"}],["path",{d:"M11 4h10",key:"1w87gc"}],["path",{d:"M11 8h7",key:"djye34"}],["path",{d:"M11 12h4",key:"q8tih4"}]],Ka=Oe("arrow-down-wide-narrow",Ha);/**
7
- * @license lucide-react v0.548.0 - ISC
8
- *
9
- * This source code is licensed under the ISC license.
10
- * See the LICENSE file in the root directory of this source tree.
11
- */const Ga=[["path",{d:"m16 3 4 4-4 4",key:"1x1c3m"}],["path",{d:"M20 7H4",key:"zbl0bi"}],["path",{d:"m8 21-4-4 4-4",key:"h9nckh"}],["path",{d:"M4 17h16",key:"g4d7ey"}]],qa=Oe("arrow-right-left",Ga);/**
12
- * @license lucide-react v0.548.0 - ISC
13
- *
14
- * This source code is licensed under the ISC license.
15
- * See the LICENSE file in the root directory of this source tree.
16
- */const Wa=[["circle",{cx:"8",cy:"8",r:"6",key:"3yglwk"}],["path",{d:"M18.09 10.37A6 6 0 1 1 10.34 18",key:"t5s6rm"}],["path",{d:"M7 6h1v4",key:"1obek4"}],["path",{d:"m16.71 13.88.7.71-2.82 2.82",key:"1rbuyh"}]],Ds=Oe("coins",Wa);/**
17
- * @license lucide-react v0.548.0 - ISC
18
- *
19
- * This source code is licensed under the ISC license.
20
- * See the LICENSE file in the root directory of this source tree.
21
- */const Ya=[["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"}]],Qa=Oe("combine",Ya);/**
22
- * @license lucide-react v0.548.0 - ISC
23
- *
24
- * This source code is licensed under the ISC license.
25
- * See the LICENSE file in the root directory of this source tree.
26
- */const Ja=[["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",Ja);/**
27
- * @license lucide-react v0.548.0 - ISC
28
- *
29
- * This source code is licensed under the ISC license.
30
- * See the LICENSE file in the root directory of this source tree.
31
- */const Xa=[["rect",{x:"3",y:"8",width:"18",height:"4",rx:"1",key:"bkv52"}],["path",{d:"M12 8v13",key:"1c76mn"}],["path",{d:"M19 12v7a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2v-7",key:"6wjy6b"}],["path",{d:"M7.5 8a2.5 2.5 0 0 1 0-5A4.8 8 0 0 1 12 8a4.8 8 0 0 1 4.5-5 2.5 2.5 0 0 1 0 5",key:"1ihvrl"}]],Za=Oe("gift",Xa);/**
32
- * @license lucide-react v0.548.0 - ISC
33
- *
34
- * This source code is licensed under the ISC license.
35
- * See the LICENSE file in the root directory of this source tree.
36
- */const ei=[["path",{d:"M11 17h3v2a1 1 0 0 0 1 1h2a1 1 0 0 0 1-1v-3a3.16 3.16 0 0 0 2-2h1a1 1 0 0 0 1-1v-2a1 1 0 0 0-1-1h-1a5 5 0 0 0-2-4V3a4 4 0 0 0-3.2 1.6l-.3.4H11a6 6 0 0 0-6 6v1a5 5 0 0 0 2 4v3a1 1 0 0 0 1 1h2a1 1 0 0 0 1-1z",key:"1piglc"}],["path",{d:"M16 10h.01",key:"1m94wz"}],["path",{d:"M2 8v1a2 2 0 0 0 2 2h1",key:"1env43"}]],ti=Oe("piggy-bank",ei);/**
37
- * @license lucide-react v0.548.0 - ISC
38
- *
39
- * This source code is licensed under the ISC license.
40
- * See the LICENSE file in the root directory of this source tree.
41
- */const ni=[["path",{d:"M17.8 19.2 16 11l3.5-3.5C21 6 21.5 4 21 3c-1-.5-3 0-4.5 1.5L13 8 4.8 6.2c-.5-.1-.9.1-1.1.5l-.3.5c-.2.5-.1 1 .3 1.3L9 12l-2 3H4l-1 1 3 2 2 3 1-1v-3l3-2 3.5 5.3c.3.4.8.5 1.3.3l.5-.2c.4-.3.6-.7.5-1.2z",key:"1v9wt8"}]],ri=Oe("plane",ni);/**
42
- * @license lucide-react v0.548.0 - ISC
43
- *
44
- * This source code is licensed under the ISC license.
45
- * See the LICENSE file in the root directory of this source tree.
46
- */const si=[["path",{d:"M21 12a9 9 0 0 0-9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"14sxne"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M3 12a9 9 0 0 0 9 9 9.75 9.75 0 0 0 6.74-2.74L21 16",key:"1hlbsb"}],["path",{d:"M16 16h5v5",key:"ccwih5"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}]],oi=Oe("refresh-ccw-dot",si);/**
47
- * @license lucide-react v0.548.0 - ISC
48
- *
49
- * This source code is licensed under the ISC license.
50
- * See the LICENSE file in the root directory of this source tree.
51
- */const ai=[["path",{d:"M14.828 14.828 21 21",key:"ar5fw7"}],["path",{d:"M21 16v5h-5",key:"1ck2sf"}],["path",{d:"m21 3-9 9-4-4-6 6",key:"1h02xo"}],["path",{d:"M21 8V3h-5",key:"1qoq8a"}]],ii=Oe("trending-up-down",ai);/**
52
- * @license lucide-react v0.548.0 - ISC
53
- *
54
- * This source code is licensed under the ISC license.
55
- * See the LICENSE file in the root directory of this source tree.
56
- */const ci=[["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"}]],li=Oe("wallet",ci),di={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=>di[e]??"Unknown",ui={CommonCharge:r.jsx(Ds,{}),BusinessTripCharge:r.jsx(ri,{}),DividendCharge:r.jsx(Za,{}),ConversionCharge:r.jsx(Co,{}),SalaryCharge:r.jsx(li,{}),InternalTransferCharge:r.jsx(qa,{}),MonthlyVatCharge:r.jsx(bo,{}),BankDepositCharge:r.jsx(ti,{}),ForeignSecuritiesCharge:r.jsx(ii,{}),CreditcardBankCharge:r.jsx(jo,{}),FinancialCharge:r.jsx(vo,{})},fi=e=>ui[e]??r.jsx(Ds,{});function qn(e){return typeof e!="string"?"":e.charAt(0).toUpperCase()+e.slice(1)}var pi=Object.defineProperty,gi=Object.defineProperties,mi=Object.getOwnPropertyDescriptors,Wn=Object.getOwnPropertySymbols,hi=Object.prototype.hasOwnProperty,xi=Object.prototype.propertyIsEnumerable,Yn=(e,t,n)=>t in e?pi(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Xt=(e,t)=>{for(var n in t||(t={}))hi.call(t,n)&&Yn(e,n,t[n]);if(Wn)for(var n of Wn(t))xi.call(t,n)&&Yn(e,n,t[n]);return e},yi=(e,t)=>gi(e,mi(t));const vi=["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)}},ji={xs:$(4),sm:$(4),md:$(6),lg:$(8),xl:$(10)};function bi({theme:e,variant:t,color:n,size:s,gradient:o}){if(!vi.includes(t))return null;if(t==="dot"){const i=we({size:s,sizes:ji});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 Ci=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(yi(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"}),bi({theme:e,variant:a,color:t,size:i,gradient:s}))}}),Di=Object.defineProperty,Tt=Object.getOwnPropertySymbols,ws=Object.prototype.hasOwnProperty,_s=Object.prototype.propertyIsEnumerable,Qn=(e,t,n)=>t in e?Di(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Si=(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},wi=(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 _i={variant:"light",size:"md",radius:"xl"},Is=g.forwardRef((e,t)=>{const n=Ue("Badge",_i,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=wi(n,["className","color","variant","fullWidth","children","size","leftSection","rightSection","radius","gradient","classNames","styles","unstyled"]),{classes:h,cx:j}=Ci({fullWidth:i,color:o,radius:f,gradient:m},{classNames:y,styles:p,name:"Badge",unstyled:u,variant:a,size:c});return N.createElement(He,Si({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 Ii=Object.defineProperty,$t=Object.getOwnPropertySymbols,Es=Object.prototype.hasOwnProperty,Os=Object.prototype.propertyIsEnumerable,Jn=(e,t,n)=>t in e?Ii(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},Ei=(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 Oi={multiple:!1},Ps=g.forwardRef((e,t)=>{const n=Ue("FileButton",Oi,e),{onChange:s,children:o,multiple:a,accept:i,name:l,form:c,resetRef:d,disabled:x,capture:f,inputProps:m}=n,y=Ei(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 Pi=Ve(()=>({placeholder:{},input:{cursor:"pointer"}})),Ai=Object.defineProperty,Ni=Object.defineProperties,Ti=Object.getOwnPropertyDescriptors,Ft=Object.getOwnPropertySymbols,As=Object.prototype.hasOwnProperty,Ns=Object.prototype.propertyIsEnumerable,Zn=(e,t,n)=>t in e?Ai(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)=>Ni(e,Ti(t)),$i=(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 Fi=({value:e})=>N.createElement(Qe,{sx:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}},Array.isArray(e)?e.map(t=>t.name).join(", "):e?.name),ki={size:"sm",valueComponent:Fi},Ts=g.forwardRef((e,t)=>{const n=wo("FileInput",ki,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=$i(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}=Pi(null,{name:"FileInput",classNames:y,styles:p,unstyled:u}),[T,G]=_o({value:i,defaultValue:l,onChange:c,finalValue:d?[]:null}),Q=Array.isArray(T)?T.length!==0:T!==null,R=h||(j&&Q&&!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)})}),Q?N.createElement(v,{value:T}):N.createElement(Wt.Placeholder,{className:A.placeholder},a))))});Ts.displayName="@mantine/core/FileInput";const Ri=Ts;var Mi=Object.defineProperty,zi=Object.defineProperties,Li=Object.getOwnPropertyDescriptors,er=Object.getOwnPropertySymbols,Bi=Object.prototype.hasOwnProperty,Vi=Object.prototype.propertyIsEnumerable,tr=(e,t,n)=>t in e?Mi(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Ui=(e,t)=>{for(var n in t||(t={}))Bi.call(t,n)&&tr(e,n,t[n]);if(er)for(var n of er(t))Vi.call(t,n)&&tr(e,n,t[n]);return e},Hi=(e,t)=>zi(e,Li(t)),Ki=Ve(e=>({root:Hi(Ui({},e.fn.cover()),{display:"flex",alignItems:"center",justifyContent:"center",overflow:"hidden"})})),Gi=Object.defineProperty,qi=Object.defineProperties,Wi=Object.getOwnPropertyDescriptors,kt=Object.getOwnPropertySymbols,$s=Object.prototype.hasOwnProperty,Fs=Object.prototype.propertyIsEnumerable,nr=(e,t,n)=>t in e?Gi(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},Yi=(e,t)=>qi(e,Wi(t)),Qi=(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 Ji={overlayOpacity:.75,transitionDuration:0,radius:0,zIndex:Vr("overlay")},ks=g.forwardRef((e,t)=>{const n=Ue("LoadingOverlay",Ji,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=Qi(n,["className","visible","loaderProps","overlayOpacity","overlayColor","transitionDuration","exitTransitionDuration","zIndex","style","loader","radius","overlayBlur","unstyled","variant","keepMounted"]),{classes:C,cx:I,theme:O}=Ki(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:Yi(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 Xi=Object.defineProperty,Zi=Object.defineProperties,ec=Object.getOwnPropertyDescriptors,rr=Object.getOwnPropertySymbols,tc=Object.prototype.hasOwnProperty,nc=Object.prototype.propertyIsEnumerable,sr=(e,t,n)=>t in e?Xi(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,or=(e,t)=>{for(var n in t||(t={}))tc.call(t,n)&&sr(e,n,t[n]);if(rr)for(var n of rr(t))nc.call(t,n)&&sr(e,n,t[n]);return e},rc=(e,t)=>Zi(e,ec(t));const sc={xs:$(16),sm:$(20),md:$(26),lg:$(32),xl:$(40)},oc=["filled","light","gradient","outline","default"];function ac({theme:e,variant:t,color:n,gradient:s}){if(!oc.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 ic=Ve((e,{color:t,radius:n,gradient:s},{variant:o,size:a})=>{const i=we({size:a,sizes:sc});return{root:or(rc(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)}),ac({theme:e,variant:o,gradient:s,color:t}))}}),cc=Object.defineProperty,Rt=Object.getOwnPropertySymbols,Rs=Object.prototype.hasOwnProperty,Ms=Object.prototype.propertyIsEnumerable,ar=(e,t,n)=>t in e?cc(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,lc=(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},dc=(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 uc={size:"md",variant:"filled"},zs=g.forwardRef((e,t)=>{const n=Ue("ThemeIcon",uc,e),{className:s,size:o,radius:a,variant:i,color:l,children:c,gradient:d,unstyled:x}=n,f=dc(n,["className","size","radius","variant","color","children","gradient","unstyled"]),{classes:m,cx:y}=ic({variant:i,radius:a,color:l,gradient:d},{name:"ThemeIcon",unstyled:x,variant:i,size:o});return N.createElement(He,lc({className:y(m.root,s),ref:t},f),c)});zs.displayName="@mantine/core/ThemeIcon";const fc=({data:e})=>{const t=L(Oo,e);return r.jsxs(r.Fragment,{children:[r.jsx(La,{data:t,onChange:()=>{}}),r.jsx(Ba,{data:t})]})},pc="deleteCharge",gc=()=>{const[{fetching:e},t]=Pe(Po),n=g.useCallback(async s=>{const o=`Error deleting charge ID [${s.chargeId}]`,a=`${pc}-${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}},mc="regenerateLedgerRecords",hc=()=>{const[{fetching:e},t]=Pe(Ao),n=g.useCallback(async s=>{const o="Error regenerating ledger",a=`${mc}-${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 xc({chargeId:e,onChange:t,...n}){const{regenerateLedgerRecords:s}=hc();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(Y,{variant:"outline",size:"icon",...n,className:Hr("size-7.5",n.className),children:r.jsx(oi,{className:"size-5"})})})})}function yc(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(Y,{onClick:a=>{a.stopPropagation(),n()},variant:s,className:Hr("size-7.5",t?"bg-blue-500 hover:bg-blue-500/90":""),children:r.jsx(Qa,{className:"size-5"})})})}const vc="updateCharge",Ls=()=>{const[{fetching:e},t]=Pe(No),n=g.useCallback(async s=>{const o=`Error updating charge ID [${s.chargeId}]`,a=`${vc}-${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}},jc="updateMiscExpense",bc=()=>{const[{fetching:e},t]=Pe(To),n=g.useCallback(async s=>{const o=`Error updating misc expense ID [${s.id}]`,a=`${jc}-${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}},Cc=({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}=bc(),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(Pa,{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"})})]})})})},Dc="insertSalaryRecordsFromFile",Sc=()=>{const[{fetching:e},t]=Pe(ko),n=g.useCallback(async s=>{const o=`Error uploading payroll file to charge ID [${s.chargeId}]`,a=`${Dc}-${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}},wc=({chargeId:e,onDone:t})=>{const{fetching:n,uploadPayrollFile:s}=Sc(),[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(Ri,{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 _c=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=Ic(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 Ic(e){var t=e.name,n=t&&t.lastIndexOf(".")!==-1;if(n&&!e.type){var s=t.split(".").pop().toLowerCase(),o=_c.get(s);o&&Object.defineProperty(e,"type",{value:o,writable:!1,configurable:!1,enumerable:!0})}return e}var Ec=[".DS_Store","Thumbs.db"];function Oc(e){return nt(this,void 0,void 0,function(){return rt(this,function(t){return Mt(e)&&Pc(e.dataTransfer)?[2,$c(e.dataTransfer,e.type)]:Ac(e)?[2,Nc(e)]:Array.isArray(e)&&e.every(function(n){return"getFile"in n&&typeof n.getFile=="function"})?[2,Tc(e)]:[2,[]]})})}function Pc(e){return Mt(e)}function Ac(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 Tc(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 $c(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(Fc))]):[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 Ec.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 Fc(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 kc(e){return nt(this,void 0,void 0,function(){return rt(this,function(t){return[2,e.isDirectory?Vs(e):Rc(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(kc)),o.push(x),a(),f.label=6;case 6:return[2]}})})},function(l){s(l)})}a()})}function Rc(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 Mc(){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 zc=Mc();const Lc=Ro(zc);function dr(e){return Uc(e)||Vc(e)||Hs(e)||Bc()}function Bc(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
57
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Vc(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function Uc(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 Gc(e)||Kc(e,t)||Hs(e,t)||Hc()}function Hc(){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 Kc(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 Gc(e){if(Array.isArray(e))return e}var qc="file-invalid-type",Wc="file-too-large",Yc="file-too-small",Qc="too-many-files",Jc=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:qc,message:"File type must be ".concat(n)}},pr=function(t){return{code:Wc,message:"File is larger than ".concat(t," ").concat(t===1?"byte":"bytes")}},gr=function(t){return{code:Yc,message:"File is smaller than ".concat(t," ").concat(t===1?"byte":"bytes")}},Xc={code:Qc,message:"Too many files"};function Ks(e,t){var n=e.type==="application/x-moz-file"||Lc(e,t);return[n,n?null:Jc(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 Zc(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 el(e){return e.indexOf("MSIE")!==-1||e.indexOf("Trident/")!==-1}function tl(e){return e.indexOf("Edge/")!==-1}function nl(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:window.navigator.userAgent;return el(e)||tl(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 rl(){return"showOpenFilePicker"in window}function sl(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 ol(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 al(e){return e instanceof DOMException&&(e.name==="AbortError"||e.code===e.ABORT_ERR)}function il(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 cl=["children"],ll=["open"],dl=["refKey","role","onKeyDown","onFocus","onBlur","onClick","onDragEnter","onDragOver","onDragLeave","onDrop"],ul=["refKey","onChange","onClick"];function fl(e){return ml(e)||gl(e)||Ys(e)||pl()}function pl(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
59
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function gl(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function ml(e){if(Array.isArray(e))return fn(e)}function en(e,t){return yl(e)||xl(e,t)||Ys(e,t)||hl()}function hl(){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 xl(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 yl(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=vl(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 vl(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,cl),o=Js(s),a=o.open,i=Lt(o,ll);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:Oc,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 ol(n)},[n]),T=g.useMemo(function(){return sl(n)},[n]),G=g.useMemo(function(){return typeof v=="function"?v:xr},[v]),Q=g.useMemo(function(){return typeof u=="function"?u:xr},[u]),R=g.useRef(null),z=g.useRef(null),le=g.useReducer(jl,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&&rl()),be=function(){!ue.current&&de&&setTimeout(function(){if(z.current){var E=z.current.files;E.length||(B({type:"closeDialog"}),Q())}},300)};g.useEffect(function(){return window.addEventListener("focus",be,!1),function(){window.removeEventListener("focus",be,!1)}},[z,de,Q,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(fl(K.current),[D.target]),It(D)&&Promise.resolve(o(D)).then(function(E){if(!(zt(D)&&!b)){var Z=E.length,se=Z>0&&Zc({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:[Xc]})}),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){al(E)?(Q(E),B({type:"closeDialog"})):il(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,Q,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||(nl()?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,dl);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,ul),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 jl(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[bl,Cl]=Kr("Dropzone component was not found in tree");var yr=Object.getOwnPropertySymbols,Dl=Object.prototype.hasOwnProperty,Sl=Object.prototype.propertyIsEnumerable,wl=(e,t)=>{var n={};for(var s in e)Dl.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&&Sl.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=wl(s,["children"]),i=Cl(),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 _l=_n("accept"),Il=_n("reject"),El=_n("idle");var Ol=Object.defineProperty,Pl=Object.defineProperties,Al=Object.getOwnPropertyDescriptors,vr=Object.getOwnPropertySymbols,Nl=Object.prototype.hasOwnProperty,Tl=Object.prototype.propertyIsEnumerable,jr=(e,t,n)=>t in e?Ol(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))Tl.call(t,n)&&jr(e,n,t[n]);return e},$l=(e,t)=>Pl(e,Al(t)),Fl=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:$l(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"}}}),kl=Object.defineProperty,Rl=Object.defineProperties,Ml=Object.getOwnPropertyDescriptors,Bt=Object.getOwnPropertySymbols,Xs=Object.prototype.hasOwnProperty,Zs=Object.prototype.propertyIsEnumerable,Cr=(e,t,n)=>t in e?kl(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)=>Rl(e,Ml(t)),zl=(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 Ll={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",Ll,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:Q,preventDropOnDocument:R,useFsAccessApi:z,getFilesFromEvent:le,validator:ie,variant:M}=t,B=zl(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}=Fl({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:Q,preventDropOnDocument:R,useFsAccessApi:z,validator:ie},le?{getFilesFromEvent:le}:null));Br(v,ae);const ee=!K&&!xe;return N.createElement(bl,{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=_l;st.Reject=Il;st.Idle=El;const eo=st;var Bl=Object.defineProperty,Vl=Object.defineProperties,Ul=Object.getOwnPropertyDescriptors,Dr=Object.getOwnPropertySymbols,Hl=Object.prototype.hasOwnProperty,Kl=Object.prototype.propertyIsEnumerable,Sr=(e,t,n)=>t in e?Bl(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Gl=(e,t)=>{for(var n in t||(t={}))Hl.call(t,n)&&Sr(e,n,t[n]);if(Dr)for(var n of Dr(t))Kl.call(t,n)&&Sr(e,n,t[n]);return e},ql=(e,t)=>Vl(e,Ul(t)),Wl=Ve(e=>({wrapper:ql(Gl({},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}})),Yl=Object.defineProperty,Ql=Object.defineProperties,Jl=Object.getOwnPropertyDescriptors,Vt=Object.getOwnPropertySymbols,to=Object.prototype.hasOwnProperty,no=Object.prototype.propertyIsEnumerable,wr=(e,t,n)=>t in e?Yl(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)=>Ql(e,Jl(t)),Xl=(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 Zl={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",Zl,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=Xl(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}=Wl(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 ed=eo,td=({children:e,chargeId:t})=>{const{uploading:n,uploadMultipleDocuments:s}=Lo();function o(a){F.error("Error",{description:a,duration:5e3})}return r.jsx(ed,{onDrop:a=>s({documents:a,chargeId:t,isSensitive:!1}),onReject:a=>o(`Rejected Files:
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)})})},nd=({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(Y,{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(Cc,{onDone:o,data:t})})]})},rd="batchUpdateCharges",sd=()=>{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=`${rd}-${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}},od=[{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 ad({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:od,onSortingChange:i,getCoreRowModel:Yr(),getSortedRowModel:Wr(),onRowSelectionChange:c,state:{sorting:a,rowSelection:l}}),{batchUpdateCharges:m}=sd(),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(Y,{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(ad,{data:l?.similarCharges??[],tagIds:t,description:n,onOpenChange:x}):null})})})}const id="updateChargeAccountantApproval",cd=()=>{const[{fetching:e},t]=Pe(Yo),n=g.useCallback(async s=>{const o=`Error toggling accountant approval to ledger record ID [${s.chargeId}]`,a=`${id}-${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 ld({data:e,onChange:t}){const n=L(Jo,e),[s,o]=g.useState(n.accountantApproval),{updateChargeAccountantApproval:a}=cd();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 dd=({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})})})})},ud=({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",{})},fd=({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]})})})},pd=({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")})})},gd=({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})]})},md=({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(td,{chargeId:o,children:r.jsx(so,{items:m})})})},hd=({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})]})},xd=({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",{})},yd=({data:e})=>{const t=L(na,e),{__typename:n}=t,{text:s,icon:o}=g.useMemo(()=>({text:Ss(n),icon:fi(n)}),[n]);return r.jsxs("td",{children:[r.jsx("div",{children:s}),r.jsx(zs,{radius:"xl",size:"xl",children:o})]})},vd=({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",{})},jd="insertDepreciationRecord",bd=()=>{const[{fetching:e},t]=Pe(sa),n=g.useCallback(async s=>{const o="Error adding depreciation record",a=jd;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(Y,{variant:"outline",size:"icon",className:"size-7.5",onClick:i=>{i.stopPropagation(),a()},children:r.jsx(ns,{className:"size-5"})})}),s&&r.jsx(Cd,{chargeId:t,opened:s,close:o,onAdd:n})]})}function Cd({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}=bd(),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 Dd="updateDepreciationRecord",Sd=()=>{const[{fetching:e},t]=Pe(oa),n=g.useCallback(async s=>{const o="Error updating depreciation record",a=Dd;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}},wd="deleteDepreciationRecord",_d=()=>{const[{fetching:e},t]=Pe(aa),n=g.useCallback(async s=>{const o="Error deleting depreciation record",a=`${wd}-${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 Id(e){const{fetching:t,deleteDepreciationRecord:n}=_d(),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(Y,{variant:"outline",size:"icon",className:"size-7.5 text-red-500",disabled:t,children:r.jsx(Sn,{className:"size-5"})})})})}const Ed=({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}=Sd(),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(Y,{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(Y,{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(Id,{depreciationRecordId:n.id,onDelete:t})]})]},n.id)},Od=({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(Ed,{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 Pd({chargeId:e,chargeType:t,setInsertDocument:n,setMatchDocuments:s,onChange:o,isIncome:a}){const{deleteCharge:i}=gc(),[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(Va,{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(Ka,{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(Od,{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(Aa,{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(wc,{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 Ad(e){return Object.prototype.toString.call(e)==="[object Object]"}function Ir(e){return Ad(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 Td(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 $d(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 Fd(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 kd(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 Rd(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 Md(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 zd(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 Q=!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&&Q,Q=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=$d(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 Ld(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 Bd(){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 Vd(e){function t(s){return e*(s/100)}return{measure:t}}function Ud(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 Hd(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 Kd(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 Gd(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 qd(e,t,n){const s=t[0],o=n?s-e:Ee(t);return{limit:Je(o,s)}}function Wd(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 Yd(e){const{max:t,length:n}=e;function s(a){const i=a-t;return n?i/-n:0}return{get:s}}function Qd(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 Jd(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 Xd(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 Zd(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 eu(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=Fd(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 tu(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,Q=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:Q}})}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 nu(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 ru(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 su(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 ou(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 au(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=Bd(),A=w.measure(t),k=n.map(w.measure),T=Md(c,d),G=T.measureSize(A),Q=Vd(G),R=kd(l,G),z=!f&&!!j,le=f||!!j,{slideSizes:ie,slideSizesWithGaps:M,startGap:B,endGap:he}=su(T,A,k,n,le,o),de=ou(T,G,v,f,A,k,B,he,b),{snaps:ue,snapsAligned:be}=Qd(T,R,A,k,de),K=-Ee(ue)+Ee(M),{snapsContained:xe,scrollContainLimit:ae}=Gd(G,K,be,j,b),ee=z?xe:be,{limit:P}=qd(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=Rd(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=Hd(ce,ge,ye,ve,m,ne),Fe=Xd(f,ee,K,P,ve),ot=Zd(q,fe,te,re,Fe,ve,i),D=Yd(P),E=vt(),Z=ru(t,n,i,u),{slideRegistry:se}=Jd(z,j,ee,ae,de,H),me=eu(e,n,se,ot,re,E,i,_),ke={ownerDocument:s,ownerWindow:o,eventHandler:i,containerRect:A,slideRects:k,animation:q,axis:T,dragHandler:zd(T,e,s,o,ve,Ld(T,o),ce,q,ot,re,Fe,fe,i,Q,y,p,h,ne,O),eventStore:E,percentOfView:Q,index:fe,indexPrevious:te,limit:P,location:ce,offsetLocation:ge,previousLocation:ye,options:a,resizeHandler:Ud(t,i,o,n,T,C,w),scrollBody:re,scrollBounds:Kd(P,ge,ve,re,Q),scrollLooper:Wd(K,P,ge,[ce,ge,ye,ve]),scrollProgress:D,scrollSnapList:ee.map(D.get),scrollSnaps:ee,scrollTarget:Fe,scrollTo:ot,slideLooper:tu(T,G,K,ie,M,ue,ee,ge,n),slideFocus:me,slidesHandler:nu(t,i,I),slidesInView:Z,slideIndexes:H,slideRegistry:se,slidesToScroll:de,target:ve,translate:lo(T,t)};return ke}function iu(){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 cu={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 lu(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 du(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=lu(o),i=du(a),l=vt(),c=iu(),{mergeOptions:d,optionsAtMedia:x,optionsMediaQueries:f}=a,{on:m,off:y,emit:p}=c,u=T;let v=!1,h,j=d(cu,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=au(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 Q(){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:Q,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(()=>{Td(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 uu={context:"[@mantine/carousel] Carousel.Slide was rendered outside of Carousel context"},[fu,pu]=Kr(uu.context);var gu=Object.defineProperty,mu=Object.defineProperties,hu=Object.getOwnPropertyDescriptors,Ar=Object.getOwnPropertySymbols,xu=Object.prototype.hasOwnProperty,yu=Object.prototype.propertyIsEnumerable,Nr=(e,t,n)=>t in e?gu(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,sn=(e,t)=>{for(var n in t||(t={}))xu.call(t,n)&&Nr(e,n,t[n]);if(Ar)for(var n of Ar(t))yu.call(t,n)&&Nr(e,n,t[n]);return e},vu=(e,t)=>mu(e,hu(t)),ju=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:vu(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}}}}),bu=Object.defineProperty,Tr=Object.getOwnPropertySymbols,Cu=Object.prototype.hasOwnProperty,Du=Object.prototype.propertyIsEnumerable,$r=(e,t,n)=>t in e?bu(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,on=(e,t)=>{for(var n in t||(t={}))Cu.call(t,n)&&$r(e,n,t[n]);if(Tr)for(var n of Tr(t))Du.call(t,n)&&$r(e,n,t[n]);return e},Su=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)}}),wu=Object.defineProperty,Ht=Object.getOwnPropertySymbols,uo=Object.prototype.hasOwnProperty,fo=Object.prototype.propertyIsEnumerable,Fr=(e,t,n)=>t in e?wu(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,_u=(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},Iu=(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=Iu(n,["children","className","size","gap"]);const c=pu(),{classes:d,cx:x}=Su({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,_u({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 Eu=Object.defineProperty,Kt=Object.getOwnPropertySymbols,go=Object.prototype.hasOwnProperty,mo=Object.prototype.propertyIsEnumerable,Rr=(e,t,n)=>t in e?Eu(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Ou=(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},Pu=(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 Au={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",Au,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:Q,withIndicators:R,plugins:z,nextControlIcon:le,previousControlIcon:ie,breakpoints:M,skipSnaps:B,containScroll:he,withKeyboardEvents:de,variant:ue}=n,be=Pu(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}=ju({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(fu,{value:{slideGap:h,slideSize:v,embla:P,orientation:j,includeGapInSize:_,breakpoints:M,classNames:y,styles:p,unstyled:u,variant:ue}},N.createElement(He,Ou({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),Q&&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,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(Y,{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(Y,{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(Y,{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(Y,{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(Y,{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(Y,{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(Y,{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(Y,{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(Y,{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(Y,{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(Y,{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(Y,{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(Y,{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 Tu(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 $u=({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:Tu(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.jsxs("div",{className:"flex items-center justify-end space-x-2 py-4",children:[r.jsx(Y,{variant:"outline",size:"sm",onClick:()=>i.previousPage(),disabled:!i.getCanPreviousPage(),children:"Previous"}),r.jsx(Y,{variant:"outline",size:"sm",onClick:()=>i.nextPage(),disabled:!i.getCanNextPage(),children:"Next"})]})]})},Fu=({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},ku=({transactionsProps:e,onChange:t})=>{const{transactions:n}=L(gs,e);return r.jsx(bs,{transactionsProps:n,onChange:t,enableEdit:!0})},Ru=({chargeId:e})=>{const[{data:t,fetching:n}]=Xe({query:va,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."})},Mu=({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)}`})]})})})]})},zu=({chargeProps:e})=>{const t=L(hs,e),n=g.useMemo(()=>t.__typename==="CreditcardBankCharge"&&t.creditCardTransactions?t.creditCardTransactions.map(s=>L(ja,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(Na,{transaction:o})}),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,{chargeId:s.chargeId})})]},s.id)})})]}):null},Lu=({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(ba,{className:"flex flex-col px-2",children:[r.jsx(Ca,{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))})},Bu="deleteMiscExpense",Vu=()=>{const[{fetching:e},t]=Pe(Da),n=g.useCallback(async s=>{const o="Error deleting misc expense",a=`${Bu}-${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 Uu({miscExpenseId:e,onChange:t}){const{deleteMiscExpense:n}=Vu();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(Y,{className:"size-7.5 text-red-500",variant:"ghost",children:r.jsx(Sn,{className:"size-5"})})})}const Hu=({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(nd,{onDone:t,data:o}),r.jsx(Uu,{miscExpenseId:o.id,onChange:t})]})]},o?.id))})]})},Ku=({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 Gu({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),Q=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(Fu,{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(Mu,{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(Lu,{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(ku,{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:Q&&r.jsx(Hu,{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(Y,{onClick:M=>{M.stopPropagation(),c()},variant:"outline",disabled:!A,size:"icon",className:"size-7.5 text-gray-500",children:r.jsx(Sa,{className:"size-5"})})}),"Documents"]}),_&&r.jsx(cn,{chargeId:d.id})]})}),r.jsx(U.Panel,{children:k&&r.jsx(wa,{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(Ku,{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(fc,{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(zu,{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(Ru,{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(xc,{chargeId:d.id,onChange:p,variant:"outline"}),"Ledger Records"]})}),r.jsx(U.Panel,{children:T&&r.jsx(qu,{data:d})})]})]}),A&&r.jsx(He,{maw:"1/6",children:r.jsx(Ua,{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 qu=({data:e})=>{const{ledger:t}=L(js,e);return r.jsx($u,{ledgerRecordsData:t.records,ledgerDiffData:t.validate?.differences,matches:t.validate?.matches})},Wu=({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:_a,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(yd,{data:d}),r.jsx(pd,{data:d}),r.jsx(dd,{data:d}),r.jsx(vd,{data:d}),je(qe,Xr,d)?r.jsx(fd,{data:d}):r.jsx("td",{}),r.jsx(gd,{data:d,onChange:p}),je(qe,es,d)?r.jsx(hd,{data:d,onChange:p}):r.jsx("td",{}),je(qe,ts,d)?r.jsx(xd,{data:d}):r.jsx("td",{}),je(qe,Jr,d)?r.jsx(ud,{data:d}):r.jsx("td",{}),r.jsx(md,{data:d}),r.jsx(ld,{data:d,onChange:p}),r.jsx("td",{children:r.jsxs("div",{className:"flex flex-col gap-2",children:[e&&r.jsx(Ia,{onClick:h=>{h.stopPropagation(),e(p)}}),s&&r.jsx(yc,{toggleMergeSelected:()=>s(p),mergeSelected:o})]})}),r.jsx("td",{children:r.jsxs("div",{className:"flex flex-col gap-2",children:[r.jsx(Pd,{chargeId:d.id,chargeType:d.__typename,setInsertDocument:t?()=>t(p):void 0,setMatchDocuments:n,onChange:p,isIncome:v}),u&&r.jsx(Oa,{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(Gu,{chargeID:d.id,onChange:p,fetching:m})})})})]})},tf=({setEditChargeId:e,setInsertDocument:t,setMatchDocuments:n,toggleMergeCharge:s,mergeSelectedCharges:o,data:a,isAllOpened:i})=>{const l=a?.map(c=>L(Ea,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(Wu,{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{tf as C,$u as L,ad as S,zs as T,yc as a,Gu as b,so as c,Ls as d,oo as e,Ds as f,cd as u};
@@ -1 +0,0 @@
1
- import{r,j as t,df as d,dg as i,B as p,gg as h,dh as x}from"./index-BdnLryTF.js";function u(n,s){const e=new Uint8Array([239,187,191]),c=new Blob([e,n],{type:"text/csv;charset=UTF-8"}),a=URL.createObjectURL(c),o=document.createElement("a");o.href=a,o.download=`${s}.csv`,document.body.appendChild(o),o.click(),document.body.removeChild(o)}const m=({createFileVariables:n,buttonProps:s,buttonContent:e,label:c})=>{const a=r.useCallback(()=>{n().then(({fileContent:o,fileName:l})=>{u(o,l)})},[n]);return t.jsxs(d,{children:[t.jsx(i,{children:t.jsx(p,{variant:"outline",className:"p-2",...s,onClick:a,children:e||t.jsx(h,{size:20})})}),t.jsx(x,{children:t.jsx("p",{children:c||"Download CSV"})})]})};export{m as D};