@accounter/client 0.0.8-alpha-20251027170934-006cd73f08bdddc55a4caff263dcfa5e2b8b63ec → 0.0.8-alpha-20251028103841-7bfcc6a48108b285963cd18e3cc0548f0dd19dd8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +1 -1
- package/dist/assets/{Checkbox-BZ680-Kk.js → Checkbox-D8vMngET.js} +2 -2
- package/dist/assets/MultiSelect-DyHLxout.js +1 -0
- package/dist/assets/Pagination-J219P8nB.js +1 -0
- package/dist/assets/{Progress-DembKoIO.js → Progress-CtbG-tgE.js} +1 -1
- package/dist/assets/Table-DiM_oZiR.js +1 -0
- package/dist/assets/Typography-Cci39G2t.js +1 -0
- package/dist/assets/YearPickerInput-fBHzo-9n.js +1 -0
- package/dist/assets/accordion-CIgxze9K.js +1 -0
- package/dist/assets/accountant-approvals-Da-Rhpn-.js +1 -0
- package/dist/assets/accounter-table-CVAmEnx0.js +1 -0
- package/dist/assets/addDays-CkP1VB0c.js +1 -0
- package/dist/assets/all-charges-DBThy56x.js +1 -0
- package/dist/assets/{arrow-up-down-J9wnXx-h.js → arrow-up-down-DuRFov-X.js} +1 -1
- package/dist/assets/{building-2-1saARtmG.js → building-2-CSNfw8ff.js} +1 -1
- package/dist/assets/business-BwlprQsj.js +32 -0
- package/dist/assets/business-extended-info-CaNS8hMv.js +13 -0
- package/dist/assets/{business-header-SAnNK6FP.js → business-header-BwPwvICE.js} +1 -1
- package/dist/assets/business-transactions-filters-Dc2oWHEf.js +1 -0
- package/dist/assets/business-transactions-single-CPfIuNhV.js +1 -0
- package/dist/assets/business-trip-ChARfpOB.js +1 -0
- package/dist/assets/charge-DVi7MgMm.js +1 -0
- package/dist/assets/charges-filters-qR84DcIb.js +1 -0
- package/dist/assets/charges-ledger-validation-DtbFDZzl.js +1 -0
- package/dist/assets/charges-table-acSB8S00.js +62 -0
- package/dist/assets/{chart-Dq5fMHeT.js → chart-DtI3g0Q5.js} +6 -6
- package/dist/assets/create-event-handler-BiA-1lGu.js +1 -0
- package/dist/assets/{data-table-pagination-4YqSgXqX.js → data-table-pagination-Cv19AH6N.js} +1 -1
- package/dist/assets/download-csv-button-CBfb0Niq.js +1 -0
- package/dist/assets/editable-business-trip-BSVnyXpu.js +16 -0
- package/dist/assets/funnel-BjNIVF6D.js +6 -0
- package/dist/assets/{index-CBQNwu37.js → index-BBP2jL6K.js} +2 -2
- package/dist/assets/index-BcYldCey.js +1 -0
- package/dist/assets/index-C0gmUFjA.css +1 -0
- package/dist/assets/{index-AxUq37Ea.js → index-C1syq_qI.js} +2 -2
- package/dist/assets/index-C4ONlwvw.js +6 -0
- package/dist/assets/index-C5CNHfZr.js +1 -0
- package/dist/assets/index-CB2VcZw_.js +768 -0
- package/dist/assets/index-CHBmUMgX.js +1 -0
- package/dist/assets/index-CJmuVRwK.js +1 -0
- package/dist/assets/{index-sA_45leD.js → index-CRPI_Ng7.js} +3 -3
- package/dist/assets/index-CXbdg8VR.js +1 -0
- package/dist/assets/index-CaGyGe4W.js +9 -0
- package/dist/assets/index-CeKRCUfE.js +1 -0
- package/dist/assets/{index-BYoh_mMo.js → index-Cm34goSF.js} +3 -3
- package/dist/assets/index-CrszoO0T.js +1 -0
- package/dist/assets/index-Cwocz_5B.js +1 -0
- package/dist/assets/index-DFacP-84.js +1 -0
- package/dist/assets/index-DGwGMNjJ.js +2 -0
- package/dist/assets/index-DHPND3oV.js +1 -0
- package/dist/assets/index-DUpo5A07.js +1 -0
- package/dist/assets/index-DoiB6EIi.js +1 -0
- package/dist/assets/index-DrYwq6CI.js +1 -0
- package/dist/assets/index-QZZ5Nw4M.js +1 -0
- package/dist/assets/{index-B4-_AJ5N.js → index-bdZbvws5.js} +16 -16
- package/dist/assets/index-dYyPNFFk.js +2 -0
- package/dist/assets/index-zeuBKIVA.js +6 -0
- package/dist/assets/{index.es-Dwfw0glc.js → index.es-Ddqnt5kx.js} +1 -1
- package/dist/assets/insert-business-trip-modal-5QaUlEPB.js +6 -0
- package/dist/assets/issue-document-n_B8vFIC.js +1 -0
- package/dist/assets/list-plus-CdX74KkH.js +6 -0
- package/dist/assets/login-page-C7kjnYWZ.js +1 -0
- package/dist/assets/match-document-modal-BhJxxCwh.js +16 -0
- package/dist/assets/missing-info-charges-CogpD4pD.js +1 -0
- package/dist/assets/modal-CWL2uL48.js +1 -0
- package/dist/assets/page-layout-Di4aGcKz.js +1 -0
- package/dist/assets/page-not-found-BzIsL96K.js +1 -0
- package/dist/assets/panel-top-open-QFGcJlh7.js +11 -0
- package/dist/assets/{pencil-CYypGy_s.js → pencil-MpkgghkS.js} +1 -1
- package/dist/assets/report-commentary-row-DVBtcPLr.js +1 -0
- package/dist/assets/{save-BE7zhMeq.js → save-C550A2xp.js} +1 -1
- package/dist/assets/similar-transactions-modal-CuhHSiYp.js +1 -0
- package/dist/assets/sub-BJ17PU-y.js +1 -0
- package/dist/assets/subMonths-ClZ3ESsy.js +1 -0
- package/dist/assets/summary-Boa5uC3b.js +1 -0
- package/dist/assets/switch-DXxPikE7.js +1 -0
- package/dist/assets/toggle-expansion-button-DmgIHP4k.js +1 -0
- package/dist/assets/tooltip-B387WRNk.js +1 -0
- package/dist/assets/use-url-query-BPBYbbPQ.js +1 -0
- package/dist/index.html +2 -2
- package/package.json +1 -1
- package/src/components/business/contracts-section.tsx +0 -7
- package/src/components/business-transactions/business-extended-info.tsx +56 -53
- package/src/components/business-transactions/index.tsx +1 -28
- package/src/components/businesses/index.tsx +6 -2
- package/src/components/charges/cells/business-trip.tsx +6 -1
- package/src/components/charges/cells/counterparty.tsx +4 -28
- package/src/components/clients/contracts/modify-contract-dialog.tsx +3 -7
- package/src/components/common/business-trip-report/parts/core-expense-row.tsx +2 -2
- package/src/components/common/business-trip-report/parts/report-header.tsx +2 -1
- package/src/components/common/business-trip-report/parts/uncategorized-transactions.tsx +2 -2
- package/src/components/common/buttons/charge-navigate-button.tsx +12 -11
- package/src/components/common/modals/edit-charge-modal.tsx +2 -2
- package/src/components/common/modals/insert-document-modal.tsx +2 -2
- package/src/components/common/modals/match-document-modal.tsx +2 -2
- package/src/components/common/new-documents-list.tsx +2 -2
- package/src/components/documents-table/cells/creditor.tsx +2 -11
- package/src/components/documents-table/cells/debtor.tsx +2 -11
- package/src/components/ledger-table/counterparty-cell.tsx +4 -33
- package/src/components/reports/conto/index.tsx +1 -18
- package/src/components/reports/trial-balance-report/index.tsx +1 -17
- package/src/components/screens/businesses/business.tsx +0 -4
- package/src/components/screens/charges/all-charges.tsx +1 -17
- package/src/components/screens/charges/charge.tsx +0 -4
- package/src/components/screens/reports/balance-report/index.tsx +0 -14
- package/src/components/screens/reports/depreciation-report/index.tsx +0 -14
- package/src/components/transactions-table/cells/counterparty.tsx +2 -23
- package/src/components/transactions-table/cells-legacy/counterparty.tsx +3 -26
- package/src/gql/gql.ts +3 -3
- package/src/gql/graphql.ts +2 -5
- package/src/providers/urql.tsx +2 -2
- package/dist/assets/Typography-DPXB3hIS.js +0 -1
- package/dist/assets/accordion-UZwiz3fM.js +0 -1
- package/dist/assets/accountant-approvals-DDxSuMql.js +0 -1
- package/dist/assets/all-charges-BCP7OG1d.js +0 -1
- package/dist/assets/business-CBRlGy9p.js +0 -32
- package/dist/assets/business-transactions-single-DvPZFvmH.js +0 -1
- package/dist/assets/business-trip-g2hB76cn.js +0 -1
- package/dist/assets/charges-filters-T9c4RGLH.js +0 -1
- package/dist/assets/charges-ledger-validation-DaD8DCN4.js +0 -1
- package/dist/assets/editable-business-trip-B95j7iAh.js +0 -16
- package/dist/assets/index-5Fl36gjg.js +0 -1
- package/dist/assets/index-BDKAR_k1.js +0 -1
- package/dist/assets/index-BKXeyD9a.js +0 -1
- package/dist/assets/index-BPSZWRv9.js +0 -9
- package/dist/assets/index-BVetJA6_.js +0 -6
- package/dist/assets/index-BXp9NrWt.js +0 -1
- package/dist/assets/index-Br0-IMSG.js +0 -1
- package/dist/assets/index-Bw6OrQ7c.js +0 -1
- package/dist/assets/index-C3bFFbEz.js +0 -1
- package/dist/assets/index-CDIzaROV.js +0 -2
- package/dist/assets/index-CgQ4Qjvh.js +0 -886
- package/dist/assets/index-D4O5HA1y.js +0 -1
- package/dist/assets/index-DAbvR7_s.js +0 -1
- package/dist/assets/index-DkwmPZgt.js +0 -1
- package/dist/assets/index-DpsNoHLd.js +0 -2
- package/dist/assets/index-DtE5Y1ZB.css +0 -1
- package/dist/assets/index-k-cHMsFi.js +0 -1
- package/dist/assets/index-vkYxo-Uq.js +0 -1
- package/dist/assets/index-vstSRm8a.js +0 -1
- package/dist/assets/issue-document-umUFIxCu.js +0 -1
- package/dist/assets/login-page-Ck61EC35.js +0 -1
- package/dist/assets/missing-info-charges-aak-KkPt.js +0 -1
- package/dist/assets/page-not-found-Dzg-czJK.js +0 -1
- package/dist/assets/report-commentary-row-B479zk-x.js +0 -1
- package/dist/assets/sub-BxFupCKS.js +0 -1
- package/dist/assets/subMonths-DskeQPiN.js +0 -1
- package/src/components/charges/helpers.ts +0 -15
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as I,b as x,r as o,u as D,j as t,c as f,C as j}from"./index-CB2VcZw_.js";import{C as v}from"./charges-table-acSB8S00.js";import{E as M,I as E,M as S}from"./match-document-modal-BhJxxCwh.js";import"./toggle-expansion-button-DmgIHP4k.js";import"./panel-top-open-QFGcJlh7.js";import"./index-zeuBKIVA.js";import"./similar-transactions-modal-CuhHSiYp.js";import"./switch-DXxPikE7.js";import"./addDays-CkP1VB0c.js";import"./list-plus-CdX74KkH.js";import"./tooltip-B387WRNk.js";import"./Table-DiM_oZiR.js";import"./summary-Boa5uC3b.js";import"./create-event-handler-BiA-1lGu.js";import"./YearPickerInput-fBHzo-9n.js";import"./insert-business-trip-modal-5QaUlEPB.js";import"./accounter-table-CVAmEnx0.js";import"./Pagination-J219P8nB.js";import"./modal-CWL2uL48.js";const K=({chargeId:u})=>{const{chargeId:g}=I(),r=u||g;let e;try{e=x()}catch{}const[a,i]=o.useState(void 0),[s,n]=o.useState(void 0),[c,d]=o.useState(void 0),[{data:p,fetching:l},m]=D({query:j,pause:!r||!!e,variables:{chargeId:r??""}});o.useEffect(()=>{r&&!e&&m()},[r,e,m]);const h=e||p,C=!e&&l;return r?t.jsxs(t.Fragment,{children:[C?t.jsx(f,{}):t.jsx(v,{setEditChargeId:i,setInsertDocument:n,setMatchDocuments:d,data:h?.charge?[h.charge]:[],isAllOpened:!0}),a&&t.jsx(M,{chargeId:a?.id,close:()=>i(void 0),onChange:a.onChange}),s&&t.jsx(E,{chargeId:s.id,onChange:s.onChange,close:()=>n(void 0)}),c&&t.jsx(S,{chargeId:c.id,ownerId:c.ownerId,setMatchDocuments:()=>d(void 0)})]}):t.jsx("div",{children:"Charge not found"})};export{K as Charge};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as i,bj as B,bq as H,j as e,bk as R,B as z,a6 as G,G as U,x as N,a8 as D,cL as _,aC as q,Q,cM as X,bm as h,e7 as J,bn as P,bo as L,bp as O,d_ as A,h1 as Y,b5 as Z,W as x,X as p,Y as j,Z as g,da as K,db as $,dc as ee}from"./index-CB2VcZw_.js";import{u as se}from"./use-url-query-BPBYbbPQ.js";import{S as m}from"./switch-DXxPikE7.js";import{P as ae}from"./modal-CWL2uL48.js";import{P as te}from"./Pagination-J219P8nB.js";import{F as ne}from"./funnel-BjNIVF6D.js";import{s as oe}from"./sub-BJ17PU-y.js";import{M as k}from"./MultiSelect-DyHLxout.js";function re(a){return!a||B(a)?null:encodeURIComponent(JSON.stringify(a))}const le=[{value:D.AbsAmount,label:"Abs Amount"},{value:D.Amount,label:"Amount"},{value:D.Date,label:"Date"}],ce=[{label:"All",value:A.All},{label:"Income",value:A.Income},{label:"Expense",value:A.Expense}];function ie({filter:a,setFilter:w,closeModal:d}){const{userContext:b}=i.useContext(G),o=U({defaultValues:{byOwners:b?.context.adminBusinessId?[b.context.adminBusinessId]:void 0,sortBy:{field:D.Date,asc:!1},toAnyDate:N(new Date,"yyyy-MM-dd"),fromAnyDate:N(oe(new Date,{years:1}),"yyyy-MM-dd"),...a}}),{control:l,handleSubmit:T,watch:C}=o,[y,F]=i.useState(a.sortBy?.asc??!1),[c,u]=i.useState(!!a.sortBy?.field),{selectableFinancialEntities:S,fetching:t}=_(),{selectableTags:v,fetching:I}=q(),E=C("sortBy.field");i.useEffect(()=>{E&&!c?u(!0):!E&&c&&u(!1)},[E,c]);const V=s=>{y!=null&&s.sortBy?.field&&(s.sortBy.asc=y),w(s),d()};function W(){w({}),F(!1),d()}return e.jsxs(e.Fragment,{children:[t?e.jsx("div",{children:"Loading..."}):e.jsx("div",{}),e.jsx(Q,{...o,children:e.jsxs("form",{onSubmit:T(V),children:[e.jsxs(X,{cols:2,children:[e.jsx(h,{name:"byOwners",control:l,defaultValue:a.byOwners,render:({field:s,fieldState:n})=>e.jsx(k,{...s,data:S,value:s.value??[],disabled:t,label:"Owners",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:n.error?.message,withinPortal:!0})}),e.jsx(h,{name:"byBusinesses",control:l,defaultValue:a.byBusinesses,render:({field:s,fieldState:n})=>e.jsx(k,{...s,data:S,value:s.value??[],disabled:t,label:"Financial Entities",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:n.error?.message,withinPortal:!0})}),e.jsx(h,{name:"byTags",control:l,defaultValue:a.byTags,render:({field:s,fieldState:n})=>e.jsx(k,{...s,data:v,itemComponent:J,value:s.value??[],disabled:I,label:"Tags",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:n.error?.message,withinPortal:!0,filter:(r,f,M)=>M.label?.toLowerCase().includes(r.toLowerCase().trim())||M.description?.toLowerCase().includes(r.toLowerCase().trim())})}),e.jsx(h,{name:"fromAnyDate",control:l,defaultValue:a.fromAnyDate,rules:{pattern:{value:P,message:"Date must be im format yyyy-mm-dd"}},render:({field:s,fieldState:n})=>e.jsx(L,{...s,onChange:r=>{const f=r?typeof r=="string"?r:N(r,"yyyy-MM-dd"):void 0;f!==s.value&&s.onChange(f)},value:s.value?new Date(s.value):void 0,error:n.error?.message,label:"From Date",popoverProps:{withinPortal:!0}})}),e.jsx(h,{name:"toAnyDate",control:l,defaultValue:a.toAnyDate,rules:{pattern:{value:P,message:"Date must be im format yyyy-mm-dd"}},render:({field:s,fieldState:n})=>e.jsx(L,{...s,onChange:r=>{const f=r?typeof r=="string"?r:N(r,"yyyy-MM-dd"):void 0;f!==s.value&&s.onChange(f)},value:s.value?new Date(s.value):void 0,error:n.error?.message,label:"To Date",popoverProps:{withinPortal:!0}})}),e.jsx(h,{name:"chargesType",control:l,defaultValue:a.chargesType,render:({field:s,fieldState:n})=>e.jsx(O,{...s,data:ce,value:s.value??A.All,disabled:t,label:"Charge Type",placeholder:"Filter income/expense",maxDropdownHeight:160,error:n.error?.message,withinPortal:!0})}),e.jsx(h,{name:"sortBy.field",control:l,defaultValue:a.sortBy?.field??D.Date,render:({field:s,fieldState:n})=>e.jsx(O,{...s,data:le,label:"Field to sort by",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:n.error?.message,rightSectionProps:{style:{width:"5rem"}},withinPortal:!0,rightSection:e.jsxs("div",{className:"flex flex-row items-center gap-1",children:[e.jsx(m,{defaultChecked:a.sortBy?.asc??!1,checked:y??!1,disabled:!c,onCheckedChange:F}),e.jsx("span",{className:"text-xs",children:y?"ASC":"DESC"})]})})}),e.jsx(h,{name:"accountantStatus",control:l,defaultValue:a.accountantStatus,render:({field:s,fieldState:n})=>e.jsx(k,{...s,value:s.value??[],data:Y,disabled:t,label:"Accountant Status",placeholder:"All",maxDropdownHeight:160,error:n.error?.message,withinPortal:!0})}),e.jsxs("div",{className:"flex flex-col gap-2 mt-4 rounded-lg border p-3 shadow-sm space-y-2",children:[e.jsx(Z,{children:"Missing Information:"}),e.jsx(x,{control:o.control,name:"withoutInvoice",render:({field:s})=>e.jsxs(p,{className:"flex flex-row items-center justify-between",children:[e.jsx("div",{className:"space-y-0.5",children:e.jsx(j,{children:"Without Invoice"})}),e.jsx(g,{children:e.jsx(m,{defaultChecked:a.withoutInvoice??!1,onCheckedChange:s.onChange})})]})}),e.jsx(x,{control:o.control,name:"withoutReceipt",render:({field:s})=>e.jsxs(p,{className:"flex flex-row items-center justify-between",children:[e.jsx("div",{className:"space-y-0.5",children:e.jsx(j,{children:"Without Receipts"})}),e.jsx(g,{children:e.jsx(m,{defaultChecked:a.withoutReceipt??!1,onCheckedChange:s.onChange})})]})}),e.jsx(x,{control:o.control,name:"withoutDocuments",render:({field:s})=>e.jsxs(p,{className:"flex flex-row items-center justify-between",children:[e.jsx("div",{className:"space-y-0.5",children:e.jsx(j,{children:"Without Documents"})}),e.jsx(g,{children:e.jsx(m,{defaultChecked:a.withoutDocuments??!1,onCheckedChange:s.onChange})})]})}),e.jsx(x,{control:o.control,name:"withOpenDocuments",render:({field:s})=>e.jsxs(p,{className:"flex flex-row items-center justify-between",children:[e.jsx("div",{className:"space-y-0.5",children:e.jsx(j,{children:"With Open Documents"})}),e.jsx(g,{children:e.jsxs(K,{children:[e.jsx($,{children:e.jsx(m,{defaultChecked:a.withOpenDocuments??!1,onCheckedChange:s.onChange})}),e.jsx(ee,{children:e.jsx("p",{children:"Show only charges with documents that are currently open"})})]})})]})}),e.jsx(x,{control:o.control,name:"withoutTransactions",render:({field:s})=>e.jsxs(p,{className:"flex flex-row items-center justify-between",children:[e.jsx("div",{className:"space-y-0.5",children:e.jsx(j,{children:"Without Transactions"})}),e.jsx(g,{children:e.jsx(m,{defaultChecked:a.withoutTransactions??!1,onCheckedChange:s.onChange})})]})}),e.jsx(x,{control:o.control,name:"unbalanced",render:({field:s})=>e.jsxs(p,{className:"flex flex-row items-center justify-between",children:[e.jsx("div",{className:"space-y-0.5",children:e.jsx(j,{children:"Unbalanced businesses"})}),e.jsx(g,{children:e.jsx(m,{defaultChecked:a.unbalanced??!1,onCheckedChange:s.onChange})})]})}),e.jsx(x,{control:o.control,name:"withoutLedger",render:({field:s})=>e.jsxs(p,{className:"flex flex-row items-center justify-between",children:[e.jsx("div",{className:"space-y-0.5",children:e.jsx(j,{children:"Without ledger"})}),e.jsx(g,{children:e.jsx(m,{defaultChecked:a.withoutLedger??!1,onCheckedChange:s.onChange})})]})})]})]}),e.jsxs("div",{className:"flex justify-center mt-5 gap-3",children:[e.jsx("button",{type:"submit",disabled:t||I,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:W,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:d,children:"Cancel"})]})]})})]})}function be({filter:a={},setFilter:w,activePage:d,setPage:b,totalPages:o=1,initiallyOpened:l=!1}){const[T,C]=i.useState(l),[y,F]=i.useState(!B(a)),{get:c,set:u}=se();i.useEffect(()=>{const t=d>1?d.toFixed(0):null,v=c("page");t!==v&&u("page",t)},[d,c,u]),i.useEffect(()=>{const t=re(a),v=c("chargesFilters");t!==v&&(u("chargesFilters",t),u("page"),b(1))},[a,c,u,b]);const S=i.useCallback(t=>{H(t,a)||(w(t),F(!B(t)))},[a,w]);return e.jsxs("div",{className:"flex flex-row gap-5 items-center",children:[e.jsx(ae,{opened:T,onClose:()=>C(!1),content:e.jsx(ie,{filter:a,setFilter:S,closeModal:()=>C(!1)}),modalSize:"xl"}),o>1&&e.jsx(te,{className:"flex-auto",value:d,onChange:b,total:o}),e.jsx(R,{inline:!0,size:16,disabled:!y,children:e.jsx(z,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>C(!0),children:e.jsx(ne,{className:"size-5"})})})]})}export{be as C,ce as c};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as t,F as D,u as E,j as e,T as N,B as w,L as T,d as b,e as z,f as W}from"./index-CB2VcZw_.js";import{u as O}from"./use-url-query-BPBYbbPQ.js";import{C as k}from"./charges-filters-qR84DcIb.js";import{C as B,T as R}from"./charges-table-acSB8S00.js";import{M as V}from"./index-C1syq_qI.js";import{E as A,I as Q,M as U}from"./match-document-modal-BhJxxCwh.js";import{P as q}from"./page-layout-Di4aGcKz.js";import{P as J}from"./Progress-CtbG-tgE.js";import{P as $,a as G}from"./panel-top-open-QFGcJlh7.js";import"./switch-DXxPikE7.js";import"./modal-CWL2uL48.js";import"./Pagination-J219P8nB.js";import"./create-event-handler-BiA-1lGu.js";import"./funnel-BjNIVF6D.js";import"./sub-BJ17PU-y.js";import"./addDays-CkP1VB0c.js";import"./subMonths-ClZ3ESsy.js";import"./MultiSelect-DyHLxout.js";import"./toggle-expansion-button-DmgIHP4k.js";import"./index-zeuBKIVA.js";import"./similar-transactions-modal-CuhHSiYp.js";import"./list-plus-CdX74KkH.js";import"./tooltip-B387WRNk.js";import"./Table-DiM_oZiR.js";import"./summary-Boa5uC3b.js";import"./Checkbox-D8vMngET.js";import"./YearPickerInput-fBHzo-9n.js";import"./insert-business-trip-modal-5QaUlEPB.js";import"./accounter-table-CVAmEnx0.js";const Fe=()=>{const{setFiltersContext:p}=t.useContext(D),[n,u]=t.useState(void 0),[l,x]=t.useState(void 0),[c,C]=t.useState(void 0),[m,f]=t.useState(!1),[r,g]=t.useState([]),{get:F}=O(),d=F("chargesFilters"),I=t.useMemo(()=>{if(d)try{return JSON.parse(decodeURIComponent(d))}catch{return}},[d]),[o,j]=t.useState(I),S=t.useCallback((s,y)=>{r.map(h=>h.id).includes(s)?g(r.filter(h=>h.id!==s)):g([...r,{id:s,onChange:y}])},[r]),[{data:a,fetching:M},v]=E({query:W,variables:{filters:o},pause:!0});function P(){g([])}const i=t.useMemo(()=>a?.chargesWithLedgerChanges?.length?a.chargesWithLedgerChanges[a.chargesWithLedgerChanges.length-1].progress:0,[a?.chargesWithLedgerChanges]),L=t.useCallback(s=>{j(s)},[j]);return t.useEffect(()=>{o&&v()},[o,v]),t.useEffect(()=>{p(e.jsxs("div",{className:"flex flex-row gap-x-5 items-center",children:[e.jsx(J,{value:i,label:`${i?.toFixed(2)}%`,size:"xl",animate:i<100,className:"min-w-52"}),e.jsx(k,{filter:o,setFilter:L,activePage:1,setPage:()=>{},initiallyOpened:!0}),e.jsx(N,{label:"Expand all accounts",children:e.jsx(w,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>f(s=>!s),children:m?e.jsx($,{className:"size-5"}):e.jsx(G,{className:"size-5"})})}),e.jsx(V,{selected:r,resetMerge:P})]}))},[a,M,o,m,p,f,r,i,L]),e.jsxs(q,{title:"Charges Ledger Validation",description:"Manage charges",children:[M?e.jsx(T,{className:"h-10 w-10 animate-spin mr-2 self-center"}):e.jsxs(e.Fragment,{children:[e.jsx(B,{setEditChargeId:u,setInsertDocument:x,setMatchDocuments:C,toggleMergeCharge:S,mergeSelectedCharges:new Set(r.map(s=>s.id)),data:a?.chargesWithLedgerChanges.filter(s=>!!s.charge).map(s=>s.charge)??[],isAllOpened:m}),e.jsxs("div",{className:"flex flex-row justify-center my-2",children:[i>0&&i<100&&e.jsx(b,{}),i===100&&!a?.chargesWithLedgerChanges.filter(s=>!!s.charge).length&&e.jsx(R,{radius:"xl",size:"xl",color:"green",children:e.jsx(z,{})})]})]}),n&&e.jsx(A,{chargeId:n?.id,close:()=>u(void 0),onChange:n.onChange}),l&&e.jsx(Q,{chargeId:l.id,onChange:l.onChange,close:()=>x(void 0)}),c&&e.jsx(U,{chargeId:c.id,ownerId:c.ownerId,setMatchDocuments:()=>C(void 0)})]})};export{Fe as ChargesLedgerValidation};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import{v as Oe,j as r,el as yo,em as vo,en as jo,aM as bo,bv as Ve,by as $,bw as we,eo as Co,r as g,bx as Ue,a9 as N,bz as He,ep as Lr,eq as Do,er as So,ef as wo,es as _o,eg as Wt,bg as Qe,et as Br,eu as Io,d as jt,bI as Vr,J as H,ev as Eo,g as Pe,ew as Oo,t as k,i as Ae,ex as Po,bN as Gt,T as Le,B as Q,m as Ur,ey as Ao,ez as No,G as xn,Q as To,eA as $o,eB as ko,eC as nt,eD as rt,eE as Mn,eF as zn,ds as Fo,eG as Hr,eH as Ro,l as gt,eI as Mo,eJ as zo,D as yn,af as Lo,bR as Kr,z as vn,eK as Bo,eL as Vo,cN as Gr,d0 as qr,d2 as Wr,ah as Uo,ai as Ho,K as Yr,cQ as jn,cR as bn,cS as Ye,cT as Te,cU as Pt,cV as Cn,cW as Ie,p as Ln,x as Be,u as Xe,eM as Ko,E as Go,c as qo,eN as Wo,dQ as Yo,eO as Qo,bk as Re,eP as Jo,bP as At,R as mt,eQ as Qr,eR as Jr,eS as ze,eT as Xo,eU as Xr,eV as Zo,eW as ea,eX as Zr,eY as an,eZ as es,e_ as ta,e$ as na,aU as Dn,f0 as ra,ag as ts,f1 as ns,n as ft,bm as $e,bn as rs,bo as ss,bH as os,bp as Nt,f2 as sa,f3 as oa,bO as Sn,e as aa,f4 as ia,a3 as ca,f5 as la,L as as,f6 as da,f7 as ua,cO as fa,f8 as cn,f9 as is,fa as cs,fb as pa,fc as Yt,fd as Bn,fe as ls,cP as ga,ff as ma,dj as De,dk as Se,ak as ds,fg as us,e3 as ha,dR as fs,fh as ps,fi as gs,fj as xa,cJ as tt,fk as ms,fl as ya,fm as hs,V as va,O as ja,fn as xs,fo as ba,fp as ys,fq as vs,fr as _e,fs as je,ft as Vn,fu as Ca,fv as Da,fw as qe,fx as Sa,fy as wa,fz as _a}from"./index-CB2VcZw_.js";import{T as Ia}from"./toggle-expansion-button-DmgIHP4k.js";import{M as Ea,P as W,I as Oa,T as js,a as Pa,D as Aa,A as Na,b as Ta,c as $a,S as ka,C as Fa,d as Ra}from"./index-zeuBKIVA.js";import{T as bs}from"./Table-DiM_oZiR.js";import{R as Ma,S as za,M as oe,B as La,L as Un,G as Qt,C as Hn,A as V,a as Ba}from"./summary-Boa5uC3b.js";import{L as Jt}from"./list-plus-CdX74KkH.js";/**
|
|
2
|
+
* @license lucide-react v0.546.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 Va=[["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"}]],Ua=Oe("arrow-down-wide-narrow",Va);/**
|
|
7
|
+
* @license lucide-react v0.546.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 Ha=[["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"}]],Ka=Oe("arrow-right-left",Ha);/**
|
|
12
|
+
* @license lucide-react v0.546.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 Ga=[["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"}]],Cs=Oe("coins",Ga);/**
|
|
17
|
+
* @license lucide-react v0.546.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 qa=[["path",{d:"M14 3a1 1 0 0 1 1 1v5a1 1 0 0 1-1 1",key:"1l7d7l"}],["path",{d:"M19 3a1 1 0 0 1 1 1v5a1 1 0 0 1-1 1",key:"9955pe"}],["path",{d:"m7 15 3 3",key:"4hkfgk"}],["path",{d:"m7 21 3-3H5a2 2 0 0 1-2-2v-2",key:"1xljwe"}],["rect",{x:"14",y:"14",width:"7",height:"7",rx:"1",key:"1cdgtw"}],["rect",{x:"3",y:"3",width:"7",height:"7",rx:"1",key:"zi3rio"}]],Wa=Oe("combine",qa);/**
|
|
22
|
+
* @license lucide-react v0.546.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 Ya=[["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"}]],Kn=Oe("file-plus-2",Ya);/**
|
|
27
|
+
* @license lucide-react v0.546.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 Qa=[["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"}]],Ja=Oe("gift",Qa);/**
|
|
32
|
+
* @license lucide-react v0.546.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 Xa=[["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"}]],Za=Oe("piggy-bank",Xa);/**
|
|
37
|
+
* @license lucide-react v0.546.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 ei=[["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"}]],ti=Oe("plane",ei);/**
|
|
42
|
+
* @license lucide-react v0.546.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 ni=[["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"}]],ri=Oe("refresh-ccw-dot",ni);/**
|
|
47
|
+
* @license lucide-react v0.546.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 si=[["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"}]],oi=Oe("trending-up-down",si);/**
|
|
52
|
+
* @license lucide-react v0.546.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 ai=[["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"}]],ii=Oe("wallet",ai),ci={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"},Ds=e=>ci[e]??"Unknown",li={CommonCharge:r.jsx(Cs,{}),BusinessTripCharge:r.jsx(ti,{}),DividendCharge:r.jsx(Ja,{}),ConversionCharge:r.jsx(bo,{}),SalaryCharge:r.jsx(ii,{}),InternalTransferCharge:r.jsx(Ka,{}),MonthlyVatCharge:r.jsx(jo,{}),BankDepositCharge:r.jsx(Za,{}),ForeignSecuritiesCharge:r.jsx(oi,{}),CreditcardBankCharge:r.jsx(vo,{}),FinancialCharge:r.jsx(yo,{})},di=e=>li[e]??r.jsx(Cs,{});function Gn(e){return typeof e!="string"?"":e.charAt(0).toUpperCase()+e.slice(1)}var ui=Object.defineProperty,fi=Object.defineProperties,pi=Object.getOwnPropertyDescriptors,qn=Object.getOwnPropertySymbols,gi=Object.prototype.hasOwnProperty,mi=Object.prototype.propertyIsEnumerable,Wn=(e,t,n)=>t in e?ui(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Xt=(e,t)=>{for(var n in t||(t={}))gi.call(t,n)&&Wn(e,n,t[n]);if(qn)for(var n of qn(t))mi.call(t,n)&&Wn(e,n,t[n]);return e},hi=(e,t)=>fi(e,pi(t));const xi=["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)}},yi={xs:$(4),sm:$(4),md:$(6),lg:$(8),xl:$(10)};function vi({theme:e,variant:t,color:n,size:s,gradient:o}){if(!xi.includes(t))return null;if(t==="dot"){const i=we({size:s,sizes:yi});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 ji=Ve((e,{color:t,radius:n,gradient:s,fullWidth:o},{variant:a,size:i})=>{const{fontSize:c,height:l}=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(hi(Xt(Xt({},e.fn.focusStyles()),e.fn.fontStyles()),{fontSize:c,height:l,WebkitTapHighlightColor:"transparent",lineHeight:`calc(${l} - ${$(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"}),vi({theme:e,variant:a,color:t,size:i,gradient:s}))}}),bi=Object.defineProperty,Tt=Object.getOwnPropertySymbols,Ss=Object.prototype.hasOwnProperty,ws=Object.prototype.propertyIsEnumerable,Yn=(e,t,n)=>t in e?bi(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Ci=(e,t)=>{for(var n in t||(t={}))Ss.call(t,n)&&Yn(e,n,t[n]);if(Tt)for(var n of Tt(t))ws.call(t,n)&&Yn(e,n,t[n]);return e},Di=(e,t)=>{var n={};for(var s in e)Ss.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&&ws.call(e,s)&&(n[s]=e[s]);return n};const Si={variant:"light",size:"md",radius:"xl"},_s=g.forwardRef((e,t)=>{const n=Ue("Badge",Si,e),{className:s,color:o,variant:a,fullWidth:i,children:c,size:l,leftSection:d,rightSection:x,radius:p,gradient:m,classNames:y,styles:f,unstyled:u}=n,v=Di(n,["className","color","variant","fullWidth","children","size","leftSection","rightSection","radius","gradient","classNames","styles","unstyled"]),{classes:h,cx:j}=ji({fullWidth:i,color:o,radius:p,gradient:m},{classNames:y,styles:f,name:"Badge",unstyled:u,variant:a,size:l});return N.createElement(He,Ci({className:j(h.root,s),ref:t},v),d&&N.createElement("span",{className:h.leftSection},d),N.createElement("span",{className:h.inner},c),x&&N.createElement("span",{className:h.rightSection},x))});_s.displayName="@mantine/core/Badge";const ln=Co(_s);var wi=Object.defineProperty,$t=Object.getOwnPropertySymbols,Is=Object.prototype.hasOwnProperty,Es=Object.prototype.propertyIsEnumerable,Qn=(e,t,n)=>t in e?wi(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Jn=(e,t)=>{for(var n in t||(t={}))Is.call(t,n)&&Qn(e,n,t[n]);if($t)for(var n of $t(t))Es.call(t,n)&&Qn(e,n,t[n]);return e},_i=(e,t)=>{var n={};for(var s in e)Is.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&&Es.call(e,s)&&(n[s]=e[s]);return n};const Ii={multiple:!1},Os=g.forwardRef((e,t)=>{const n=Ue("FileButton",Ii,e),{onChange:s,children:o,multiple:a,accept:i,name:c,form:l,resetRef:d,disabled:x,capture:p,inputProps:m}=n,y=_i(n,["onChange","children","multiple","accept","name","form","resetRef","disabled","capture","inputProps"]),f=g.useRef(),u=()=>{!x&&f.current.click()},v=j=>{s(a?Array.from(j.currentTarget.files):j.currentTarget.files[0]||null)};return Lr(d,()=>{f.current.value=""}),N.createElement(N.Fragment,null,o(Jn({onClick:u},y)),N.createElement("input",Jn({style:{display:"none"},type:"file",accept:i,multiple:a,onChange:v,ref:Do(t,f),name:c,form:l,capture:p},m)))});Os.displayName="@mantine/core/FileButton";var Ei=Ve(()=>({placeholder:{},input:{cursor:"pointer"}})),Oi=Object.defineProperty,Pi=Object.defineProperties,Ai=Object.getOwnPropertyDescriptors,kt=Object.getOwnPropertySymbols,Ps=Object.prototype.hasOwnProperty,As=Object.prototype.propertyIsEnumerable,Xn=(e,t,n)=>t in e?Oi(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,et=(e,t)=>{for(var n in t||(t={}))Ps.call(t,n)&&Xn(e,n,t[n]);if(kt)for(var n of kt(t))As.call(t,n)&&Xn(e,n,t[n]);return e},St=(e,t)=>Pi(e,Ai(t)),Ni=(e,t)=>{var n={};for(var s in e)Ps.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&&As.call(e,s)&&(n[s]=e[s]);return n};const Ti=({value:e})=>N.createElement(Qe,{sx:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}},Array.isArray(e)?e.map(t=>t.name).join(", "):e?.name),$i={size:"sm",valueComponent:Ti},Ns=g.forwardRef((e,t)=>{const n=So("FileInput",$i,e),{inputProps:s,wrapperProps:o,placeholder:a,value:i,defaultValue:c,onChange:l,multiple:d,accept:x,name:p,form:m,classNames:y,styles:f,unstyled:u,valueComponent:v,rightSection:h,clearable:j,clearButtonProps:C,readOnly:I,capture:O,fileInputProps:_}=n,b=Ni(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:F}=Ei(null,{name:"FileInput",classNames:y,styles:f,unstyled:u}),[T,G]=wo({value:i,defaultValue:c,onChange:l,finalValue:d?[]:null}),Y=Array.isArray(T)?T.length!==0:T!==null,R=h||(j&&Y&&!I?N.createElement(_o,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(Os,{onChange:G,multiple:d,accept:x,name:p,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:F(A.input,y?.input)})}),Y?N.createElement(v,{value:T}):N.createElement(Wt.Placeholder,{className:A.placeholder},a))))});Ns.displayName="@mantine/core/FileInput";const ki=Ns;var Fi=Object.defineProperty,Ri=Object.defineProperties,Mi=Object.getOwnPropertyDescriptors,Zn=Object.getOwnPropertySymbols,zi=Object.prototype.hasOwnProperty,Li=Object.prototype.propertyIsEnumerable,er=(e,t,n)=>t in e?Fi(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Bi=(e,t)=>{for(var n in t||(t={}))zi.call(t,n)&&er(e,n,t[n]);if(Zn)for(var n of Zn(t))Li.call(t,n)&&er(e,n,t[n]);return e},Vi=(e,t)=>Ri(e,Mi(t)),Ui=Ve(e=>({root:Vi(Bi({},e.fn.cover()),{display:"flex",alignItems:"center",justifyContent:"center",overflow:"hidden"})})),Hi=Object.defineProperty,Ki=Object.defineProperties,Gi=Object.getOwnPropertyDescriptors,Ft=Object.getOwnPropertySymbols,Ts=Object.prototype.hasOwnProperty,$s=Object.prototype.propertyIsEnumerable,tr=(e,t,n)=>t in e?Hi(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,wt=(e,t)=>{for(var n in t||(t={}))Ts.call(t,n)&&tr(e,n,t[n]);if(Ft)for(var n of Ft(t))$s.call(t,n)&&tr(e,n,t[n]);return e},qi=(e,t)=>Ki(e,Gi(t)),Wi=(e,t)=>{var n={};for(var s in e)Ts.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&&$s.call(e,s)&&(n[s]=e[s]);return n};const Yi={overlayOpacity:.75,transitionDuration:0,radius:0,zIndex:Br("overlay")},ks=g.forwardRef((e,t)=>{const n=Ue("LoadingOverlay",Yi,e),{className:s,visible:o,loaderProps:a,overlayOpacity:i,overlayColor:c,transitionDuration:l,exitTransitionDuration:d,zIndex:x,style:p,loader:m,radius:y,overlayBlur:f,unstyled:u,variant:v,keepMounted:h}=n,j=Wi(n,["className","visible","loaderProps","overlayOpacity","overlayColor","transitionDuration","exitTransitionDuration","zIndex","style","loader","radius","overlayBlur","unstyled","variant","keepMounted"]),{classes:C,cx:I,theme:O}=Ui(null,{name:"LoadingOverlay",unstyled:u,variant:v}),_=`calc(${x} + 1)`;return N.createElement(Io,{keepMounted:h,duration:l,exitDuration:d,mounted:o,transition:"fade"},b=>N.createElement(He,wt({className:I(C.root,s),style:qi(wt(wt({},b),p),{zIndex:x}),ref:t},j),m?N.createElement("div",{style:{zIndex:_}},m):N.createElement(jt,wt({style:{zIndex:_}},a)),N.createElement(Vr,{opacity:i,zIndex:x,radius:y,blur:f,unstyled:u,color:c||(O.colorScheme==="dark"?O.colors.dark[5]:O.white)})))});ks.displayName="@mantine/core/LoadingOverlay";var Qi=Object.defineProperty,Ji=Object.defineProperties,Xi=Object.getOwnPropertyDescriptors,nr=Object.getOwnPropertySymbols,Zi=Object.prototype.hasOwnProperty,ec=Object.prototype.propertyIsEnumerable,rr=(e,t,n)=>t in e?Qi(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,sr=(e,t)=>{for(var n in t||(t={}))Zi.call(t,n)&&rr(e,n,t[n]);if(nr)for(var n of nr(t))ec.call(t,n)&&rr(e,n,t[n]);return e},tc=(e,t)=>Ji(e,Xi(t));const nc={xs:$(16),sm:$(20),md:$(26),lg:$(32),xl:$(40)},rc=["filled","light","gradient","outline","default"];function sc({theme:e,variant:t,color:n,gradient:s}){if(!rc.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 oc=Ve((e,{color:t,radius:n,gradient:s},{variant:o,size:a})=>{const i=we({size:a,sizes:nc});return{root:sr(tc(sr({},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)}),sc({theme:e,variant:o,gradient:s,color:t}))}}),ac=Object.defineProperty,Rt=Object.getOwnPropertySymbols,Fs=Object.prototype.hasOwnProperty,Rs=Object.prototype.propertyIsEnumerable,or=(e,t,n)=>t in e?ac(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,ic=(e,t)=>{for(var n in t||(t={}))Fs.call(t,n)&&or(e,n,t[n]);if(Rt)for(var n of Rt(t))Rs.call(t,n)&&or(e,n,t[n]);return e},cc=(e,t)=>{var n={};for(var s in e)Fs.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&&Rs.call(e,s)&&(n[s]=e[s]);return n};const lc={size:"md",variant:"filled"},Ms=g.forwardRef((e,t)=>{const n=Ue("ThemeIcon",lc,e),{className:s,size:o,radius:a,variant:i,color:c,children:l,gradient:d,unstyled:x}=n,p=cc(n,["className","size","radius","variant","color","children","gradient","unstyled"]),{classes:m,cx:y}=oc({variant:i,radius:a,color:c,gradient:d},{name:"ThemeIcon",unstyled:x,variant:i,size:o});return N.createElement(He,ic({className:y(m.root,s),ref:t},p),l)});Ms.displayName="@mantine/core/ThemeIcon";const dc=({data:e})=>{const t=H(Eo,e);return r.jsxs(r.Fragment,{children:[r.jsx(Ma,{data:t,onChange:()=>{}}),r.jsx(za,{data:t})]})},uc="deleteCharge",fc=()=>{const[{fetching:e},t]=Pe(Oo),n=g.useCallback(async s=>{const o=`Error deleting charge ID [${s.chargeId}]`,a=`${uc}-${s.chargeId}`;k.loading("Deleting charge",{id:a});try{const i=await t(s),c=Ae(i,o,a);if(c){if(c.deleteCharge===!1)throw new Error("Unsuccessful deletion");return k.success("Success",{id:a,description:"Charge was deleted"}),c.deleteCharge}}catch(i){console.error(`${o}: ${i}`),k.error("Error",{id:a,description:o,duration:1e5,closeButton:!0})}return!1},[t]);return{fetching:e,deleteCharge:n}},pc="regenerateLedgerRecords",gc=()=>{const[{fetching:e},t]=Pe(Po),n=g.useCallback(async s=>{const o="Error regenerating ledger",a=`${pc}-${s.chargeId}`;k.loading("Regenerating Ledger",{id:a});try{const i=await t(s),c=Ae(i,o,a,"regenerateLedgerRecords");if(c)return k.success("Success",{id:a,description:"Ledger records were regenerated"}),c.regenerateLedgerRecords}catch(i){console.error(`${o}: ${i}`),k.error("Error",{id:a,description:o,duration:1e5,closeButton:!0})}},[t]);return{fetching:e,regenerateLedgerRecords:n}};function mc({chargeId:e,onChange:t,...n}){const{regenerateLedgerRecords:s}=gc();function o(){s({chargeId:e}).then(t)}return r.jsx(Gt,{onConfirm:o,title:"Are you sure you want to regenerate ledger records?",children:r.jsx(Le,{label:"Regenerate Ledger",children:r.jsx(Q,{variant:"outline",size:"icon",...n,className:Ur("size-7.5",n.className),children:r.jsx(ri,{className:"size-5"})})})})}function hc(e){const{mergeSelected:t,toggleMergeSelected:n}=e,[s,o]=g.useState(t?"default":"ghost");return g.useEffect(()=>{o(t?"default":"ghost")},[t]),r.jsx(Le,{label:"Select for merge",children:r.jsx(Q,{onClick:a=>{a.stopPropagation(),n()},variant:s,className:Ur("size-7.5",t?"bg-blue-500 hover:bg-blue-500/90":""),children:r.jsx(Wa,{className:"size-5"})})})}const xc="updateCharge",zs=()=>{const[{fetching:e},t]=Pe(Ao),n=g.useCallback(async s=>{const o=`Error updating charge ID [${s.chargeId}]`,a=`${xc}-${s.chargeId}`;k.loading("Updating charge",{id:a});try{const i=await t(s),c=Ae(i,o,a,"updateCharge");if(c)return k.success("Success",{id:a,description:"Charge updated"}),c.updateCharge.charge}catch(i){console.error(`${o}: ${i}`),k.error("Error",{id:a,description:o,duration:1e5,closeButton:!0})}},[t]);return{fetching:e,updateCharge:n}},yc="updateMiscExpense",vc=()=>{const[{fetching:e},t]=Pe(No),n=g.useCallback(async s=>{const o=`Error updating misc expense ID [${s.id}]`,a=`${yc}-${s.id}`;k.loading("Update Misc Expense",{id:a});try{const i=await t(s),c=Ae(i,o,a,"updateMiscExpense");if(c)return k.success("Success",{id:a,description:"Misc expense was updated"}),c.updateMiscExpense}catch(i){console.error(`${o}: ${i}`),k.error("Error",{id:a,description:o,duration:1e5,closeButton:!0})}},[t]);return{fetching:e,updateMiscExpense:n}},jc=({onDone:e,data:t})=>{const[n,s]=g.useState(!1),o=H($o,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:c}}=a,{updateMiscExpense:l,fetching:d}=vc(),x=g.useCallback(async m=>{s(!0),await l({id:o.id,fields:m}),e(),s(!1)},[l,e,o.id]),p=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(To,{...a,children:r.jsx("form",{onSubmit:i(p),noValidate:!0,children:r.jsxs("div",{className:"px-5 flex flex-col gap-5",children:[r.jsx(Ea,{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(c).length===0,children:"Accept"})})]})})})},bc="insertSalaryRecordsFromFile",Cc=()=>{const[{fetching:e},t]=Pe(ko),n=g.useCallback(async s=>{const o=`Error uploading payroll file to charge ID [${s.chargeId}]`,a=`${bc}-${s.chargeId}`;k.loading("Uploading payroll file",{id:a});try{const i=await t(s),c=Ae(i,o,a,"insertSalaryRecordsFromFile");if(c)return k.success("Success",{id:a,description:"Payroll file added"}),c.insertSalaryRecordsFromFile}catch(i){console.error(`${o}: ${i}`),k.error("Error",{id:a,description:o,duration:1e5,closeButton:!0})}return!1},[t]);return{fetching:e,uploadPayrollFile:n}},Dc=({chargeId:e,onDone:t})=>{const{fetching:n,uploadPayrollFile:s}=Cc(),[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(ki,{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 Sc=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=wc(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 wc(e){var t=e.name,n=t&&t.lastIndexOf(".")!==-1;if(n&&!e.type){var s=t.split(".").pop().toLowerCase(),o=Sc.get(s);o&&Object.defineProperty(e,"type",{value:o,writable:!1,configurable:!1,enumerable:!0})}return e}var _c=[".DS_Store","Thumbs.db"];function Ic(e){return nt(this,void 0,void 0,function(){return rt(this,function(t){return Mt(e)&&Ec(e.dataTransfer)?[2,Nc(e.dataTransfer,e.type)]:Oc(e)?[2,Pc(e)]:Array.isArray(e)&&e.every(function(n){return"getFile"in n&&typeof n.getFile=="function"})?[2,Ac(e)]:[2,[]]})})}function Ec(e){return Mt(e)}function Oc(e){return Mt(e)&&Mt(e.target)}function Mt(e){return typeof e=="object"&&e!==null}function Pc(e){return dn(e.target.files).map(function(t){return bt(t)})}function Ac(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 Nc(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(Tc))]):[3,2];case 1:return s=o.sent(),[2,ar(Ls(s))];case 2:return[2,ar(dn(e.files).map(function(a){return bt(a)}))]}})})}function ar(e){return e.filter(function(t){return _c.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 Tc(e){if(typeof e.webkitGetAsEntry!="function")return ir(e);var t=e.webkitGetAsEntry();return t&&t.isDirectory?Bs(t):ir(e)}function Ls(e){return e.reduce(function(t,n){return Mn(Mn([],zn(t),!1),zn(Array.isArray(n)?Ls(n):[n]),!1)},[])}function ir(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 $c(e){return nt(this,void 0,void 0,function(){return rt(this,function(t){return[2,e.isDirectory?Bs(e):kc(e)]})})}function Bs(e){var t=e.createReader();return new Promise(function(n,s){var o=[];function a(){var i=this;t.readEntries(function(c){return nt(i,void 0,void 0,function(){var l,d,x;return rt(this,function(p){switch(p.label){case 0:if(c.length)return[3,5];p.label=1;case 1:return p.trys.push([1,3,,4]),[4,Promise.all(o)];case 2:return l=p.sent(),n(l),[3,4];case 3:return d=p.sent(),s(d),[3,4];case 4:return[3,6];case 5:x=Promise.all(c.map($c)),o.push(x),a(),p.label=6;case 6:return[2]}})})},function(c){s(c)})}a()})}function kc(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={},cr;function Fc(){return cr||(cr=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 c=i.trim().toLowerCase();return c.charAt(0)==="."?s.toLowerCase().endsWith(c):c.endsWith("/*")?a===c.replace(/\/.*$/,""):o===c})}return!0}),_t}var Rc=Fc();const Mc=Fo(Rc);function lr(e){return Bc(e)||Lc(e)||Us(e)||zc()}function zc(){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 Lc(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function Bc(e){if(Array.isArray(e))return un(e)}function dr(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 ur(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?dr(Object(n),!0).forEach(function(s){Vs(e,s,n[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):dr(Object(n)).forEach(function(s){Object.defineProperty(e,s,Object.getOwnPropertyDescriptor(n,s))})}return e}function Vs(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 Hc(e)||Uc(e,t)||Us(e,t)||Vc()}function Vc(){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 Us(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 Uc(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,c;try{for(n=n.call(e);!(o=(i=n.next()).done)&&(s.push(i.value),!(t&&s.length===t));o=!0);}catch(l){a=!0,c=l}finally{try{!o&&n.return!=null&&n.return()}finally{if(a)throw c}}return s}}function Hc(e){if(Array.isArray(e))return e}var Kc="file-invalid-type",Gc="file-too-large",qc="file-too-small",Wc="too-many-files",Yc=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:Kc,message:"File type must be ".concat(n)}},fr=function(t){return{code:Gc,message:"File is larger than ".concat(t," ").concat(t===1?"byte":"bytes")}},pr=function(t){return{code:qc,message:"File is smaller than ".concat(t," ").concat(t===1?"byte":"bytes")}},Qc={code:Wc,message:"Too many files"};function Hs(e,t){var n=e.type==="application/x-moz-file"||Mc(e,t);return[n,n?null:Yc(t)]}function Ks(e,t,n){if(We(e.size))if(We(t)&&We(n)){if(e.size>n)return[!1,fr(n)];if(e.size<t)return[!1,pr(t)]}else{if(We(t)&&e.size<t)return[!1,pr(t)];if(We(n)&&e.size>n)return[!1,fr(n)]}return[!0,null]}function We(e){return e!=null}function Jc(e){var t=e.files,n=e.accept,s=e.minSize,o=e.maxSize,a=e.multiple,i=e.maxFiles,c=e.validator;return!a&&t.length>1||a&&i>=1&&t.length>i?!1:t.every(function(l){var d=Hs(l,n),x=ht(d,1),p=x[0],m=Ks(l,s,o),y=ht(m,1),f=y[0],u=c?c(l):null;return p&&f&&!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 gr(e){e.preventDefault()}function Xc(e){return e.indexOf("MSIE")!==-1||e.indexOf("Trident/")!==-1}function Zc(e){return e.indexOf("Edge/")!==-1}function el(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:window.navigator.userAgent;return Xc(e)||Zc(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(c){return!zt(s)&&c&&c.apply(void 0,[s].concat(a)),zt(s)})}}function tl(){return"showOpenFilePicker"in window}function nl(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 Gs(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(qs))&&(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 ur(ur({},n),{},Vs({},a,i))},{});return[{description:"Files",accept:t}]}return e}function rl(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(lr(t),[o],lr(a))},[]).filter(function(t){return Gs(t)||qs(t)}).join(",")}function sl(e){return e instanceof DOMException&&(e.name==="AbortError"||e.code===e.ABORT_ERR)}function ol(e){return e instanceof DOMException&&(e.name==="SecurityError"||e.code===e.SECURITY_ERR)}function Gs(e){return e==="audio/*"||e==="video/*"||e==="image/*"||e==="text/*"||/\w+\/[-+.\w]+/g.test(e)}function qs(e){return/^.*\.[\w]+$/.test(e)}var al=["children"],il=["open"],cl=["refKey","role","onKeyDown","onFocus","onBlur","onClick","onDragEnter","onDragOver","onDragLeave","onDrop"],ll=["refKey","onChange","onClick"];function dl(e){return pl(e)||fl(e)||Ws(e)||ul()}function ul(){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 fl(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function pl(e){if(Array.isArray(e))return fn(e)}function en(e,t){return hl(e)||ml(e,t)||Ws(e,t)||gl()}function gl(){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 Ws(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 ml(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,c;try{for(n=n.call(e);!(o=(i=n.next()).done)&&(s.push(i.value),!(t&&s.length===t));o=!0);}catch(l){a=!0,c=l}finally{try{!o&&n.return!=null&&n.return()}finally{if(a)throw c}}return s}}function hl(e){if(Array.isArray(e))return e}function mr(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?mr(Object(n),!0).forEach(function(s){pn(e,s,n[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):mr(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=xl(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 xl(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,al),o=Qs(s),a=o.open,i=Lt(o,il);return g.useImperativeHandle(t,function(){return{open:a}},[a]),N.createElement(g.Fragment,null,n(J(J({},i),{},{open:a})))});wn.displayName="Dropzone";var Ys={disabled:!1,getFilesFromEvent:Ic,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=Ys;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 Qs(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t=J(J({},Ys),e),n=t.accept,s=t.disabled,o=t.getFilesFromEvent,a=t.maxSize,i=t.minSize,c=t.multiple,l=t.maxFiles,d=t.onDragEnter,x=t.onDragLeave,p=t.onDragOver,m=t.onDrop,y=t.onDropAccepted,f=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,F=g.useMemo(function(){return rl(n)},[n]),T=g.useMemo(function(){return nl(n)},[n]),G=g.useMemo(function(){return typeof v=="function"?v:hr},[v]),Y=g.useMemo(function(){return typeof u=="function"?u:hr},[u]),R=g.useRef(null),z=g.useRef(null),le=g.useReducer(yl,gn),ie=en(le,2),M=ie[0],L=ie[1],he=M.isFocused,de=M.isFileDialogActive,ue=g.useRef(typeof window<"u"&&window.isSecureContext&&h&&tl()),be=function(){!ue.current&&de&&setTimeout(function(){if(z.current){var E=z.current.files;E.length||(L({type:"closeDialog"}),Y())}},300)};g.useEffect(function(){return window.addEventListener("focus",be,!1),function(){window.removeEventListener("focus",be,!1)}},[z,de,Y,ue]);var K=g.useRef([]),xe=function(E){R.current&&R.current.contains(E.target)||(E.preventDefault(),K.current=[])};g.useEffect(function(){return C&&(document.addEventListener("dragover",gr,!1),document.addEventListener("drop",xe,!1)),function(){C&&(document.removeEventListener("dragover",gr),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(dl(K.current),[D.target]),It(D)&&Promise.resolve(o(D)).then(function(E){if(!(zt(D)&&!b)){var Z=E.length,se=Z>0&&Jc({files:E,accept:F,minSize:i,maxSize:a,multiple:c,maxFiles:l,validator:A}),me=Z>0&&!se;L({isDragAccept:se,isDragReject:me,isDragActive:!0,type:"setDraggedFiles"}),d&&d(D)}}).catch(function(E){return ae(E)})},[o,d,ae,b,F,i,a,c,l,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&&p&&p(D),!1},[p,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)&&(L({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 Fe=Hs(me,F),Ce=en(Fe,2),Ke=Ce[0],Ge=Ce[1],Me=Ks(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})})}}),(!c&&Z.length>1||c&&l>=1&&Z.length>l)&&(Z.forEach(function(me){se.push({file:me,errors:[Qc]})}),Z.splice(0)),L({acceptedFiles:Z,fileRejections:se,type:"setFiles"}),m&&m(Z,se,E),se.length>0&&f&&f(se,E),Z.length>0&&y&&y(Z,E)},[L,c,F,i,a,l,m,y,f,A]),U=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)}),L({type:"reset"})},[o,te,ae,b]),S=g.useCallback(function(){if(ue.current){L({type:"openDialog"}),G();var D={multiple:c,types:T};window.showOpenFilePicker(D).then(function(E){return o(E)}).then(function(E){te(E,null),L({type:"closeDialog"})}).catch(function(E){sl(E)?(Y(E),L({type:"closeDialog"})):ol(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&&(L({type:"openDialog"}),G(),z.current.value=null,z.current.click())},[L,G,Y,h,te,ae,T,c]),B=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(){L({type:"focus"})},[]),ne=g.useCallback(function(){L({type:"blur"})},[]),pe=g.useCallback(function(){I||(el()?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,Fe=D.onFocus,Ce=D.onBlur,Ke=D.onClick,Ge=D.onDragEnter,Me=D.onDragOver,Ze=D.onDragLeave,at=D.onDrop,it=Lt(D,cl);return J(J(pn({onKeyDown:ye(Ne(me,B)),onFocus:ye(Ne(Fe,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,U)),role:typeof se=="string"&&se!==""?se:"presentation"},Z,R),!s&&!O?{tabIndex:0}:{}),it)}},[R,B,q,ne,pe,ee,P,fe,U,O,_,s]),ke=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,Fe=Lt(D,ll),Ce=pn({accept:F,multiple:c,type:"file",style:{display:"none"},onChange:ce(Ne(se,U)),onClick:ce(Ne(me,ke)),tabIndex:-1},Z,z);return J(J({},Ce),Fe)}},[z,n,c,U,s]);return J(J({},M),{},{isFocused:he&&!s,getRootProps:re,getInputProps:ot,rootRef:R,inputRef:z,open:ce(S)})}function yl(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 hr(){}const[vl,jl]=Hr("Dropzone component was not found in tree");var xr=Object.getOwnPropertySymbols,bl=Object.prototype.hasOwnProperty,Cl=Object.prototype.propertyIsEnumerable,Dl=(e,t)=>{var n={};for(var s in e)bl.call(e,s)&&t.indexOf(s)<0&&(n[s]=e[s]);if(e!=null&&xr)for(var s of xr(e))t.indexOf(s)<0&&Cl.call(e,s)&&(n[s]=e[s]);return n};function _n(e){const t=n=>{const s=Ue(`Dropzone${Gn(e)}`,{},n),{children:o}=s,a=Dl(s,["children"]),i=jl(),c=Ro(o)?o:N.createElement("span",null,o);return i[e]?g.cloneElement(c,a):null};return t.displayName=`@mantine/dropzone/${Gn(e)}`,t}const Sl=_n("accept"),wl=_n("reject"),_l=_n("idle");var Il=Object.defineProperty,El=Object.defineProperties,Ol=Object.getOwnPropertyDescriptors,yr=Object.getOwnPropertySymbols,Pl=Object.prototype.hasOwnProperty,Al=Object.prototype.propertyIsEnumerable,vr=(e,t,n)=>t in e?Il(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,jr=(e,t)=>{for(var n in t||(t={}))Pl.call(t,n)&&vr(e,n,t[n]);if(yr)for(var n of yr(t))Al.call(t,n)&&vr(e,n,t[n]);return e},Nl=(e,t)=>El(e,Ol(t)),Tl=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:Nl(jr(jr({},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"}}}),$l=Object.defineProperty,kl=Object.defineProperties,Fl=Object.getOwnPropertyDescriptors,Bt=Object.getOwnPropertySymbols,Js=Object.prototype.hasOwnProperty,Xs=Object.prototype.propertyIsEnumerable,br=(e,t,n)=>t in e?$l(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,dt=(e,t)=>{for(var n in t||(t={}))Js.call(t,n)&&br(e,n,t[n]);if(Bt)for(var n of Bt(t))Xs.call(t,n)&&br(e,n,t[n]);return e},tn=(e,t)=>kl(e,Fl(t)),Rl=(e,t)=>{var n={};for(var s in e)Js.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&&Xs.call(e,s)&&(n[s]=e[s]);return n};const Ml={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",Ml,e),{className:n,padding:s,radius:o,disabled:a,classNames:i,styles:c,loading:l,multiple:d,maxSize:x,accept:p,children:m,onDropAny:y,onDrop:f,onReject:u,openRef:v,name:h,unstyled:j,maxFiles:C,autoFocus:I,activateOnClick:O,activateOnDrag:_,dragEventsBubbling:b,activateOnKeyboard:w,onDragEnter:A,onDragLeave:F,onDragOver:T,onFileDialogCancel:G,onFileDialogOpen:Y,preventDropOnDocument:R,useFsAccessApi:z,getFilesFromEvent:le,validator:ie,variant:M}=t,L=Rl(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}=Tl({radius:o,padding:s},{name:"Dropzone",classNames:i,styles:c,unstyled:j,variant:M}),{getRootProps:ue,getInputProps:be,isDragAccept:K,isDragReject:xe,open:ae}=Qs(dt({onDrop:y,onDropAccepted:f,onDropRejected:u,disabled:a||l,accept:Array.isArray(p)?p.reduce((P,fe)=>tn(dt({},P),{[fe]:[]}),{}):p,multiple:d,maxSize:x,maxFiles:C,autoFocus:I,noClick:!O,noDrag:!_,noDragEventsBubbling:!b,noKeyboard:!w,onDragEnter:A,onDragLeave:F,onDragOver:T,onFileDialogCancel:G,onFileDialogOpen:Y,preventDropOnDocument:R,useFsAccessApi:z,validator:ie},le?{getFilesFromEvent:le}:null));Lr(v,ae);const ee=!K&&!xe;return N.createElement(vl,{value:{accept:K,reject:xe,idle:ee}},N.createElement(He,tn(dt(dt({},L),ue()),{"data-accept":K||void 0,"data-reject":xe||void 0,"data-idle":ee||void 0,"data-loading":l||void 0,className:de(he.root,n)}),N.createElement(ks,{visible:l,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=Sl;st.Reject=wl;st.Idle=_l;const Zs=st;var zl=Object.defineProperty,Ll=Object.defineProperties,Bl=Object.getOwnPropertyDescriptors,Cr=Object.getOwnPropertySymbols,Vl=Object.prototype.hasOwnProperty,Ul=Object.prototype.propertyIsEnumerable,Dr=(e,t,n)=>t in e?zl(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Hl=(e,t)=>{for(var n in t||(t={}))Vl.call(t,n)&&Dr(e,n,t[n]);if(Cr)for(var n of Cr(t))Ul.call(t,n)&&Dr(e,n,t[n]);return e},Kl=(e,t)=>Ll(e,Bl(t)),Gl=Ve(e=>({wrapper:Kl(Hl({},e.fn.cover(0)),{position:"fixed",backgroundColor:e.colorScheme==="dark"?e.colors.dark[7]:e.white,display:"flex",padding:e.spacing.xs,transition:"opacity 100ms ease"}),dropzone:{flex:1}})),ql=Object.defineProperty,Wl=Object.defineProperties,Yl=Object.getOwnPropertyDescriptors,Vt=Object.getOwnPropertySymbols,eo=Object.prototype.hasOwnProperty,to=Object.prototype.propertyIsEnumerable,Sr=(e,t,n)=>t in e?ql(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,nn=(e,t)=>{for(var n in t||(t={}))eo.call(t,n)&&Sr(e,n,t[n]);if(Vt)for(var n of Vt(t))to.call(t,n)&&Sr(e,n,t[n]);return e},rn=(e,t)=>Wl(e,Yl(t)),Ql=(e,t)=>{var n={};for(var s in e)eo.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&&to.call(e,s)&&(n[s]=e[s]);return n};const Jl={padding:"md",loading:!1,multiple:!0,maxSize:1/0,autoFocus:!1,activateOnClick:!0,activateOnDrag:!0,dragEventsBubbling:!0,activateOnKeyboard:!0,active:!0,zIndex:Br("max"),withinPortal:!0};function no(e){const t=Ue("DropzoneFullScreen",Jl,e),{classNames:n,styles:s,sx:o,className:a,style:i,unstyled:c,active:l,onDrop:d,onReject:x,zIndex:p,withinPortal:m,portalProps:y}=t,f=Ql(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}=Gl(null,{name:"DropzoneFullScreen",classNames:n,styles:s,unstyled:c}),_=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(l)return document.addEventListener("dragenter",_,!1),document.addEventListener("dragleave",b,!1),()=>{document.removeEventListener("dragenter",_,!1),document.removeEventListener("dragleave",b,!1)}},[l]),N.createElement(Mo,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:p})},N.createElement(st,rn(nn({},f),{classNames:n,styles:s,unstyled:c,className:I.dropzone,onDrop:w=>{d?.(w),C()},onReject:w=>{x?.(w),C()}}))))}no.displayName="@mantine/dropzone/DropzoneFullScreen";Zs.FullScreen=no;const Xl=Zs,Zl=({children:e,chargeId:t})=>{const{uploading:n,uploadMultipleDocuments:s}=zo();function o(a){k.error("Error",{description:a,duration:5e3})}return r.jsx(Xl,{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})},ro=({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)})})},ed=({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(Lo,{asChild:!0,children:r.jsx(Le,{label:"Edit Misc Expense",children:r.jsx(Q,{variant:"ghost",size:"icon",className:"size-7.5",children:r.jsx(Kr,{className:"size-5"})})})}),r.jsx(vn,{className:"sm:max-w-[425px]",children:r.jsx(jc,{onDone:o,data:t})})]})},td="batchUpdateCharges",nd=()=>{const[{fetching:e},t]=Pe(Bo),n=g.useCallback(async s=>{const o=Array.isArray(s.chargeIds)?s.chargeIds:[s.chargeIds],a=`Error updating charge IDs [${o.join(", ")}]`,i=`${td}-${o[0]}`;k.loading("Updating charge",{id:i});try{const c=await t(s),l=Ae(c,a,i,"batchUpdateCharges");if(l)return k.success("Success",{id:i,description:`${o.length} charge${o.length>1?"s":""} updated`}),l.batchUpdateCharges.charges}catch(c){console.error(`${a}: ${c}`),k.error("Error",{id:i,description:a,duration:1e5,closeButton:!0})}},[t]);return{fetching:e,batchUpdateCharges:n}},rd=[{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 sd({data:e,tagIds:t,description:n,onOpenChange:s,title:o="Similar Charges"}){const[a,i]=N.useState([]),[c,l]=N.useState({}),d=g.useMemo(()=>e.map(f=>H(Vo,f)),[e]),x=g.useMemo(()=>d.map(u=>({id:u.id,chargeType:Ds(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 p=Gr({data:x,columns:rd,onSortingChange:i,getCoreRowModel:Wr(),getSortedRowModel:qr(),onRowSelectionChange:l,state:{sorting:a,rowSelection:c}}),{batchUpdateCharges:m}=nd(),y=g.useCallback(async()=>{const f=p.getSelectedRowModel().rows.map(u=>u.original.id);await m({chargeIds:f,fields:{...t?{tags:t}:{},...n?{userDescription:n}:{}}}),s(!1)},[m,s,p,t,n]);return g.useEffect(()=>{e.length===0&&s(!1)},[e.length,s]),e.length?r.jsxs(r.Fragment,{children:[r.jsxs(Uo,{className:"flex flex-row items-center justify-between",children:[r.jsx(Ho,{children:o}),r.jsx(Q,{onClick:y,children:"Approve selected"})]}),r.jsx(Yr,{children:r.jsxs(jn,{children:[r.jsx(bn,{children:p.getHeaderGroups().map(f=>r.jsx(Ye,{children:f.headers.map(u=>r.jsx(Te,{children:u.isPlaceholder?null:Pt(u.column.columnDef.header,u.getContext())},u.id))},f.id))}),r.jsx(Cn,{children:p.getRowModel().rows.map(f=>r.jsx(Ye,{"data-state":f.getIsSelected()&&"selected",children:f.getVisibleCells().map(u=>r.jsx(Ie,{children:Pt(u.column.columnDef.cell,u.getContext())},u.id))},f.id))})]})})]}):null}function so({chargeId:e,tagIds:t,description:n,open:s,onOpenChange:o,onClose:a,showChargesWithExistingSuggestions:i=!1}){const[{data:c,fetching:l},d]=Xe({pause:!0,query:Ko,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)&&!c&&d()},[s,t,n,d,c]);const x=g.useCallback(m=>{o(m),s&&!m&&a?.()},[o,a,s]);g.useEffect(()=>{s&&!l&&c?.similarCharges.length===0&&a?.()},[s,l,c,a]);const p=g.useMemo(()=>s&&(!!t||!!n)&&c&&c?.similarCharges.length>0,[s,t,n,c]);return r.jsx(yn,{open:p,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(Go,{fallback:r.jsx("div",{children:"Error fetching similar charges"}),children:l?r.jsx(qo,{}):t||n?r.jsx(sd,{data:c?.similarCharges??[],tagIds:t,description:n,onOpenChange:x}):null})})})}const od="updateChargeAccountantApproval",ad=()=>{const[{fetching:e},t]=Pe(Wo),n=g.useCallback(async s=>{const o=`Error toggling accountant approval to ledger record ID [${s.chargeId}]`,a=`${od}-${s.chargeId}`;k.loading("Updating approval status",{id:a});try{const i=await t(s),c=Ae(i,o,a,"updateChargeAccountantApproval");if(c)return k.success("Success",{id:a,description:"Accountant approval was updated"}),c.updateChargeAccountantApproval}catch(i){console.error(`${o}: ${i}`),k.error("Error",{id:a,description:o,duration:1e5,closeButton:!0})}},[t]);return{fetching:e,updateChargeAccountantApproval:n}};function id({data:e,onChange:t}){const n=H(Qo,e),[s,o]=g.useState(n.accountantApproval),{updateChargeAccountantApproval:a}=ad();return g.useEffect(()=>{s==null&&n.accountantApproval!=null&&o(n.accountantApproval)},[s,n.accountantApproval]),r.jsx("td",{children:r.jsx(Yo,{value:s,onChange:i=>a({chargeId:n.id,status:i}).then(t)})})}const cd=({data:e})=>{const t=H(Jo,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})})})})},ld=({data:e})=>{const t=H(Qr,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",{})},dd=({data:e})=>{const{counterparty:t,validationData:n,__typename:s}=H(Jr,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:c}=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&&c&&r.jsx(At,{to:mt.BUSINESSES.DETAIL(c),target:"_blank",rel:"noreferrer",onClick:l=>l.stopPropagation(),className:"inline-flex items-center font-semibold",children:i}),a&&i]})})})},ud=({data:e})=>{const t=H(Xo,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")})})},fd=({data:e,onChange:t})=>{const[n,s]=g.useState(!1),o=H(Zo,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:c,id:l}=o,d=g.useMemo(()=>c&&c?.trim()!==""?c:o.missingInfoSuggestions?.description?o.missingInfoSuggestions.description:"Missing",[c,o.missingInfoSuggestions?.description]),{updateCharge:x,fetching:p}=zs(),m=g.useCallback(async y=>{y!==void 0&&(await x({chargeId:l,fields:{userDescription:y}}),s(!0))},[l,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(Xr,{onClick:y=>{y.stopPropagation(),m(o.missingInfoSuggestions.description)},disabled:p})]}),r.jsx(so,{chargeId:l,description:o.missingInfoSuggestions?.description??void 0,open:n,onOpenChange:s,onClose:t})]})},pd=({data:e})=>{const t=H(ea,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]),c=g.useMemo(()=>{switch(a){case"FinancialCharge":return!1;default:return!0}},[a]),l=g.useMemo(()=>c&&s?.missingInfo?.includes(ze.Transactions),[c,s?.missingInfo]),d=g.useMemo(()=>i&&s?.missingInfo?.includes(ze.Documents),[i,s?.missingInfo]),x=g.useMemo(()=>!n?.invalidLedger,[n?.invalidLedger]),p=g.useMemo(()=>n?.invalidLedger,[n?.invalidLedger]),m=g.useMemo(()=>{const y=[];return(l||n?.transactionsCount||c)&&y.push({extraClassName:n?.transactionsCount||!c?void 0:"bg-yellow-400",content:r.jsx(Re,{inline:!0,size:12,disabled:!l,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:p==="VALID",color:p==="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,c,l,d,s?.missingInfo,p,x]);return r.jsx("td",{children:r.jsx(Zl,{chargeId:o,children:r.jsx(ro,{items:m})})})},gd=({data:e,onChange:t})=>{const{tags:n,id:s,validationData:o,missingInfoSuggestions:a}=H(Zr,e),{updateCharge:i,fetching:c}=zs(),[l,d]=g.useState(n??[]),[x,p]=g.useState(!1),m=o?.missingInfo?.includes(ze.Tags),y=m&&!!a?.tags?.length;g.useEffect(()=>{n?.length&&!l.length&&d(n)},[n,l.length]),g.useEffect(()=>{l.length===0&&y&&d(a?.tags??[])},[l.length,y,a?.tags]);const f=g.useCallback(async u=>{await i({chargeId:s,fields:{tags:u?.map(v=>({id:v.id}))}}),p(!0)},[s,i]);return r.jsxs("td",{children:[r.jsx(Re,{inline:!0,size:12,disabled:!m,color:"red",zIndex:"auto",children:r.jsx(ro,{items:l.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(Xr,{onClick:u=>{u.stopPropagation(),f(a.tags)},disabled:c}),r.jsx(so,{chargeId:s,tagIds:a?.tags?.map(u=>({id:u.id})),open:x,onOpenChange:p,onClose:t})]})},md=({data:e})=>{const{validationData:t,taxCategory:n,__typename:s}=H(es,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",{})},hd=({data:e})=>{const t=H(ta,e),{__typename:n}=t,{text:s,icon:o}=g.useMemo(()=>({text:Ds(n),icon:di(n)}),[n]);return r.jsxs("td",{children:[r.jsx("div",{children:s}),r.jsx(Ms,{radius:"xl",size:"xl",children:o})]})},xd=({data:e})=>{const{vat:t,totalAmount:n,validationData:s,__typename:o}=H(na,e),a=g.useMemo(()=>s?.missingInfo?.includes(ze.Vat),[s?.missingInfo]),i=g.useMemo(()=>!t&&n?.currency===Dn.Ils,[t,n?.currency]),c=g.useMemo(()=>(t?.raw??0)>0&&(n?.raw??0)<0||(t?.raw??0)<0&&(n?.raw??0)>0,[t?.raw,n?.raw]),l=i||c;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:l?"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",{})},yd="insertDepreciationRecord",vd=()=>{const[{fetching:e},t]=Pe(ra),n=g.useCallback(async s=>{const o="Error adding depreciation record",a=yd;k.loading("Adding depreciation record",{id:a});try{const i=await t(s),c=Ae(i,o,a,"insertDepreciationRecord");if(c)return k.success("Success",{id:a,description:"Depreciation record was added"}),c.insertDepreciationRecord}catch(i){console.error(`${o}: ${i}`),k.error("Error",{id:a,description:o,duration:1e5,closeButton:!0})}},[t]);return{fetching:e,addDepreciationRecord:n}};function wr(e){const{chargeId:t,onAdd:n}=e,[s,{close:o,open:a}]=gt(!1);return r.jsxs(r.Fragment,{children:[r.jsx(Le,{label:"Add Depreciation Record",children:r.jsx(Q,{variant:"outline",size:"icon",className:"size-7.5",onClick:i=>{i.stopPropagation(),a()},children:r.jsx(ts,{className:"size-5"})})}),s&&r.jsx(jd,{chargeId:t,opened:s,close:o,onAdd:n})]})}function jd({chargeId:e,opened:t,close:n,onAdd:s}){const{control:o,handleSubmit:a}=xn({defaultValues:{chargeId:e}}),[i,c]=g.useState(!1),[{data:l,fetching:d}]=Xe({query:ns}),{addDepreciationRecord:x,fetching:p}=vd(),m=f=>{x({fields:f}).then(()=>{s?.(),n()})},y=l?.depreciationCategories?.map(f=>({value:f.id,label:f.name}))??[];return g.useEffect(()=>{c(!!(d||p))},[d,p]),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:rs,message:"Date must be im format yyyy-mm-dd"}},render:({field:{value:f,...u}})=>{const v=f?new Date(f):void 0;return r.jsx(ss,{...u,onChange:h=>{const j=h?typeof h=="string"?h:Be(h,"yyyy-MM-dd"):void 0;j!==f&&u.onChange(j)},value:v,label:"Activation Date",popoverProps:{withinPortal:!0}})}}),r.jsx($e,{name:"amount",control:o,render:({field:f,fieldState:u})=>r.jsx($e,{name:"currency",control:o,render:({field:v,fieldState:h})=>r.jsx(os,{...f,value:f.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:f,fieldState:u})=>r.jsx(Nt,{...f,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:f,fieldState:u})=>r.jsx(Nt,{...f,data:oo,value:f.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"})})]})}),(p||i)&&r.jsx(Vr,{blur:1,center:!0,children:r.jsx(jt,{})})]})}const bd="updateDepreciationRecord",Cd=()=>{const[{fetching:e},t]=Pe(sa),n=g.useCallback(async s=>{const o="Error updating depreciation record",a=bd;k.loading("Updating depreciation record",{id:a});try{const i=await t(s),c=Ae(i,o,a,"updateDepreciationRecord");if(c)return k.success("Success",{id:a,description:"Depreciation record was updated"}),c.updateDepreciationRecord}catch(i){console.error(`${o}: ${i}`),k.error("Error",{id:a,description:o,duration:1e5,closeButton:!0})}},[t]);return{fetching:e,updateDepreciationRecord:n}},Dd="deleteDepreciationRecord",Sd=()=>{const[{fetching:e},t]=Pe(oa),n=g.useCallback(async s=>{const o="Error deleting depreciation record",a=`${Dd}-${s.depreciationRecordId}`;k.loading("Deleting depreciation record",{id:a});try{const i=await t(s),c=Ae(i,o,a);if(c)return k.success("Success",{id:a,description:"Depreciation record was deleted"}),c.deleteDepreciationRecord}catch(i){console.error(`${o}: ${i}`),k.error("Error",{id:a,description:o,duration:1e5,closeButton:!0})}},[t]);return{fetching:e,deleteDepreciationRecord:n}};function wd(e){const{fetching:t,deleteDepreciationRecord:n}=Sd(),s=g.useCallback(()=>{n({depreciationRecordId:e.depreciationRecordId}).then(()=>{e.onDelete?.()})},[e,n]);return r.jsx(Gt,{onConfirm:s,title:"Are you sure you want to delete the depreciation record?",children:r.jsx(Le,{label:"Remove Depreciation",children:r.jsx(Q,{variant:"outline",size:"icon",className:"size-7.5 text-red-500",disabled:t,children:r.jsx(Sn,{className:"size-5"})})})})}const _d=({data:e,onChange:t})=>{const n=H(ia,e),[s,o]=g.useState(!1),[{data:a,fetching:i},c]=Xe({query:ns,pause:!0}),{control:l,handleSubmit:d,formState:{dirtyFields:x}}=xn({defaultValues:{id:n.id}}),{updateDepreciationRecord:p,fetching:m}=Cd(),y=u=>{const v=ca(u,x);v&&Object.keys(v).length>0&&p({fields:{...u,id:n.id}}).then(()=>{t?.(),o(!1)})},f=a?.depreciationCategories.map(u=>({value:u.id,label:u.name}));return g.useEffect(()=>{s&&!a&&c()},[s,a,c]),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:l,render:({field:u,fieldState:v})=>r.jsx($e,{name:"currency",control:l,render:({field:h,fieldState:j})=>r.jsx(os,{...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:l,defaultValue:n.activationDate,rules:{pattern:{value:rs,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(ss,{...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:l,render:({field:u,fieldState:v})=>r.jsx(Nt,{...u,form:`form ${n.id}`,disabled:i,data:f??[],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:l,render:({field:u,fieldState:v})=>r.jsx(Nt,{...u,form:`form ${n.id}`,data:oo,value:u.value,label:"Type",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:v.error?.message,withinPortal:!0})}):r.jsx("div",{children:n.type})}),r.jsxs("td",{children:[r.jsx(Le,{label:"Edit",children:r.jsx(Q,{disabled:m||i,variant:s?"default":"outline",size:"icon",className:"size-7.5",onClick:u=>{u.stopPropagation(),o(v=>!v)},children:r.jsx(Kr,{className:"size-5"})})}),s&&r.jsx(Le,{label:"Confirm Changes",children:r.jsx(Q,{type:"submit",form:`form ${n.id}`,variant:"outline",size:"icon",className:"size-7.5 text-green-500",children:r.jsx(aa,{className:"size-5"})})}),r.jsx(wd,{depreciationRecordId:n.id,onDelete:t})]})]},n.id)},Id=({chargeId:e,onChange:t})=>{const[{data:n,fetching:s}]=Xe({query:la,variables:{chargeId:e}});return!s&&!n?.depreciationRecordsByCharge.length?r.jsx(wr,{chargeId:e,onAdd:t}):s?r.jsx(as,{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(bs,{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(_d,{data:o,onChange:t},o.id)),r.jsx("tr",{children:r.jsx("td",{colSpan:5,children:r.jsx(wr,{chargeId:e,onAdd:t})})})]})]})})},oo=Object.entries(da).map(([e,t])=>({value:t,label:e}));function Ed({chargeId:e,chargeType:t,setInsertDocument:n,setMatchDocuments:s,onChange:o,isIncome:a}){const{deleteCharge:i}=fc(),[c,l]=g.useState(!1),[d,{open:x,close:p}]=gt(!1),[m,y]=g.useState(!1),[f,{open:u,close:v}]=gt(!1),[h,j]=g.useState(!1),[C,I]=g.useState(!1);function O(){i({chargeId:e}),o?.()}function _(){l(!1)}return r.jsxs(r.Fragment,{children:[r.jsxs(oe,{shadow:"md",width:200,opened:c,children:[r.jsx(oe.Target,{children:r.jsx(La,{opened:c,onClick:b=>{b.stopPropagation(),l(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(Kn,{size:14}),onClick:b=>{b.stopPropagation(),I(!0),_()},children:"Upload Documents"}),")",s&&r.jsx(oe.Item,{icon:r.jsx(ua,{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(Ua,{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(Kn,{size:14}),onClick:b=>{b.stopPropagation(),_(),u()},children:"Payroll file upload"})]})]})]}),r.jsx(ft,{withinPortal:!0,size:"xl",centered:!0,opened:d,onClose:p,title:"Depreciation",onClick:b=>b.stopPropagation(),children:r.jsx(Id,{chargeId:e,onChange:()=>{p(),o?.()}})}),r.jsx(yn,{open:m,onOpenChange:y,children:r.jsx(vn,{className:"sm:max-w-[425px]",onClick:b=>b.stopPropagation(),children:r.jsx(Oa,{onDone:()=>{y(!1),o?.()},chargeId:e})})}),r.jsx(ft,{centered:!0,opened:f,onClose:v,title:"Upload Payroll File",onClick:b=>b.stopPropagation(),children:r.jsx(Dc,{onDone:()=>{v(),o?.()},chargeId:e})}),r.jsx(fa,{open:C,onOpenChange:I,onChange:o,chargeId:e}),r.jsx(cn,{chargeId:e,open:h,setOpen:j,onDone:()=>o?.()})]})}function Od(e){return Object.prototype.toString.call(e)==="[object Object]"}function _r(e){return Od(e)||Array.isArray(e)}function Pd(){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 c=e[i],l=t[i];return typeof c=="function"?`${c}`==`${l}`:!_r(c)||!_r(l)?c===l:In(c,l)})}function Ir(e){return e.concat().sort((t,n)=>t.name>n.name?1:-1).map(t=>t.options)}function Ad(e,t){if(e.length!==t.length)return!1;const n=Ir(e),s=Ir(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 Er(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 Nd(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 Td(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 Or(e,t=0){return Array.from(Array(e),(n,s)=>t+s)}function yt(e){return Object.keys(e)}function ao(e,t){return[e,t].reduce((n,s)=>(yt(s).forEach(o=>{const a=n[o],i=s[o],c=Er(a)&&Er(i);n[o]=c?ao(a,i):i}),n),{})}function hn(e,t){return typeof t.MouseEvent<"u"&&e instanceof t.MouseEvent}function $d(e,t){const n={start:s,center:o,end:a};function s(){return 0}function o(l){return a(l)/2}function a(l){return t-l}function i(l,d){return mn(e)?n[e](l):e(t,l,d)}return{measure:i}}function vt(){let e=[];function t(o,a,i,c={passive:!0}){let l;if("addEventListener"in o)o.addEventListener(a,i,c),l=()=>o.removeEventListener(a,i,c);else{const d=o;d.addListener(i),l=()=>d.removeListener(i)}return e.push(l),s}function n(){e=e.filter(o=>o())}const s={add:t,clear:n};return s}function kd(e,t,n,s){const o=vt(),a=1e3/60;let i=null,c=0,l=0;function d(){o.add(e,"visibilitychange",()=>{e.hidden&&f()})}function x(){y(),o.clear()}function p(v){if(!l)return;i||(i=v,n(),n());const h=v-i;for(i=v,c+=h;c>=a;)n(),c-=a;const j=c/a;s(j),l&&(l=t.requestAnimationFrame(p))}function m(){l||(l=t.requestAnimationFrame(p))}function y(){t.cancelAnimationFrame(l),i=null,c=0,l=0}function f(){i=null,c=0}return{init:d,destroy:x,start:m,stop:y,update:n,render:s}}function Fd(e,t){const n=t==="rtl",s=e==="y",o=s?"y":"x",a=s?"x":"y",i=!s&&n?-1:1,c=x(),l=p();function d(f){const{height:u,width:v}=f;return s?u:v}function x(){return s?"top":n?"right":"left"}function p(){return s?"bottom":n?"left":"right"}function m(f){return f*i}return{scroll:o,cross:a,startEdge:c,endEdge:l,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 c(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:c}}function io(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 c(){return a}function l(m){return a=i(m),p}function d(m){return x().set(c()+m)}function x(){return io(e,c(),n)}const p={get:c,set:l,add:d,clone:x};return p}function Rd(e,t,n,s,o,a,i,c,l,d,x,p,m,y,f,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)),F={mouse:300,touch:400},T={mouse:500,touch:600},G=f?43:25;let Y=!1,R=0,z=0,le=!1,ie=!1,M=!1,L=!1;function he(S){if(!j)return;function B(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",B).add(q,"mousedown",B).add(q,"touchcancel",P).add(q,"contextmenu",P).add(q,"click",fe,!0)}function de(){b.clear(),w.clear()}function ue(){const S=L?n:t;w.add(S,"touchmove",ee,_).add(S,"touchend",P).add(S,"mousemove",ee,_).add(S,"mouseup",P)}function be(S){const B=S.nodeName||"";return O.includes(B)}function K(){return(f?T:F)[L?"mouse":"touch"]}function xe(S,B){const q=p.add(On(S)*-1),ne=x.byDistance(S,!f).distance;return f||X(S)<A?ne:v&&B?ne*.5:x.byIndex(q.get(),0).distance}function ae(S){const B=hn(S,s);L=B,M=f&&B&&!S.buttons&&Y,Y=pt(o.get(),i.get())>=2,!(B&&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&&!L&&(!S.cancelable||(ie=pe>ce,!ie)))return P(S);const ye=a.pointerMove(S);pe>u&&(M=!0),d.useFriction(.3).useDuration(.75),c.start(),o.add(I(ye)),S.preventDefault()}function P(S){const q=x.byDistance(0,!1).index!==p.get(),ne=a.pointerUp(S)*K(),pe=xe(I(ne),q),ce=Nd(ne,pe),ye=G-10*ce,ge=h+ce/50;ie=!1,le=!1,w.clear(),d.useDuration(ye).useFriction(ge),l.distance(pe,!f),L=!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 Md(e,t){let s,o;function a(p){return p.timeStamp}function i(p,m){const f=`client${(m||e.scroll)==="x"?"X":"Y"}`;return(hn(p,t)?p:p.touches[0])[f]}function c(p){return s=p,o=p,i(p)}function l(p){const m=i(p)-i(o),y=a(p)-a(s)>170;return o=p,y&&(s=p),m}function d(p){if(!s||!o)return 0;const m=i(o)-i(s),y=a(p)-a(s),f=a(p)-a(o)>170,u=m/y;return y&&!f&&X(u)>.1?u:0}return{pointerDown:c,pointerMove:l,pointerUp:d,readPoint:i}}function zd(){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 Ld(e){function t(s){return e*(s/100)}return{measure:t}}function Bd(e,t,n,s,o,a,i){const c=[e].concat(s);let l,d,x=[],p=!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(p)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}}}l=new ResizeObserver(j=>{(qt(a)||a(v,j))&&h(j)}),n.requestAnimationFrame(()=>{c.forEach(j=>l.observe(j))})}function f(){p=!0,l&&l.disconnect()}return{init:y,destroy:f}}function Vd(e,t,n,s,o,a){let i=0,c=0,l=o,d=a,x=e.get(),p=0;function m(){const _=s.get()-e.get(),b=!l;let w=0;return b?(i=0,n.set(s),e.set(s),w=_):(n.set(e),i+=_/l,i*=d,x+=i,e.add(i),w=x-p),c=On(w),p=x,O}function y(){const _=s.get()-t.get();return X(_)<.001}function f(){return l}function u(){return c}function v(){return i}function h(){return C(o)}function j(){return I(a)}function C(_){return l=_,O}function I(_){return d=_,O}const O={direction:u,duration:f,velocity:v,seek:m,settled:y,useBaseFriction:j,useBaseDuration:h,useFriction:I,useDuration:C};return O}function Ud(e,t,n,s,o){const a=o.measure(10),i=o.measure(50),c=Je(.1,.99);let l=!1;function d(){return!(l||!e.reachedAny(n.get())||!e.reachedAny(t.get()))}function x(y){if(!d())return;const f=e.reachedMin(t.get())?"min":"max",u=X(e[f]-t.get()),v=n.get()-t.get(),h=c.constrain(u/i);n.subtract(v*h),!y&&X(v)<a&&(n.set(e.constrain(n.get())),s.useDuration(25).useBaseFriction())}function p(y){l=!y}return{shouldConstrain:d,constrain:x,toggleActive:p}}function Hd(e,t,n,s,o){const a=Je(-t+e,0),i=p(),c=x(),l=m();function d(f,u){return pt(f,u)<=1}function x(){const f=i[0],u=Ee(i),v=i.lastIndexOf(f),h=i.indexOf(u)+1;return Je(v,h)}function p(){return n.map((f,u)=>{const{min:v,max:h}=a,j=a.constrain(f),C=!u,I=Pn(n,u);return C?h:I||d(v,j)?v:d(h,j)?h:j}).map(f=>parseFloat(f.toFixed(3)))}function m(){if(t<=e+o)return[a.max];if(s==="keepSnaps")return i;const{min:f,max:u}=c;return i.slice(f,u)}return{snapsContained:l,scrollContainLimit:c}}function Kd(e,t,n){const s=t[0],o=n?s-e:Ee(t);return{limit:Je(o,s)}}function Gd(e,t,n,s){const a=t.min+.1,i=t.max+.1,{reachedMin:c,reachedMax:l}=Je(a,i);function d(m){return m===1?l(n.get()):m===-1?c(n.get()):!1}function x(m){if(!d(m))return;const y=e*(m*-1);s.forEach(f=>f.add(y))}return{loop:x}}function qd(e){const{max:t,length:n}=e;function s(a){const i=a-t;return n?i/-n:0}return{get:s}}function Wd(e,t,n,s,o){const{startEdge:a,endEdge:i}=e,{groupSlides:c}=o,l=p().map(t.measure),d=m(),x=y();function p(){return c(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 c(d).map(u=>u[0]).map((u,v)=>u+l[v])}return{snaps:d,snapsAligned:x}}function Yd(e,t,n,s,o,a){const{groupSlides:i}=o,{min:c,max:l}=s,d=x();function x(){const m=i(a),y=!e||t==="keepSnaps";return n.length===1?[a]:y?m:m.slice(c,l).map((f,u,v)=>{const h=!u,j=Pn(v,u);if(h){const C=Ee(v[0])+1;return Or(C)}if(j){const C=Ct(a)-Ee(v)[0]+1;return Or(C,Ee(v)[0])}return f})}return{slideRegistry:d}}function Qd(e,t,n,s,o){const{reachedAny:a,removeOffset:i,constrain:c}=s;function l(f){return f.concat().sort((u,v)=>X(u)-X(v))[0]}function d(f){const u=e?i(f):c(f),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(f,u){const v=[f,f+n,f-n];if(!e)return f;if(!u)return l(v);const h=v.filter(j=>On(j)===u);return h.length?l(h):Ee(v)-n}function p(f,u){const v=t[f]-o.get(),h=x(v,u);return{index:f,distance:h}}function m(f,u){const v=o.get()+f,{index:h,distance:j}=d(v),C=!e&&a(v);if(!u||C)return{index:h,distance:f};const I=t[h]-j,O=f+x(I,0);return{index:h,distance:O}}return{byDistance:m,byIndex:p,shortcut:x}}function Jd(e,t,n,s,o,a,i){function c(p){const m=p.distance,y=p.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(p.index),i.emit("select"))}function l(p,m){const y=o.byDistance(p,m);c(y)}function d(p,m){const y=t.clone().set(p),f=o.byIndex(y.get(),m);c(f)}return{distance:l,index:d}}function Xd(e,t,n,s,o,a,i,c){const l={passive:!0,capture:!0};let d=0;function x(y){if(!c)return;function f(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",p,!1),t.forEach((u,v)=>{a.add(u,"focus",h=>{(qt(c)||c(y,h))&&f(v)},l)})}function p(y){y.code==="Tab"&&(d=new Date().getTime())}return{init:x}}function ut(e){let t=e;function n(){return t}function s(l){t=i(l)}function o(l){t+=i(l)}function a(l){t-=i(l)}function i(l){return En(l)?l:l.get()}return{get:n,set:s,add:o,subtract:a}}function co(e,t){const n=e.scroll==="x"?i:c,s=t.style;let o=null,a=!1;function i(m){return`translate3d(${m}px,0px,0px)`}function c(m){return`translate3d(0px,${m}px,0px)`}function l(m){if(a)return;const y=Td(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:l,toggleActive:d}}function Zd(e,t,n,s,o,a,i,c,l){const x=xt(o),p=xt(o).reverse(),m=h().concat(j());function y(b,w){return b.reduce((A,F)=>A-o[F],w)}function f(b,w){return b.reduce((A,F)=>y(A,w)>0?A.concat([F]):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 F=u(w);return b.map(T=>{const G=A?0:-n,Y=A?n:0,R=A?"end":"start",z=F[T][R];return{index:T,loopPoint:z,slideLocation:ut(-1),translate:co(e,l[T]),target:()=>c.get()>z?G:Y}})}function h(){const b=i[0],w=f(p,b);return v(w,n,!1)}function j(){const b=t-i[0]-1,w=f(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:F}=b,T=w();T!==F.get()&&(A.to(T),F.set(T))})}function O(){m.forEach(b=>b.translate.clear())}return{canLoop:C,clear:O,loop:I,loopPoints:m}}function eu(e,t,n){let s,o=!1;function a(l){if(!n)return;function d(x){for(const p of x)if(p.type==="childList"){l.reInit(),t.emit("slidesChanged");break}}s=new MutationObserver(x=>{o||(qt(n)||n(l,x))&&d(x)}),s.observe(e,{childList:!0})}function i(){s&&s.disconnect(),o=!0}return{init:a,destroy:i}}function tu(e,t,n,s){const o={};let a=null,i=null,c,l=!1;function d(){c=new IntersectionObserver(f=>{l||(f.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(f=>c.observe(f))}function x(){c&&c.disconnect(),l=!0}function p(f){return yt(o).reduce((u,v)=>{const h=parseInt(v),{isIntersecting:j}=o[h];return(f&&j||!f&&!j)&&u.push(h),u},[])}function m(f=!0){if(f&&a)return a;if(!f&&i)return i;const u=p(f);return f&&(a=u),f||(i=u),u}return{init:d,destroy:x,get:m}}function nu(e,t,n,s,o,a){const{measureSize:i,startEdge:c,endEdge:l}=e,d=n[0]&&o,x=f(),p=u(),m=n.map(i),y=v();function f(){if(!d)return 0;const j=n[0];return X(t[c]-j[c])}function u(){if(!d)return 0;const j=a.getComputedStyle(Ee(s));return parseFloat(j.getPropertyValue(`margin-${l}`))}function v(){return n.map((j,C,I)=>{const O=!C,_=Pn(I,C);return O?m[C]+x:_?m[C]+p:I[C+1][c]-j[c]}).map(X)}return{slideSizes:m,slideSizesWithGaps:y,startGap:x,endGap:p}}function ru(e,t,n,s,o,a,i,c,l){const{startEdge:d,endEdge:x,direction:p}=e,m=En(n);function y(h,j){return xt(h).filter(C=>C%j===0).map(C=>h.slice(C,C+j))}function f(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],F=!s&&_?p(i):0,T=!s&&b?p(c):0,G=X(A-T-(w+F));return I&&G>t+l&&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):f(h)}return{groupSlides:u}}function su(e,t,n,s,o,a,i){const{align:c,axis:l,direction:d,startIndex:x,loop:p,duration:m,dragFree:y,dragThreshold:f,inViewThreshold:u,slidesToScroll:v,skipSnaps:h,containScroll:j,watchResize:C,watchSlides:I,watchDrag:O,watchFocus:_}=a,b=2,w=zd(),A=w.measure(t),F=n.map(w.measure),T=Fd(l,d),G=T.measureSize(A),Y=Ld(G),R=$d(c,G),z=!p&&!!j,le=p||!!j,{slideSizes:ie,slideSizesWithGaps:M,startGap:L,endGap:he}=nu(T,A,F,n,le,o),de=ru(T,G,v,p,A,F,L,he,b),{snaps:ue,snapsAligned:be}=Wd(T,R,A,F,de),K=-Ee(ue)+Ee(M),{snapsContained:xe,scrollContainLimit:ae}=Hd(G,K,be,j,b),ee=z?xe:be,{limit:P}=Kd(K,ee,p),fe=io(Ct(ee),x,p),te=fe.clone(),U=xt(n),S=({dragHandler:Ce,scrollBody:Ke,scrollBounds:Ge,options:{loop:Me}})=>{Me||Ge.constrain(Ce.pointerDown()),Ke.seek()},B=({scrollBody:Ce,translate:Ke,location:Ge,offsetLocation:Me,previousLocation:Ze,scrollLooper:at,slideLooper:it,dragHandler:ct,animation:lt,eventHandler:Dt,scrollBounds:mo,options:{loop:Tn}},$n)=>{const kn=Ce.settled(),ho=!mo.shouldConstrain(),Fn=Tn?kn:kn&&ho,Rn=Fn&&!ct.pointerDown();Rn&<.stop();const xo=Ge.get()*$n+Ze.get()*(1-$n);Me.set(xo),Tn&&(at.loop(Ce.direction()),it.loop()),Ke.to(Me.get()),Rn&&Dt.emit("settle"),Fn||Dt.emit("scroll")},q=kd(s,o,()=>S(Fe),Ce=>B(Fe,Ce)),ne=.68,pe=ee[fe.get()],ce=ut(pe),ye=ut(pe),ge=ut(pe),ve=ut(pe),re=Vd(ce,ge,ye,ve,m,ne),ke=Qd(p,ee,K,P,ve),ot=Jd(q,fe,te,re,ke,ve,i),D=qd(P),E=vt(),Z=tu(t,n,i,u),{slideRegistry:se}=Yd(z,j,ee,ae,de,U),me=Xd(e,n,se,ot,re,E,i,_),Fe={ownerDocument:s,ownerWindow:o,eventHandler:i,containerRect:A,slideRects:F,animation:q,axis:T,dragHandler:Rd(T,e,s,o,ve,Md(T,o),ce,q,ot,re,ke,fe,i,Y,y,f,h,ne,O),eventStore:E,percentOfView:Y,index:fe,indexPrevious:te,limit:P,location:ce,offsetLocation:ge,previousLocation:ye,options:a,resizeHandler:Bd(t,i,o,n,T,C,w),scrollBody:re,scrollBounds:Ud(P,ge,ve,re,Y),scrollLooper:Gd(K,P,ge,[ce,ge,ye,ve]),scrollProgress:D,scrollSnapList:ee.map(D.get),scrollSnaps:ee,scrollTarget:ke,scrollTo:ot,slideLooper:Zd(T,G,K,ie,M,ue,ee,ge,n),slideFocus:me,slidesHandler:eu(t,i,I),slidesInView:Z,slideIndexes:U,slideRegistry:se,slidesToScroll:de,target:ve,translate:co(T,t)};return Fe}function ou(){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)),l}function a(d,x){return e[d]=s(d).concat([x]),l}function i(d,x){return e[d]=s(d).filter(p=>p!==x),l}function c(){e={}}const l={init:n,emit:o,off:i,on:a,clear:c};return l}const au={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 iu(e){function t(a,i){return ao(a,i||{})}function n(a){const i=a.breakpoints||{},c=yt(i).filter(l=>e.matchMedia(l).matches).map(l=>i[l]).reduce((l,d)=>t(l,d),{});return t(a,c)}function s(a){return a.map(i=>yt(i.breakpoints||{})).reduce((i,c)=>i.concat(c),[]).map(e.matchMedia)}return{mergeOptions:t,optionsAtMedia:n,optionsMediaQueries:s}}function cu(e){let t=[];function n(a,i){return t=i.filter(({options:c})=>e.optionsAtMedia(c).active!==!1),t.forEach(c=>c.init(a,e)),i.reduce((c,l)=>Object.assign(c,{[l.name]:l}),{})}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=iu(o),i=cu(a),c=vt(),l=ou(),{mergeOptions:d,optionsAtMedia:x,optionsMediaQueries:p}=a,{on:m,off:y,emit:f}=l,u=T;let v=!1,h,j=d(au,Ut.globalOptions),C=d(j),I=[],O,_,b;function w(){const{container:U,slides:S}=C;_=(mn(U)?e.querySelector(U):U)||e.children[0];const q=mn(S)?_.querySelectorAll(S):S;b=[].slice.call(q||_.children)}function A(U){const S=su(e,_,b,s,o,U,l);if(U.loop&&!S.slideLooper.canLoop()){const B=Object.assign({},U,{loop:!1});return A(B)}return S}function F(U,S){v||(j=d(j,U),C=x(j),I=S||I,w(),h=A(C),p([j,...I.map(({options:B})=>B)]).forEach(B=>c.add(B,"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(U,S){const B=de();G(),F(d({startIndex:B},U),S),l.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(),c.clear()}function Y(){v||(v=!0,c.clear(),G(),l.emit("destroy"),l.clear())}function R(U,S,B){!C.active||v||(h.scrollBody.useBaseFriction().useDuration(S===!0?0:C.duration),h.scrollTo.index(U,B||0))}function z(U){const S=h.index.add(1).get();R(S,U,-1)}function le(U){const S=h.index.add(-1).get();R(S,U,1)}function ie(){return h.index.add(1).get()!==de()}function M(){return h.index.add(-1).get()!==de()}function L(){return h.scrollSnapList}function he(){return h.scrollProgress.get(h.offsetLocation.get())}function de(){return h.index.get()}function ue(){return h.indexPrevious.get()}function be(){return h.slidesInView.get()}function K(){return h.slidesInView.get(!1)}function xe(){return O}function ae(){return h}function ee(){return e}function P(){return _}function fe(){return b}const te={canScrollNext:ie,canScrollPrev:M,containerNode:P,internalEngine:ae,destroy:Y,off:y,on:m,emit:f,plugins:xe,previousScrollSnap:ue,reInit:u,rootNode:ee,scrollNext:z,scrollPrev:le,scrollProgress:he,scrollSnapList:L,scrollTo:R,selectedScrollSnap:de,slideNodes:fe,slidesInView:be,slidesNotInView:K};return F(t,n),setTimeout(()=>l.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,c]=g.useState(),l=g.useCallback(()=>{o&&o.reInit(n.current,s.current)},[o]);return g.useEffect(()=>{In(n.current,e)||(n.current=e,l())},[e,l]),g.useEffect(()=>{Ad(s.current,t)||(s.current=t,l())},[t,l]),g.useEffect(()=>{if(Pd()&&i){Ut.globalOptions=An.globalOptions;const d=Ut(i,n.current,s.current);return a(d),()=>d.destroy()}else a(void 0)},[i,a]),[c,o]}An.globalOptions=void 0;const lu={context:"[@mantine/carousel] Carousel.Slide was rendered outside of Carousel context"},[du,uu]=Hr(lu.context);var fu=Object.defineProperty,pu=Object.defineProperties,gu=Object.getOwnPropertyDescriptors,Pr=Object.getOwnPropertySymbols,mu=Object.prototype.hasOwnProperty,hu=Object.prototype.propertyIsEnumerable,Ar=(e,t,n)=>t in e?fu(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,sn=(e,t)=>{for(var n in t||(t={}))mu.call(t,n)&&Ar(e,n,t[n]);if(Pr)for(var n of Pr(t))hu.call(t,n)&&Ar(e,n,t[n]);return e},xu=(e,t)=>pu(e,gu(t)),yu=Ve((e,{controlSize:t,controlsOffset:n,orientation:s,height:o,includeGapInSize:a,breakpoints:i=[],slideGap:c})=>{const l=s==="horizontal",d=m=>{if(!a)return{};const y=we({size:m,sizes:e.spacing});return{[s==="horizontal"?"marginRight":"marginBottom"]:`calc(${y} * -1)`}},p=i.some(m=>typeof m.slideGap<"u"||typeof m.slideSize<"u")?is(e,i).reduce((m,y)=>{const f="maxWidth"in y?"max-width":"min-width",u=we({size:f==="max-width"?y.maxWidth:y.minWidth,sizes:e.breakpoints}),v=typeof y.slideGap>"u"?void 0:$(y.slideGap),h=cs(u)-(f==="max-width"?1:0);return m[`@media (${f}: ${$(h)})`]=d(v),m},{}):null;return{root:{position:"relative"},viewport:{height:$(o),overflow:"hidden"},container:sn(sn({display:"flex",flexDirection:l?"row":"column",height:$(o)},d(c)),p),controls:{position:"absolute",zIndex:1,left:l?0:`calc(50% - ${$(t)} / 2)`,right:l?0:void 0,top:l?`calc(50% - ${$(t)} / 2)`:0,bottom:l?void 0:0,display:"flex",flexDirection:l?"row":"column",alignItems:"center",justifyContent:"space-between",paddingLeft:l?we({size:n,sizes:e.spacing}):void 0,paddingRight:l?we({size:n,sizes:e.spacing}):void 0,paddingTop:l?void 0:we({size:n,sizes:e.spacing}),paddingBottom:l?void 0:we({size:n,sizes:e.spacing}),pointerEvents:"none"},control:xu(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:l?e.spacing.md:0,top:l?void 0:0,left:l?0:void 0,right:l?0:e.spacing.md,display:"flex",flexDirection:l?"row":"column",justifyContent:"center",gap:$(8),pointerEvents:"none"},indicator:{pointerEvents:"all",width:l?$(25):$(5),height:l?$(5):$(25),borderRadius:e.radius.xl,backgroundColor:e.white,boxShadow:e.shadows.sm,opacity:.6,transition:`opacity 150ms ${e.transitionTimingFunction}`,"&[data-active]":{opacity:1}}}}),vu=Object.defineProperty,Nr=Object.getOwnPropertySymbols,ju=Object.prototype.hasOwnProperty,bu=Object.prototype.propertyIsEnumerable,Tr=(e,t,n)=>t in e?vu(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,on=(e,t)=>{for(var n in t||(t={}))ju.call(t,n)&&Tr(e,n,t[n]);if(Nr)for(var n of Nr(t))bu.call(t,n)&&Tr(e,n,t[n]);return e},Cu=Ve((e,{size:t,gap:n,orientation:s,includeGapInSize:o,breakpoints:a=[]})=>{const i=(d,x)=>{const p=we({size:d,sizes:e.spacing}),m=$(x),y=o?{[s==="horizontal"?"paddingRight":"paddingBottom"]:p}:{[s==="horizontal"?"marginRight":"marginBottom"]:p};return on({flex:`0 0 ${m}`},y)},l=a.some(d=>typeof d.slideGap<"u"||typeof d.slideSize<"u")?is(e,a).reduce((d,x)=>{const p="maxWidth"in x?"max-width":"min-width",m=we({size:p==="max-width"?x.maxWidth:x.minWidth,sizes:e.breakpoints}),y=typeof x.slideGap>"u"?n:x.slideGap,f=cs(m)-(p==="max-width"?1:0);return d[`@media (${p}: ${$(f)})`]=i(y,x.slideSize),d},{}):null;return{slide:on(on({position:"relative"},i(n,t)),l)}}),Du=Object.defineProperty,Ht=Object.getOwnPropertySymbols,lo=Object.prototype.hasOwnProperty,uo=Object.prototype.propertyIsEnumerable,$r=(e,t,n)=>t in e?Du(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Su=(e,t)=>{for(var n in t||(t={}))lo.call(t,n)&&$r(e,n,t[n]);if(Ht)for(var n of Ht(t))uo.call(t,n)&&$r(e,n,t[n]);return e},wu=(e,t)=>{var n={};for(var s in e)lo.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&&uo.call(e,s)&&(n[s]=e[s]);return n};const fo=g.forwardRef((e,t)=>{var n=e,{children:s,className:o,size:a,gap:i}=n,c=wu(n,["children","className","size","gap"]);const l=uu(),{classes:d,cx:x}=Cu({gap:typeof i>"u"?l.slideGap:i,size:typeof a>"u"?l.slideSize:a,orientation:l.orientation,includeGapInSize:l.includeGapInSize,breakpoints:l.breakpoints},{name:"Carousel",classNames:l.classNames,styles:l.styles,unstyled:l.unstyled,variant:l.variant});return N.createElement(He,Su({className:x(d.slide,o),ref:t},c),s)});fo.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 _u=Object.defineProperty,Kt=Object.getOwnPropertySymbols,po=Object.prototype.hasOwnProperty,go=Object.prototype.propertyIsEnumerable,Fr=(e,t,n)=>t in e?_u(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Iu=(e,t)=>{for(var n in t||(t={}))po.call(t,n)&&Fr(e,n,t[n]);if(Kt)for(var n of Kt(t))go.call(t,n)&&Fr(e,n,t[n]);return e},Eu=(e,t)=>{var n={};for(var s in e)po.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&&go.call(e,s)&&(n[s]=e[s]);return n};const Ou={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",Ou,e),{children:s,className:o,getEmblaApi:a,onNextSlide:i,onPreviousSlide:c,onSlideChange:l,nextControlLabel:d,previousControlLabel:x,controlSize:p,controlsOffset:m,classNames:y,styles:f,unstyled:u,slideSize:v,slideGap:h,orientation:j,height:C,align:I,slidesToScroll:O,includeGapInSize:_,draggable:b,dragFree:w,loop:A,speed:F,initialSlide:T,inViewThreshold:G,withControls:Y,withIndicators:R,plugins:z,nextControlIcon:le,previousControlIcon:ie,breakpoints:M,skipSnaps:L,containScroll:he,withKeyboardEvents:de,variant:ue}=n,be=Eu(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}=yu({controlSize:p,controlsOffset:m,orientation:j,height:C,includeGapInSize:_,breakpoints:M,slideGap:h},{name:"Carousel",classNames:y,styles:f,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:F,inViewThreshold:G,skipSnaps:L,containScroll:he},z),[fe,te]=g.useState(0),[U,S]=g.useState(0),B=g.useCallback(re=>P&&P.scrollTo(re),[P]),q=g.useCallback(()=>{if(!P)return;const re=P.selectedScrollSnap();te(re),l?.(re)},[P,te]),ne=g.useCallback(()=>{P?.scrollPrev(),c?.()},[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=>pa(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(U).fill(0).map((re,ke)=>N.createElement(Yt,{key:ke,"data-active":ke===fe||void 0,className:K.indicator,"aria-hidden":!0,tabIndex:-1,onClick:()=>B(ke)}));return N.createElement(du,{value:{slideGap:h,slideSize:v,embla:P,orientation:j,includeGapInSize:_,breakpoints:M,classNames:y,styles:f,unstyled:u,variant:ue}},N.createElement(He,Iu({className:xe(K.root,o),ref:t,onKeyDownCapture:ce},be),N.createElement("div",{className:K.viewport,ref:ee},N.createElement("div",{className:K.container},s)),R&&N.createElement("div",{className:K.indicators},ve),Y&&N.createElement("div",{className:K.controls},N.createElement(Yt,{onClick:ne,className:K.control,"aria-label":x,"data-inactive":!ye||void 0,tabIndex:ye?0:-1},typeof ie<"u"?ie:N.createElement(Bn,{style:{transform:`rotate(${kr({dir:ae.dir,orientation:j,direction:"previous"})}deg)`}})),N.createElement(Yt,{onClick:pe,className:K.control,"aria-label":d,"data-inactive":!ge||void 0,tabIndex:ge?0:-1},typeof le<"u"?le:N.createElement(Bn,{style:{transform:`rotate(${kr({dir:ae.dir,orientation:j,direction:"next"})}deg)`}})))))});Nn.Slide=fo;Nn.displayName="@mantine/carousel/Carousel";const Rr=Nn,Pu=({chargeProps:e,onChange:t})=>{const{additionalDocuments:n}=H(ls,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(Rr,{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(Rr.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(ga,{src:a.image?.toString(),withPlaceholder:!0})})})]})},a.id))})}),r.jsx(ma,{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})})]})})},Mr=({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})]})},zr=[{accessorKey:"invoiceDate",header:({column:e})=>r.jsxs(Q,{variant:"ghost",onClick:()=>e.toggleSorting(e.getIsSorted()==="asc"),children:["Invoice Date",e.getIsSorted()&&(e.getIsSorted()==="asc"?r.jsx(De,{className:"ml-2 h-4 w-4"}):r.jsx(Se,{className:"ml-2 h-4 w-4"}))]}),cell:({row:e})=>r.jsx(Mr,{date:e.original.invoiceDate,diff:e.original.diff?.invoiceDate})},{accessorKey:"valueDate",header:({column:e})=>r.jsxs(Q,{variant:"ghost",onClick:()=>e.toggleSorting(e.getIsSorted()==="asc"),children:["Value Date",e.getIsSorted()&&(e.getIsSorted()==="asc"?r.jsx(De,{className:"ml-2 h-4 w-4"}):r.jsx(Se,{className:"ml-2 h-4 w-4"}))]}),cell:({row:e})=>r.jsx(Mr,{date:e.original.valueDate,diff:e.original.diff?.valueDate})},{header:"Debit Account1",columns:[{accessorKey:"debitAccount1.name",header:({column:e})=>r.jsxs(Q,{variant:"ghost",onClick:()=>e.toggleSorting(e.getIsSorted()==="asc"),children:["Account",e.getIsSorted()&&(e.getIsSorted()==="asc"?r.jsx(De,{className:"ml-2 h-4 w-4"}):r.jsx(Se,{className:"ml-2 h-4 w-4"}))]}),cell:({row:e})=>r.jsx(Ot,{account:e.original.debitAccount1,diffAccount:e.original.diff?.debitAccount1})},{accessorKey:"localCurrencyDebitAmount1.raw",header:({column:e})=>r.jsxs(Q,{variant:"ghost",onClick:()=>e.toggleSorting(e.getIsSorted()==="asc"),children:["Amount",e.getIsSorted()&&(e.getIsSorted()==="asc"?r.jsx(De,{className:"ml-2 h-4 w-4"}):r.jsx(Se,{className:"ml-2 h-4 w-4"}))]}),cell:({row:e})=>r.jsx(Et,{foreignAmount:e.original.debitAmount1,localAmount:e.original.localCurrencyDebitAmount1,diff:e.original.diff?{foreignAmount:e.original.diff.debitAmount1,localAmount:e.original.diff.localCurrencyDebitAmount1}:void 0})}]},{header:"Credit Account1",columns:[{accessorKey:"creditAccount1.name",header:({column:e})=>r.jsxs(Q,{variant:"ghost",onClick:()=>e.toggleSorting(e.getIsSorted()==="asc"),children:["Account",e.getIsSorted()&&(e.getIsSorted()==="asc"?r.jsx(De,{className:"ml-2 h-4 w-4"}):r.jsx(Se,{className:"ml-2 h-4 w-4"}))]}),cell:({row:e})=>r.jsx(Ot,{account:e.original.creditAccount1,diffAccount:e.original.diff?.creditAccount1})},{accessorKey:"localCurrencyCreditAmount1.raw",header:({column:e})=>r.jsxs(Q,{variant:"ghost",onClick:()=>e.toggleSorting(e.getIsSorted()==="asc"),children:["Amount",e.getIsSorted()&&(e.getIsSorted()==="asc"?r.jsx(De,{className:"ml-2 h-4 w-4"}):r.jsx(Se,{className:"ml-2 h-4 w-4"}))]}),cell:({row:e})=>r.jsx(Et,{foreignAmount:e.original.creditAmount1,localAmount:e.original.localCurrencyCreditAmount1,diff:e.original.diff?{foreignAmount:e.original.diff.creditAmount1,localAmount:e.original.diff.localCurrencyCreditAmount1}:void 0})}]},{header:"Debit Account2",columns:[{accessorKey:"debitAccount2.name",header:({column:e})=>r.jsxs(Q,{variant:"ghost",onClick:()=>e.toggleSorting(e.getIsSorted()==="asc"),children:["Account",e.getIsSorted()&&(e.getIsSorted()==="asc"?r.jsx(De,{className:"ml-2 h-4 w-4"}):r.jsx(Se,{className:"ml-2 h-4 w-4"}))]}),cell:({row:e})=>r.jsx(Ot,{account:e.original.debitAccount2,diffAccount:e.original.diff?.debitAccount2})},{accessorKey:"localCurrencyDebitAmount2.raw",header:({column:e})=>r.jsxs(Q,{variant:"ghost",onClick:()=>e.toggleSorting(e.getIsSorted()==="asc"),children:["Amount",e.getIsSorted()&&(e.getIsSorted()==="asc"?r.jsx(De,{className:"ml-2 h-4 w-4"}):r.jsx(Se,{className:"ml-2 h-4 w-4"}))]}),cell:({row:e})=>r.jsx(Et,{foreignAmount:e.original.debitAmount2,localAmount:e.original.localCurrencyDebitAmount2,diff:e.original.diff?{foreignAmount:e.original.diff.debitAmount2,localAmount:e.original.diff.localCurrencyDebitAmount2}:void 0})}]},{header:"Credit Account2",columns:[{accessorKey:"creditAccount2.name",header:({column:e})=>r.jsxs(Q,{variant:"ghost",onClick:()=>e.toggleSorting(e.getIsSorted()==="asc"),children:["Account",e.getIsSorted()&&(e.getIsSorted()==="asc"?r.jsx(De,{className:"ml-2 h-4 w-4"}):r.jsx(Se,{className:"ml-2 h-4 w-4"}))]}),cell:({row:e})=>r.jsx(Ot,{account:e.original.creditAccount2,diffAccount:e.original.diff?.creditAccount2})},{accessorKey:"localCurrencyCreditAmount2.raw",header:({column:e})=>r.jsxs(Q,{variant:"ghost",onClick:()=>e.toggleSorting(e.getIsSorted()==="asc"),children:["Amount",e.getIsSorted()&&(e.getIsSorted()==="asc"?r.jsx(De,{className:"ml-2 h-4 w-4"}):r.jsx(Se,{className:"ml-2 h-4 w-4"}))]}),cell:({row:e})=>r.jsx(Et,{foreignAmount:e.original.creditAmount2,localAmount:e.original.localCurrencyCreditAmount2,diff:e.original.diff?{foreignAmount:e.original.diff.creditAmount2,localAmount:e.original.diff.localCurrencyCreditAmount2}:void 0})}]},{accessorKey:"description",header:({column:e})=>r.jsxs(Q,{variant:"ghost",onClick:()=>e.toggleSorting(e.getIsSorted()==="asc"),children:["Details",e.getIsSorted()&&(e.getIsSorted()==="asc"?r.jsx(De,{className:"ml-2 h-4 w-4"}):r.jsx(Se,{className:"ml-2 h-4 w-4"}))]}),cell:({row:{original:e}})=>{const t=e.diff&&e.diff.description!==e.description;return r.jsxs("div",{className:"flex flex-col whitespace-normal",children:[r.jsx("p",{className:t?"line-through":"",children:e.description}),t&&r.jsx("div",{className:"border-2 border-yellow-500 rounded-md",children:e.diff?.description})]})}},{accessorKey:"reference",header:({column:e})=>r.jsxs(Q,{variant:"ghost",onClick:()=>e.toggleSorting(e.getIsSorted()==="asc"),children:["Reference",e.getIsSorted()&&(e.getIsSorted()==="asc"?r.jsx(De,{className:"ml-2 h-4 w-4"}):r.jsx(Se,{className:"ml-2 h-4 w-4"}))]}),cell:({row:{original:e}})=>{const t=e.diff&&e.diff.reference!==e.reference;return r.jsxs("div",{className:"flex flex-col whitespace-normal",children:[r.jsx("p",{className:t?"line-through":"",children:e.reference}),t&&r.jsx("div",{className:"border-2 border-yellow-500 rounded-md",children:e.diff?.reference})]})}},{accessorKey:"matchingStatus",header:({column:e})=>r.jsxs(Q,{variant:"ghost",onClick:()=>e.toggleSorting(e.getIsSorted()==="asc"),children:["Status",e.getIsSorted()&&(e.getIsSorted()==="asc"?r.jsx(De,{className:"ml-2 h-4 w-4"}):r.jsx(Se,{className:"ml-2 h-4 w-4"}))]}),cell:({row:{original:{matchingStatus:e}}})=>{if(e){const t=e==="Deleted"?"bg-red-500":e==="Diff"?"bg-yellow-500":"bg-green-500";return r.jsx(ds,{variant:"default",className:t,children:e})}return null}}];function Au(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 Nu=({ledgerFragment:e})=>{const{ledger:t}=H(us,e),[n,s]=g.useState([]),o=g.useMemo(()=>{const i=t.records.map(l=>{const d=t.validate?.differences?.find(x=>x.id===l.id);return{...l,matchingStatus:!t.validate?.matches||t.validate.matches?.includes(l.id)?void 0:d?"Diff":"Deleted",diff:d}}),c=t?.validate?.differences?.filter(l=>l.id===ha).map(l=>({...l,matchingStatus:"New"}))??[];return i.push(...c),i},[t]),a=Gr({data:o,columns:zr,getCoreRowModel:Wr(),onSortingChange:s,getSortedRowModel:qr(),state:{sorting:n}});return r.jsxs(jn,{children:[r.jsx(bn,{children:a.getHeaderGroups().map(i=>r.jsx(Ye,{children:i.headers.map(c=>r.jsx(Te,{colSpan:c.colSpan,children:c.isPlaceholder?null:Pt(c.column.columnDef.header,c.getContext())},c.id))},i.id))}),r.jsx(Cn,{children:a.getRowModel().rows?.length?a.getRowModel().rows.map(i=>r.jsx(Ye,{"data-state":i.getIsSelected()&&"selected",className:Au(i.original.matchingStatus),children:i.getVisibleCells().map(c=>r.jsx(Ie,{children:Pt(c.column.columnDef.cell,c.getContext())},c.id))},i.id)):r.jsx(Ye,{children:r.jsx(Ie,{colSpan:zr.length,className:"h-24 text-center",children:"No results."})})})]})},Tu=({data:e})=>{const t=H(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(Un,{size:"sm",withPadding:!0,children:t.errorsLedger.validate.errors.map((n,s)=>r.jsx(Un.Item,{children:r.jsx(Qe,{c:"red",children:n})},s))})]}):null},$u=({transactionsProps:e,onChange:t})=>{const{transactions:n}=H(gs,e);return r.jsx(js,{transactionsProps:n,onChange:t,enableEdit:!0})},ku=({chargeId:e})=>{const[{data:t,fetching:n}]=Xe({query:xa,variables:{chargeId:e}}),s=g.useMemo(()=>t?.depositByCharge?.transactions?.filter(o=>o.chargeId!==e)??[],[t?.depositByCharge?.transactions,e]);return n?r.jsx(as,{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(js,{transactionsProps:s,enableChargeLink:!0})]}):r.jsx("div",{className:"text-sm text-gray-500",children:"No bank deposit found for this charge."})},Fu=({chargeProps:e})=>{const t=H(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(Hn,{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(Hn,{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)}`})]})})})]})},Ru=({chargeProps:e})=>{const t=H(hs,e),n=g.useMemo(()=>t.__typename==="CreditcardBankCharge"&&t.creditCardTransactions?t.creditCardTransactions.map(s=>H(ya,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(Pa,{transaction:o})}),r.jsx(Ie,{children:r.jsx(Aa,{transaction:o})}),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(ka,{transaction:o})}),r.jsx(Ie,{children:r.jsx(Fa,{transaction:o})}),r.jsx(Ie,{children:r.jsx(Ra,{chargeId:s.chargeId})})]},s.id)})})]}):null},Mu=({chargeProps:e})=>{const t=H(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(Yr,{className:"gap-0 py-2",children:r.jsxs(va,{className:"flex flex-col px-2",children:[r.jsx(ja,{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(ds,{variant:"default",className:"flex gap-1 rounded-lg text-md",children:[tt(Dn.Ils),o]})]})]})},s))})},zu="deleteMiscExpense",Lu=()=>{const[{fetching:e},t]=Pe(ba),n=g.useCallback(async s=>{const o="Error deleting misc expense",a=`${zu}-${s.id}`;k.loading("Deleting misc expense",{id:a});try{const i=await t(s),c=Ae(i,o,a);if(c)return k.success("Success",{id:a,description:"Misc expense was deleted successfully"}),c.deleteMiscExpense}catch(i){console.error(`${o}: ${i}`),k.error("Error",{id:a,description:o,duration:1e5,closeButton:!0})}},[t]);return{fetching:e,deleteMiscExpense:n}};function Bu({miscExpenseId:e,onChange:t}){const{deleteMiscExpense:n}=Lu();async function s(){try{await n({id:e}),t?.()}catch(o){const a="Failed to delete misc expense";console.error(`${a}: ${o}`),k.error("Error",{description:a})}}return r.jsx(Gt,{onConfirm:s,title:"Are you sure you want to delete this expense?",children:r.jsx(Q,{className:"size-7.5 text-red-500",variant:"ghost",children:r.jsx(Sn,{className:"size-5"})})})}const Vu=({miscExpensesData:e,onChange:t})=>{const n=H(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(ed,{onDone:t,data:o}),r.jsx(Bu,{miscExpenseId:o.id,onChange:t})]})]},o?.id))})]})},Uu=({salaryRecordsProps:e})=>{const t=H(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 Hu({chargeID:e,onChange:t=()=>{},fetching:n}){const[s,o]=g.useState([]),[a,i]=g.useState(e),[c,{toggle:l}]=gt(!1),[d,x]=g.useState(void 0),[{data:p,fetching:m},y]=Xe({query:_e,variables:{chargeId:a}}),f=g.useCallback(()=>{y(),t()},[y,t]);g.useEffect(()=>{p?.charge&&x(p.charge)},[p]),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(L=>L.filter(he=>he!==M)):o(L=>[...L,M])}const A=je(_e,ls,d),F=je(_e,Vn,d),T=je(_e,us,d),G=je(_e,gs,d),Y=je(_e,ys,d),R=g.useMemo(()=>u==="ConversionCharge"&&je(_e,ms,d),[d,u]),z=g.useMemo(()=>u==="FinancialCharge"&&je(_e,xs,d),[d,u]),le=u==="SalaryCharge"&&je(_e,vs,d),ie=g.useMemo(()=>u==="CreditcardBankCharge"&&je(_e,hs,d),[d,u]);return r.jsxs("div",{className:"flex flex-col gap-5",children:[m&&r.jsx(jt,{className:"flex self-center my-5",color:"dark",size:"xl",variant:"dots"}),je(_e,ps,d)&&r.jsx(Tu,{data:d}),d&&r.jsxs("div",{className:"flex flex-row",children:[r.jsxs(V,{className:"w-full",multiple:!0,value:s,chevron:r.jsx(ts,{size:"1rem"}),styles:{chevron:{"&[data-rotate]":{transform:"rotate(45deg)"}}},children:[u==="ConversionCharge"&&r.jsxs(V.Item,{value:"conversion",children:[r.jsx(V.Control,{disabled:!h,onClick:()=>w("conversion"),children:"Conversion Info"}),r.jsx(V.Panel,{children:R&&r.jsx(Fu,{chargeProps:d})})]}),u==="FinancialCharge"&&r.jsxs(V.Item,{value:"exchangeRates",children:[r.jsx(V.Control,{disabled:!z,onClick:()=>w("exchangeRates"),children:"Exchange Rates"}),r.jsx(V.Panel,{children:z&&r.jsx(Mu,{chargeProps:d})})]}),h&&r.jsxs(V.Item,{value:"transactions",children:[r.jsx(V.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(V.Panel,{children:G&&r.jsx($u,{transactionsProps:d,onChange:f})})]}),O&&r.jsxs(V.Item,{value:"miscExpenses",children:[r.jsx(V.Control,{disabled:!O,onClick:()=>w("miscExpenses"),children:"Misc Expenses"}),r.jsx(V.Panel,{children:Y&&r.jsx(Vu,{miscExpensesData:d,onChange:f})})]}),j&&r.jsxs(V.Item,{value:"documents",children:[r.jsx(V.Control,{disabled:!j,onClick:()=>w("documents"),children:r.jsxs("div",{className:"flex flex-row items-center gap-2 justify-between w-full",children:[r.jsxs("div",{className:"flex flex-row items-center gap-2 justify-start",children:[j&&r.jsx(Le,{label:"Documents Gallery",children:r.jsx(Q,{onClick:M=>{M.stopPropagation(),l()},variant:"outline",disabled:!A,size:"icon",className:"size-7.5 text-gray-500",children:r.jsx(Ca,{className:"size-5"})})}),"Documents"]}),_&&r.jsx(cn,{chargeId:d.id})]})}),r.jsx(V.Panel,{children:F&&r.jsx(Da,{documentsProps:H(Vn,d)?.additionalDocuments,onChange:f})})]}),u==="SalaryCharge"&&r.jsxs(V.Item,{value:"salaries",children:[r.jsx(V.Control,{disabled:!I,onClick:()=>w("salaries"),children:"Salaries"}),r.jsx(V.Panel,{children:le&&r.jsx(Uu,{salaryRecordsProps:d})})]}),d.__typename==="BusinessTripCharge"&&r.jsxs(V.Item,{value:"businessTrip",children:[r.jsx(V.Control,{onClick:()=>w("businessTrip"),children:"Business Trip"}),r.jsx(V.Panel,{children:r.jsx(dc,{data:d.businessTrip})})]}),u==="CreditcardBankCharge"&&r.jsxs(V.Item,{value:"creditcard",children:[r.jsx(V.Control,{onClick:()=>w("creditcard"),children:"CreditCard Transactions"}),r.jsx(V.Panel,{children:ie&&r.jsx(Ru,{chargeProps:d})})]}),u==="BankDepositCharge"&&r.jsxs(V.Item,{value:"bankDeposit",children:[r.jsx(V.Control,{onClick:()=>w("bankDeposit"),children:"Bank Deposit"}),r.jsx(V.Panel,{children:r.jsx(ku,{chargeId:d.id})})]}),v&&r.jsxs(V.Item,{value:"ledger",children:[r.jsx(V.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(mc,{chargeId:d.id,onChange:f,variant:"outline"}),"Ledger Records"]})}),r.jsx(V.Panel,{children:T&&r.jsx(Nu,{ledgerFragment:d})})]})]}),A&&r.jsx(He,{maw:"1/6",children:r.jsx(Ba,{in:c,transitionDuration:500,transitionTimingFunction:"linear",children:r.jsx(Pu,{chargeProps:d,onChange:f})})})]}),!m&&!d&&r.jsx("p",{children:"Error fetching extended information for this charge"})]})}const Ku=({setEditCharge:e,setInsertDocument:t,setMatchDocuments:n,toggleMergeCharge:s,isSelectedForMerge:o,data:a,isAllOpened:i})=>{const[c,l]=g.useState(!1),[d,x]=g.useState(H(qe,a)),[{data:p,fetching:m},y]=Xe({query:Sa,pause:!0,variables:{chargeId:a.id}}),f=y;g.useEffect(()=>{const h=p?.charge;h&&x(H(qe,h))},[p]),g.useEffect(()=>{x(H(qe,a))},[a]),g.useEffect(()=>{l(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&&(l(h=>!h),f())},children:[r.jsx(hd,{data:d}),r.jsx(ud,{data:d}),r.jsx(cd,{data:d}),r.jsx(xd,{data:d}),je(qe,Jr,d)?r.jsx(dd,{data:d}):r.jsx("td",{}),r.jsx(fd,{data:d,onChange:f}),je(qe,Zr,d)?r.jsx(gd,{data:d,onChange:f}):r.jsx("td",{}),je(qe,es,d)?r.jsx(md,{data:d}):r.jsx("td",{}),je(qe,Qr,d)?r.jsx(ld,{data:d}):r.jsx("td",{}),r.jsx(pd,{data:d}),r.jsx(id,{data:d,onChange:f}),r.jsx("td",{children:r.jsxs("div",{className:"flex flex-col gap-2",children:[e&&r.jsx(wa,{onClick:h=>{h.stopPropagation(),e(f)}}),s&&r.jsx(hc,{toggleMergeSelected:()=>s(f),mergeSelected:o})]})}),r.jsx("td",{children:r.jsxs("div",{className:"flex flex-col gap-2",children:[r.jsx(Ed,{chargeId:d.id,chargeType:d.__typename,setInsertDocument:t?()=>t(f):void 0,setMatchDocuments:n,onChange:f,isIncome:v}),u&&r.jsx(Ia,{toggleExpansion:l,isExpanded:c,onClickAction:()=>f()})]})})]}),u&&c&&r.jsx("tr",{children:r.jsx("td",{colSpan:13,children:r.jsx(fs,{style:{width:"100%"},withBorder:!0,shadow:"lg",children:r.jsx(Hu,{chargeID:d.id,onChange:f,fetching:m})})})})]})},Xu=({setEditChargeId:e,setInsertDocument:t,setMatchDocuments:n,toggleMergeCharge:s,mergeSelectedCharges:o,data:a,isAllOpened:i})=>{const c=a?.map(l=>H(_a,l))??[];return r.jsxs(bs,{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:c?.map(l=>r.jsx(Ku,{data:l,setEditCharge:e?d=>e({id:l.id,onChange:d}):void 0,setInsertDocument:t?d=>t({id:l.id,onChange:d}):void 0,setMatchDocuments:n?()=>n({id:l.id,ownerId:l.owner.id}):void 0,toggleMergeCharge:s?d=>s(l.id,d):void 0,isSelectedForMerge:o?.has(l.id)??!1,isAllOpened:i},l.id))})]})};export{Xu as C,ro as L,sd as S,Ms as T,hc as a,Hu as b,zs as c,so as d,Cs as e,ad as u};
|