UNPKG

@accounter/client

Version:
1 lines • 94.1 kB
import{s as e}from"./dist-BbgEzppd.js";import{i as t,o as n}from"./utils-BUNz070n.js";import{$t as r,Bi as i,Gi as a,Gt as o,Ht as s,Ja as c,Kt as l,Mn as u,O as d,On as f,Q as p,Qn as m,Ri as h,Rn as g,Vi as _,Vn as v,Vr as y,Vt as b,Wn as x,Wt as S,Xt as C,Ya as w,_a as T,an as E,cn as D,cr as ee,dn as te,en as O,fn as ne,h as re,in as k,jn as ie,k as A,ln as ae,lo as oe,lr as j,nn as se,on as M,qn as N,qr as P,qt as F,r as I,rn as ce,sn as L,t as le,tn as ue,un as de,wn as fe}from"./error-handling-AQOG1RNy.js";import{i as pe,l as me,s as he,t as R}from"./routes-BXbESQBe.js";import{a as ge,c as _e,d as ve,dt as ye,f as be,ft as z,gt as xe,ht as Se,i as Ce,mt as B,n as we,o as Te,r as Ee,s as De,t as Oe,u as ke}from"./select-6mBYg_R6.js";import{$n as Ae,$t as je,A as Me,C as Ne,Cr as Pe,Gn as Fe,Gt as Ie,Kn as Le,Kt as Re,Lt as ze,Mr as Be,Ot as Ve,Sr as He,St as Ue,Ur as We,Ut as Ge,Vr as Ke,Vt as qe,Xn as Je,Zn as Ye,_n as Xe,_r as Ze,at as Qe,bn as $e,ct as et,en as tt,et as nt,gn as rt,gt as it,hn as at,hr as ot,ht as st,ir as ct,jr as lt,l as ut,ln as dt,m as ft,mn as V,n as pt,nn as mt,nt as ht,ot as gt,pn as _t,qt as vt,r as yt,rt as bt,sn as xt,st as St,t as Ct,tn as wt,tr as Tt,tt as Et,un as Dt,v as Ot,vn as kt,vt as At,xn as jt,yn as Mt,yt as Nt,zt as Pt}from"./common-B-HfTiG-.js";import{n as Ft,t as It}from"./bank-deposits-B-QBe3fn.js";import{a as Lt,f as Rt,i as zt,o as Bt,y as Vt}from"./separator-EFzchRgs.js";import{t as H}from"./button-CBTN3XMQ.js";import{i as U,n as W,r as G,t as Ht}from"./accordion-DovkXMHD.js";import{n as Ut,o as Wt,t as Gt}from"./card-I9-5Y7H7.js";import{C as Kt,E as qt,G as Jt,J as K,K as q,O as Yt,Q as Xt,S as Zt,T as Qt,X as $t,_ as J,a as en,c as tn,f as nn,g as Y,h as rn,i as an,k as on,m as sn,n as cn,o as ln,ot as un,p as dn,r as X,s as fn,t as pn,u as mn,w as hn,x as gn}from"./table-BO0OUJta.js";import{t as _n}from"./Card-CYY6IrKW.js";import{a as vn,c as yn,i as bn,n as xn,o as Sn,r as Cn,s as wn,t as Tn}from"./transactions-table-D4icXN1I.js";var En=xe(`arrow-down-wide-narrow`,[[`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`}]]),Dn=xe(`file-plus-corner`,[[`path`,{d:`M11.35 22H6a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v5.35`,key:`17jvcc`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M14 19h6`,key:`bvotb8`}],[`path`,{d:`M17 16v6`,key:`18yu1i`}]]),Z=e(n()),On=e(oe()),kn=Object.defineProperty,An=Object.defineProperties,jn=Object.getOwnPropertyDescriptors,Mn=Object.getOwnPropertySymbols,Nn=Object.prototype.hasOwnProperty,Pn=Object.prototype.propertyIsEnumerable,Fn=(e,t,n)=>t in e?kn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,In=(e,t)=>{for(var n in t||={})Nn.call(t,n)&&Fn(e,n,t[n]);if(Mn)for(var n of Mn(t))Pn.call(t,n)&&Fn(e,n,t[n]);return e},Ln=(e,t)=>An(e,jn(t)),Rn=(e,t)=>{var n={};for(var r in e)Nn.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&Mn)for(var r of Mn(e))t.indexOf(r)<0&&Pn.call(e,r)&&(n[r]=e[r]);return n};function zn(e){if(!e||typeof e==`string`)return 0;let t=e/36;return Math.round((4+15*t**.25+t/5)*10)}function Bn(e){return e?.current?e.current.scrollHeight:`auto`}var Vn=typeof window<`u`&&window.requestAnimationFrame;function Hn({transitionDuration:e,transitionTimingFunction:t=`ease`,onTransitionEnd:n=()=>{},opened:r}){let i=(0,Z.useRef)(null),a={display:`none`,height:0,overflow:`hidden`},[o,s]=(0,Z.useState)(r?{}:a),c=e=>{(0,On.flushSync)(()=>s(e))},l=e=>{c(t=>In(In({},t),e))};function u(n){return{transition:`height ${e||zn(n)}ms ${t}`}}Xt(()=>{Vn(r?()=>{l({willChange:`height`,display:`block`,overflow:`hidden`}),Vn(()=>{let e=Bn(i);l(Ln(In({},u(e)),{height:e}))})}:()=>{let e=Bn(i);l(Ln(In({},u(e)),{willChange:`height`,height:e})),Vn(()=>l({height:0,overflow:`hidden`}))})},[r]);let d=e=>{if(!(e.target!==i.current||e.propertyName!==`height`))if(r){let e=Bn(i);e===o.height?c({}):l({height:e}),n()}else o.height===0&&(c(a),n())};function f(e={}){var t=e,{style:n={},refKey:a=`ref`}=t,s=Rn(t,[`style`,`refKey`]);let c=s[a];return Ln(In({"aria-hidden":!r},s),{[a]:Tt(i,c),onTransitionEnd:d,style:In(In({boxSizing:`border-box`},n),o)})}return f}var Un=Object.defineProperty,Wn=Object.getOwnPropertySymbols,Gn=Object.prototype.hasOwnProperty,Kn=Object.prototype.propertyIsEnumerable,qn=(e,t,n)=>t in e?Un(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Jn=(e,t)=>{for(var n in t||={})Gn.call(t,n)&&qn(e,n,t[n]);if(Wn)for(var n of Wn(t))Kn.call(t,n)&&qn(e,n,t[n]);return e},Yn=(e,t)=>{var n={};for(var r in e)Gn.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&Wn)for(var r of Wn(e))t.indexOf(r)<0&&Kn.call(e,r)&&(n[r]=e[r]);return n},Xn={transitionDuration:200,transitionTimingFunction:`ease`,animateOpacity:!0},Zn=(0,Z.forwardRef)((e,t)=>{let n=Yt(`Collapse`,Xn,e),{children:r,in:i,transitionDuration:a,transitionTimingFunction:o,style:s,onTransitionEnd:c,animateOpacity:l}=n,u=Yn(n,[`children`,`in`,`transitionDuration`,`transitionTimingFunction`,`style`,`onTransitionEnd`,`animateOpacity`]),d=on(),f=Ae(),p=d.respectReducedMotion&&f?0:a,{systemStyles:m,rest:h}=Qt(u),g=Hn({opened:i,transitionDuration:p,transitionTimingFunction:o,onTransitionEnd:c});return p===0?i?Z.createElement(hn,Jn({},h),r):null:Z.createElement(hn,Jn({},g(Jn(Jn({style:s,ref:t},h),m))),Z.createElement(`div`,{style:{opacity:i||!l?1:0,transition:l?`opacity ${p}ms ${o}`:`none`}},r))});Zn.displayName=`@mantine/core/Collapse`;var Qn=Object.defineProperty,$n=Object.defineProperties,er=Object.getOwnPropertyDescriptors,tr=Object.getOwnPropertySymbols,nr=Object.prototype.hasOwnProperty,rr=Object.prototype.propertyIsEnumerable,ir=(e,t,n)=>t in e?Qn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,ar=(e,t)=>{for(var n in t||={})nr.call(t,n)&&ir(e,n,t[n]);if(tr)for(var n of tr(t))rr.call(t,n)&&ir(e,n,t[n]);return e},or=(e,t)=>$n(e,er(t)),sr=[`light`,`filled`,`outline`,`dot`,`gradient`],cr={xs:{fontSize:K(9),height:K(16)},sm:{fontSize:K(10),height:K(18)},md:{fontSize:K(11),height:K(20)},lg:{fontSize:K(13),height:K(26)},xl:{fontSize:K(16),height:K(32)}},lr={xs:K(4),sm:K(4),md:K(6),lg:K(8),xl:K(10)};function ur({theme:e,variant:t,color:n,size:r,gradient:i}){if(!sr.includes(t))return null;if(t===`dot`){let t=q({size:r,sizes:lr});return{backgroundColor:`transparent`,color:e.colorScheme===`dark`?e.colors.dark[0]:e.colors.gray[7],border:`${K(1)} solid ${e.colorScheme===`dark`?e.colors.dark[3]:e.colors.gray[3]}`,paddingLeft:`calc(${q({size:r,sizes:e.spacing})} / 1.5 - ${t} / 2)`,"&::before":{content:`""`,display:`block`,width:t,height:t,borderRadius:t,backgroundColor:e.fn.themeColor(n,e.colorScheme===`dark`?4:e.fn.primaryShade(`light`),!0),marginRight:t}}}let a=e.fn.variant({color:n,variant:t,gradient:i});return{background:a.background,color:a.color,border:`${K(t===`gradient`?0:1)} solid ${a.border}`}}var dr=qt((e,{color:t,radius:n,gradient:r,fullWidth:i},{variant:a,size:o})=>{let{fontSize:s,height:c}=o in cr?cr[o]:cr.md;return{leftSection:{marginRight:`calc(${e.spacing.xs} / 2)`},rightSection:{marginLeft:`calc(${e.spacing.xs} / 2)`},inner:{whiteSpace:`nowrap`,overflow:`hidden`,textOverflow:`ellipsis`},root:ar(or(ar(ar({},e.fn.focusStyles()),e.fn.fontStyles()),{fontSize:s,height:c,WebkitTapHighlightColor:`transparent`,lineHeight:`calc(${c} - ${K(2)})`,textDecoration:`none`,padding:`0 calc(${q({size:o,sizes:e.spacing})} / 1.5)`,boxSizing:`border-box`,display:i?`flex`:`inline-flex`,alignItems:`center`,justifyContent:`center`,width:i?`100%`:`auto`,textTransform:`uppercase`,borderRadius:e.fn.radius(n),fontWeight:700,letterSpacing:K(.25),cursor:`inherit`,textOverflow:`ellipsis`,overflow:`hidden`}),ur({theme:e,variant:a,color:t,size:o,gradient:r}))}}),fr=Object.defineProperty,pr=Object.getOwnPropertySymbols,mr=Object.prototype.hasOwnProperty,hr=Object.prototype.propertyIsEnumerable,gr=(e,t,n)=>t in e?fr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,_r=(e,t)=>{for(var n in t||={})mr.call(t,n)&&gr(e,n,t[n]);if(pr)for(var n of pr(t))hr.call(t,n)&&gr(e,n,t[n]);return e},vr=(e,t)=>{var n={};for(var r in e)mr.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&pr)for(var r of pr(e))t.indexOf(r)<0&&hr.call(e,r)&&(n[r]=e[r]);return n},yr={variant:`light`,size:`md`,radius:`xl`},br=(0,Z.forwardRef)((e,t)=>{let n=Yt(`Badge`,yr,e),{className:r,color:i,variant:a,fullWidth:o,children:s,size:c,leftSection:l,rightSection:u,radius:d,gradient:f,classNames:p,styles:m,unstyled:h}=n,g=vr(n,[`className`,`color`,`variant`,`fullWidth`,`children`,`size`,`leftSection`,`rightSection`,`radius`,`gradient`,`classNames`,`styles`,`unstyled`]),{classes:_,cx:v}=dr({fullWidth:o,color:i,radius:d,gradient:f},{classNames:p,styles:m,name:`Badge`,unstyled:h,variant:a,size:c});return Z.createElement(hn,_r({className:v(_.root,r),ref:t},g),l&&Z.createElement(`span`,{className:_.leftSection},l),Z.createElement(`span`,{className:_.inner},s),u&&Z.createElement(`span`,{className:_.rightSection},u))});br.displayName=`@mantine/core/Badge`;var xr=$t(br),Sr=Object.defineProperty,Cr=Object.defineProperties,wr=Object.getOwnPropertyDescriptors,Tr=Object.getOwnPropertySymbols,Er=Object.prototype.hasOwnProperty,Dr=Object.prototype.propertyIsEnumerable,Or=(e,t,n)=>t in e?Sr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,kr=(e,t)=>{for(var n in t||={})Er.call(t,n)&&Or(e,n,t[n]);if(Tr)for(var n of Tr(t))Dr.call(t,n)&&Or(e,n,t[n]);return e},Ar=(e,t)=>Cr(e,wr(t)),jr={xs:K(16),sm:K(20),md:K(26),lg:K(32),xl:K(40)},Mr=[`filled`,`light`,`gradient`,`outline`,`default`];function Nr({theme:e,variant:t,color:n,gradient:r}){if(!Mr.includes(t))return null;let i=e.fn.variant({variant:t,color:n||e.primaryColor,gradient:r,primaryFallback:!1});return{backgroundColor:i.background,color:i.color,backgroundImage:t===`gradient`?i.background:void 0,border:`${K(t===`gradient`?0:1)} solid ${i.border}`}}var Pr=qt((e,{color:t,radius:n,gradient:r},{variant:i,size:a})=>{let o=q({size:a,sizes:jr});return{root:kr(Ar(kr({},e.fn.fontStyles()),{display:`inline-flex`,alignItems:`center`,justifyContent:`center`,boxSizing:`border-box`,width:o,height:o,minWidth:o,minHeight:o,borderRadius:e.fn.radius(n)}),Nr({theme:e,variant:i,gradient:r,color:t}))}}),Fr=Object.defineProperty,Ir=Object.getOwnPropertySymbols,Lr=Object.prototype.hasOwnProperty,Rr=Object.prototype.propertyIsEnumerable,zr=(e,t,n)=>t in e?Fr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Br=(e,t)=>{for(var n in t||={})Lr.call(t,n)&&zr(e,n,t[n]);if(Ir)for(var n of Ir(t))Rr.call(t,n)&&zr(e,n,t[n]);return e},Vr=(e,t)=>{var n={};for(var r in e)Lr.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&Ir)for(var r of Ir(e))t.indexOf(r)<0&&Rr.call(e,r)&&(n[r]=e[r]);return n},Hr={size:`md`,variant:`filled`},Ur=(0,Z.forwardRef)((e,t)=>{let n=Yt(`ThemeIcon`,Hr,e),{className:r,size:i,radius:a,variant:o,color:s,children:c,gradient:l,unstyled:u}=n,d=Vr(n,[`className`,`size`,`radius`,`variant`,`color`,`children`,`gradient`,`unstyled`]),{classes:f,cx:p}=Pr({variant:o,radius:a,color:s,gradient:l},{name:`ThemeIcon`,unstyled:u,variant:o,size:i});return Z.createElement(hn,Br({className:p(f.root,r),ref:t},d),c)});Ur.displayName=`@mantine/core/ThemeIcon`;var Q=t();function Wr({data:e,onChange:t}){let n=Y(r,e),[i,a]=(0,Z.useState)(n.accountantApproval);return(0,Z.useEffect)(()=>{i==null&&n.accountantApproval!=null&&a(n.accountantApproval)},[i,n.accountantApproval]),(0,Q.jsx)(`td`,{children:(0,Q.jsx)(et,{chargeId:n.id,value:i,onChange:t})})}var Gr=({data:e})=>{let t=Y(O,e),[n,r]=(0,Z.useState)(!0),[i,a]=(0,Z.useState)(!0),o=`validCreditCardAmount`in t?t.validCreditCardAmount:null;return(0,Z.useEffect)(()=>{t.__typename===`CreditcardBankCharge`&&(a(o==null),o!=null&&r(o))},[t.__typename,o]),(0,Q.jsx)(`td`,{children:(0,Q.jsx)(`div`,{children:(0,Q.jsx)(rt,{inline:!0,size:12,disabled:n,processing:i,color:`red`,zIndex:`auto`,children:(0,Q.jsx)(`p`,{className:(t.totalAmount?.raw??0)>0?`whitespace-nowrap text-green-700`:`whitespace-nowrap text-red-500`,children:t.totalAmount?.formatted})})})})},Kr=({data:e})=>{let t=Y(ue,e);return`businessTrip`in t?(0,Q.jsx)(`td`,{children:(0,Q.jsx)(me,{to:t.businessTrip?.id?R.BUSINESS_TRIPS.DETAIL(t.businessTrip?.id):R.BUSINESS_TRIPS.ROOT,target:`_blank`,rel:`noreferrer`,onClick:e=>e.stopPropagation(),className:`inline-flex items-center font-semibold`,children:t.businessTrip?.name})}):(0,Q.jsx)(`td`,{})},qr=({data:e})=>{let{counterparty:t,validationData:n,__typename:r}=Y(k,e),i=(0,Z.useMemo)(()=>{switch(r){case`BusinessTripCharge`:case`DividendCharge`:case`ConversionCharge`:case`SalaryCharge`:case`InternalTransferCharge`:return!1;default:return!0}},[r]),a=(0,Z.useMemo)(()=>i&&n?.missingInfo?.includes(P.Counterparty),[i,n?.missingInfo]),{name:o,id:s}=t??{name:`Missing`,id:void 0};return(0,Q.jsx)(`td`,{children:(0,Q.jsx)(`div`,{className:`flex flex-wrap`,children:(0,Q.jsxs)(rt,{inline:!0,size:12,disabled:!a,color:`red`,zIndex:`auto`,children:[!a&&s&&(0,Q.jsx)(me,{to:R.BUSINESSES.DETAIL(s),target:`_blank`,rel:`noreferrer`,onClick:e=>e.stopPropagation(),className:`inline-flex items-center font-semibold`,children:o}),a&&o]})})})},Jr=({data:e})=>{let{minDebitDate:t,minEventDate:n,minDocumentsDate:r}=Y(se,e),i=t||n||r;return(0,Q.jsx)(`td`,{children:(0,Q.jsx)(`div`,{children:i&&un(new Date(i),`dd/MM/yy`)})})},Yr=({data:e,onChange:t})=>{let[n,r]=(0,Z.useState)(!1),i=Y(ce,e),a=i.validationData?.missingInfo?.includes(P.Description),o=a&&!!i.missingInfoSuggestions?.description?.trim().length,{userDescription:s,id:c}=i,l=s&&s?.trim()!==``?s:i.missingInfoSuggestions?.description?i.missingInfoSuggestions.description:`Missing`,{updateCharge:u,fetching:d}=ze(),f=(0,Z.useCallback)(async e=>{e!==void 0&&(await u({chargeId:c,fields:{userDescription:e}}),r(!0))},[c,u]);return(0,Q.jsxs)(`td`,{children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap`,children:[(0,Q.jsx)(`div`,{className:`flex flex-col justify-center`,children:(0,Q.jsx)(rt,{inline:!0,size:12,disabled:!a,color:`red`,zIndex:`auto`,children:(0,Q.jsx)(`p`,{className:o?`bg-yellow-400`:void 0,children:l})})}),o&&(0,Q.jsx)(tt,{onClick:e=>{e.stopPropagation(),f(i.missingInfoSuggestions.description)},disabled:d})]}),(0,Q.jsx)(ut,{chargeId:c,description:i.missingInfoSuggestions?.description??void 0,open:n,onOpenChange:r,onClose:t})]})},Xr=({data:e})=>{let{metadata:t,validationData:n,id:r,__typename:i}=Y(L,e),a=(0,Z.useMemo)(()=>{switch(i){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}},[i]),o=(0,Z.useMemo)(()=>{switch(i){case`FinancialCharge`:return!1;default:return!0}},[i]),s=(0,Z.useMemo)(()=>o&&n?.missingInfo?.includes(P.Transactions),[o,n?.missingInfo]),c=(0,Z.useMemo)(()=>a&&n?.missingInfo?.includes(P.Documents),[a,n?.missingInfo]),l=(0,Z.useMemo)(()=>!t?.invalidLedger,[t?.invalidLedger]),u=(0,Z.useMemo)(()=>t?.invalidLedger,[t?.invalidLedger]);return(0,Q.jsx)(`td`,{children:(0,Q.jsx)(st,{chargeId:r,children:(0,Q.jsx)(St,{items:(0,Z.useMemo)(()=>{let e=[];return(s||t?.transactionsCount||o)&&e.push({extraClassName:t?.transactionsCount||!o?void 0:`bg-yellow-400`,content:(0,Q.jsx)(rt,{inline:!0,size:12,disabled:!s,color:`red`,zIndex:`auto`,children:(0,Q.jsxs)(`div`,{className:`whitespace-nowrap`,children:[`Transactions: `,t?.transactionsCount??0]})},`transactions`)}),e.push({content:(0,Q.jsx)(rt,{inline:!0,size:12,processing:l,disabled:u===`VALID`,color:u===`DIFF`?`orange`:`red`,zIndex:`auto`,children:(0,Q.jsxs)(`div`,{className:`whitespace-nowrap`,children:[`Ledger Records: `,t?.ledgerCount??0]})},`ledger`)}),(c||t?.documentsCount)&&e.push({content:(0,Q.jsx)(rt,{inline:!0,size:12,disabled:!c,color:`red`,zIndex:`auto`,children:(0,Q.jsxs)(`div`,{className:`whitespace-nowrap`,children:[`Documents: `,t?.documentsCount??0]})},`documents`),extraClassName:!n?.missingInfo?.includes(P.Documents)||!a?void 0:`bg-yellow-400`}),t?.miscExpensesCount&&e.push({content:(0,Q.jsxs)(`div`,{className:`whitespace-nowrap`,children:[`Misc Expenses: `,t?.miscExpensesCount??0]})}),e},[t?.transactionsCount,t?.ledgerCount,t?.documentsCount,t?.miscExpensesCount,a,o,s,c,n?.missingInfo,u,l])})})})},Zr=({data:e,onChange:t})=>{let{tags:n,id:r,validationData:i,missingInfoSuggestions:a}=Y(ae,e),{updateCharge:o,fetching:s}=ze(),[c,l]=(0,Z.useState)(n??[]),[u,d]=(0,Z.useState)(!1),f=i?.missingInfo?.includes(P.Tags),p=f&&!!a?.tags?.length;(0,Z.useEffect)(()=>{n?.length&&!c.length&&l(n)},[n,c.length]),(0,Z.useEffect)(()=>{c.length===0&&p&&l(a?.tags??[])},[c.length,p,a?.tags]);let m=(0,Z.useCallback)(async e=>{await o({chargeId:r,fields:{tags:e?.map(e=>({id:e.id}))}}),d(!0)},[r,o,d]);return(0,Q.jsxs)(`td`,{children:[(0,Q.jsx)(rt,{inline:!0,size:12,disabled:!f,color:`red`,zIndex:`auto`,children:(0,Q.jsx)(St,{items:c.map(e=>(0,Q.jsx)(Xe,{children:(0,Q.jsxs)(`div`,{children:[e.namePath&&(0,Q.jsx)(Zt,{size:`xs`,opacity:.65,children:`${e.namePath.join(` > `)} >`}),(0,Q.jsx)(Zt,{size:`sm`,children:e.name})]})},e.id)),extraClassName:p?`bg-yellow-400`:void 0})}),p&&(0,Q.jsx)(tt,{onClick:e=>{e.stopPropagation(),m(a.tags)},disabled:s}),(0,Q.jsx)(ut,{chargeId:r,tagIds:a?.tags?.map(e=>({id:e.id})),open:u,onOpenChange:d,onClose:t})]})},Qr=({data:e})=>{let{validationData:t,taxCategory:n,__typename:r}=Y(de,e),i=(0,Z.useMemo)(()=>{switch(r){case`DividendCharge`:case`InternalTransferCharge`:case`SalaryCharge`:case`BankDepositCharge`:case`ForeignSecuritiesCharge`:return!1;default:return!0}},[r]),a=(0,Z.useMemo)(()=>t?.missingInfo?.includes(P.TaxCategory),[t?.missingInfo]);return i?(0,Q.jsx)(`td`,{children:(0,Q.jsx)(rt,{inline:!0,size:12,disabled:!a,color:`red`,zIndex:`auto`,children:n?.name??`N/A`})}):(0,Q.jsx)(`td`,{})},$r=({data:e})=>{let{__typename:t}=Y(te,e),{text:n,icon:r}=(0,Z.useMemo)(()=>({text:Pe(t),icon:He(t)}),[t]);return(0,Q.jsxs)(`td`,{children:[(0,Q.jsx)(`div`,{children:n}),(0,Q.jsx)(Ur,{radius:`xl`,size:`xl`,children:r})]})},ei=({data:e})=>{let{vat:t,totalAmount:n,validationData:r,__typename:i}=Y(ne,e),a=(0,Z.useMemo)(()=>r?.missingInfo?.includes(P.Vat),[r?.missingInfo]),o=(0,Z.useMemo)(()=>!t&&n?.currency===u.Ils,[t,n?.currency]),s=(0,Z.useMemo)(()=>(t?.raw??0)>0&&(n?.raw??0)<0||(t?.raw??0)<0&&(n?.raw??0)>0,[t?.raw,n?.raw]),c=o||s;return(0,Z.useMemo)(()=>{switch(i){case`BusinessTripCharge`:case`DividendCharge`:case`ConversionCharge`:case`SalaryCharge`:case`InternalTransferCharge`:case`BankDepositCharge`:case`ForeignSecuritiesCharge`:case`CreditcardBankCharge`:return!1;default:return!0}},[i])?(0,Q.jsx)(`td`,{children:(0,Q.jsx)(`div`,{className:c?`whitespace-nowrap text-red-500`:`whitespace-nowrap text-green-700`,children:(0,Q.jsx)(rt,{inline:!0,size:12,disabled:!a,color:`red`,zIndex:`auto`,children:t?.formatted})})}):(0,Q.jsx)(`td`,{})},ti=`insertDepreciationRecord`,ni=()=>{let[{fetching:e},t]=c(re);return{fetching:e,addDepreciationRecord:(0,Z.useCallback)(async e=>{let n=`Error adding depreciation record`,r=ti;I.loading(`Adding depreciation record`,{id:r});try{let i=le(await t(e),n,r,`insertDepreciationRecord`);if(i)return I.success(`Success`,{id:r,description:`Depreciation record was added`}),i.insertDepreciationRecord}catch(e){console.error(`${n}: ${e}`),I.error(`Error`,{id:r,description:n,duration:1e5,closeButton:!0})}},[t])}};function ri(e){let{chargeId:t,onAdd:n}=e,[r,{close:i,open:a}]=Ye(!1);return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(At,{content:`Add Depreciation Record`,children:(0,Q.jsx)(H,{variant:`outline`,size:`icon`,className:`size-7.5`,onClick:e=>{e.stopPropagation(),a()},children:(0,Q.jsx)(Vt,{className:`size-5`})})}),r&&(0,Q.jsx)(ii,{chargeId:t,opened:r,close:i,onAdd:n})]})}function ii({chargeId:e,opened:t,close:n,onAdd:r}){let{control:i,handleSubmit:a}=qe({defaultValues:{chargeId:e}}),[o,s]=(0,Z.useState)(!1),[{data:c,fetching:l}]=w({query:A}),{addDepreciationRecord:u,fetching:d}=ni(),f=e=>{u({fields:e}).then(()=>{r?.(),n()})},p=c?.depreciationCategories?.map(e=>({value:e.id,label:e.name}))??[];return(0,Z.useEffect)(()=>{s(!!(l||d))},[l,d]),(0,Q.jsxs)(_t,{opened:t,onClose:n,centered:!0,lockScroll:!0,children:[(0,Q.jsx)(_t.Title,{children:`Add Depreciation Record`}),(0,Q.jsx)(_t.Body,{children:(0,Q.jsxs)(`form`,{onSubmit:a(f),children:[(0,Q.jsx)(Pt,{name:`activationDate`,control:i,rules:{pattern:{value:he,message:`Date must be im format yyyy-mm-dd`}},render:({field:{value:e,...t}})=>{let n=e?new Date(e):void 0;return(0,Q.jsx)(Ve,{...t,onChange:n=>{let r=n?typeof n==`string`?n:un(n,`yyyy-MM-dd`):void 0;r!==e&&t.onChange(r)},value:n,label:`Activation Date`,popoverProps:{withinPortal:!0}})}}),(0,Q.jsx)(Pt,{name:`amount`,control:i,render:({field:e,fieldState:t})=>(0,Q.jsx)(Pt,{name:`currency`,control:i,render:({field:n,fieldState:r})=>(0,Q.jsx)(it,{...e,value:e.value??void 0,error:t.error?.message||r.error?.message,label:`Amount`,currencyCodeProps:{...n,label:`Currency`}})})}),(0,Q.jsx)(Pt,{name:`categoryId`,control:i,render:({field:e,fieldState:t})=>(0,Q.jsx)(Dt,{...e,disabled:l,data:p,label:`Category`,placeholder:`Scroll to see all options`,maxDropdownHeight:160,searchable:!0,error:t.error?.message,withinPortal:!0})}),(0,Q.jsx)(Pt,{name:`type`,control:i,render:({field:e,fieldState:t})=>(0,Q.jsx)(Dt,{...e,data:fi,value:e.value,label:`Type`,placeholder:`Scroll to see all options`,maxDropdownHeight:160,searchable:!0,error:t.error?.message,withinPortal:!0})}),(0,Q.jsx)(`div`,{className:`flex justify-center mt-5 gap-3`,children:(0,Q.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`})})]})}),(d||o)&&(0,Q.jsx)(Mt,{blur:1,center:!0,children:(0,Q.jsx)(Kt,{})})]})}var ai=`updateDepreciationRecord`,oi=()=>{let[{fetching:e},t]=c(T);return{fetching:e,updateDepreciationRecord:(0,Z.useCallback)(async e=>{let n=`Error updating depreciation record`,r=ai;I.loading(`Updating depreciation record`,{id:r});try{let i=le(await t(e),n,r,`updateDepreciationRecord`);if(i)return I.success(`Success`,{id:r,description:`Depreciation record was updated`}),i.updateDepreciationRecord}catch(e){console.error(`${n}: ${e}`),I.error(`Error`,{id:r,description:n,duration:1e5,closeButton:!0})}},[t])}},si=`deleteDepreciationRecord`,ci=()=>{let[{fetching:e},t]=c(g);return{fetching:e,deleteDepreciationRecord:(0,Z.useCallback)(async e=>{let n=`Error deleting depreciation record`,r=`${si}-${e.depreciationRecordId}`;I.loading(`Deleting depreciation record`,{id:r});try{let i=le(await t(e),n,r);if(i)return I.success(`Success`,{id:r,description:`Depreciation record was deleted`}),i.deleteDepreciationRecord}catch(e){console.error(`${n}: ${e}`),I.error(`Error`,{id:r,description:n,duration:1e5,closeButton:!0})}},[t])}};function li(e){let{fetching:t,deleteDepreciationRecord:n}=ci();return(0,Q.jsx)(At,{content:`Remove Depreciation`,children:(0,Q.jsx)(bt,{onConfirm:(0,Z.useCallback)(()=>{n({depreciationRecordId:e.depreciationRecordId}).then(()=>{e.onDelete?.()})},[e,n]),title:`Are you sure you want to delete the depreciation record?`,children:(0,Q.jsx)(H,{variant:`outline`,size:`icon`,className:`size-7.5 text-red-500`,disabled:t,children:(0,Q.jsx)(lt,{className:`size-5`})})})})}var ui=({data:e,onChange:t})=>{let n=Y(x,e),[r,i]=(0,Z.useState)(!1),[{data:a,fetching:o},s]=w({query:A,pause:!0}),{control:c,handleSubmit:l,formState:{dirtyFields:u}}=qe({defaultValues:{id:n.id}}),{updateDepreciationRecord:d,fetching:f}=oi(),p=e=>{let r=pe(e,u);r&&Object.keys(r).length>0&&d({fields:{...e,id:n.id}}).then(()=>{t?.(),i(!1)})},m=a?.depreciationCategories.map(e=>({value:e.id,label:e.name}));return(0,Z.useEffect)(()=>{r&&!a&&s()},[r,a,s]),(0,Q.jsxs)(`tr`,{children:[(0,Q.jsx)(`td`,{children:(0,Q.jsx)(`form`,{id:`form ${n.id}`,onSubmit:l(p),children:r?(0,Q.jsx)(Pt,{name:`amount`,control:c,render:({field:e,fieldState:t})=>(0,Q.jsx)(Pt,{name:`currency`,control:c,render:({field:r,fieldState:i})=>(0,Q.jsx)(it,{...e,defaultValue:n.amount?.raw??n.charge.totalAmount?.raw,value:e.value??void 0,error:t.error?.message||i.error?.message,label:`Amount`,currencyCodeProps:{...r,label:`Currency`,defaultValue:n.amount?.currency??n.charge.totalAmount?.currency}})})}):(0,Q.jsx)(`div`,{children:n.amount?.formatted??n.charge.totalAmount?.formatted})})}),(0,Q.jsx)(`td`,{children:(0,Q.jsx)(`div`,{className:`flex flex-col gap-2 justify-center`,children:r?(0,Q.jsx)(Pt,{name:`activationDate`,control:c,defaultValue:n.activationDate,rules:{pattern:{value:he,message:`Date must be im format yyyy-mm-dd`}},render:({field:{value:e,...t},fieldState:r})=>{let i=e?new Date(e):void 0;return(0,Q.jsx)(Ve,{...t,form:`form ${n.id}`,onChange:n=>{let r=n?typeof n==`string`?n:un(n,`yyyy-MM-dd`):void 0;r!==e&&t.onChange(r)},value:i,label:`Activation Date`,error:r.error?.message,popoverProps:{withinPortal:!0}})}}):(0,Q.jsx)(`div`,{children:un(new Date(n.activationDate),`dd/MM/yy`)})})}),(0,Q.jsx)(`td`,{children:r?(0,Q.jsx)(Pt,{name:`categoryId`,control:c,render:({field:e,fieldState:t})=>(0,Q.jsx)(Dt,{...e,form:`form ${n.id}`,disabled:o,data:m??[],label:`Category`,placeholder:`Scroll to see all options`,maxDropdownHeight:160,searchable:!0,error:t.error?.message,withinPortal:!0})}):(0,Q.jsxs)(`div`,{children:[n.category.name,` (`,n.category.percentage,`%)`]})}),(0,Q.jsx)(`td`,{children:r?(0,Q.jsx)(Pt,{name:`type`,control:c,render:({field:e,fieldState:t})=>(0,Q.jsx)(Dt,{...e,form:`form ${n.id}`,data:fi,value:e.value,label:`Type`,placeholder:`Scroll to see all options`,maxDropdownHeight:160,searchable:!0,error:t.error?.message,withinPortal:!0})}):(0,Q.jsx)(`div`,{children:n.type})}),(0,Q.jsxs)(`td`,{children:[(0,Q.jsx)(At,{content:`Edit`,children:(0,Q.jsx)(H,{disabled:f||o,variant:r?`default`:`outline`,size:`icon`,className:`size-7.5`,onClick:e=>{e.stopPropagation(),i(e=>!e)},children:(0,Q.jsx)(Be,{className:`size-5`})})}),r&&(0,Q.jsx)(At,{content:`Confirm Changes`,children:(0,Q.jsx)(H,{type:`submit`,form:`form ${n.id}`,variant:`outline`,size:`icon`,className:`size-7.5 text-green-500`,children:(0,Q.jsx)(Se,{className:`size-5`})})}),(0,Q.jsx)(li,{depreciationRecordId:n.id,onDelete:t})]})]},n.id)},di=({chargeId:e,onChange:t})=>{let[{data:n,fetching:r}]=w({query:b,variables:{chargeId:e}});return!r&&!n?.depreciationRecordsByCharge.length?(0,Q.jsx)(ri,{chargeId:e,onAdd:t}):r?(0,Q.jsx)(ye,{className:`h-10 w-10 animate-spin mr-2 self-center`}):(0,Q.jsx)(`div`,{className:`flex flex-col gap-2 mt-5`,children:(0,Q.jsxs)(xt,{highlightOnHover:!0,withBorder:!0,children:[(0,Q.jsx)(`thead`,{children:(0,Q.jsxs)(`tr`,{children:[(0,Q.jsx)(`th`,{children:`Amount`}),(0,Q.jsx)(`th`,{children:`Activation Date`}),(0,Q.jsx)(`th`,{children:`Category`}),(0,Q.jsx)(`th`,{children:`Type`}),(0,Q.jsx)(`th`,{})]})}),(0,Q.jsxs)(`tbody`,{children:[n?.depreciationRecordsByCharge.map(e=>(0,Q.jsx)(ui,{data:e,onChange:t},e.id)),(0,Q.jsx)(`tr`,{children:(0,Q.jsx)(`td`,{colSpan:5,children:(0,Q.jsx)(ri,{chargeId:e,onAdd:t})})})]})]})})},fi=Object.entries(N).map(([e,t])=>({value:t,label:e}));function pi({chargeId:e,chargeType:t,onChange:n,isIncome:r}){let{deleteCharge:i}=je(),[a,o]=(0,Z.useState)(!1),[s,{open:c,close:l}]=Ye(!1),[u,d]=(0,Z.useState)(!1),[f,{open:p,close:m}]=Ye(!1),[h,g]=(0,Z.useState)(!1),[_,v]=(0,Z.useState)(!1),[y,b]=(0,Z.useState)(!1),[x,S]=(0,Z.useState)(!1),C=(0,Z.useCallback)(()=>{o(!1)},[]),w=(0,Z.useCallback)(async()=>{await i({chargeId:e}),n?.(),C()},[e,i,n,C]);return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(V,{shadow:`md`,width:200,opened:a,children:[(0,Q.jsx)(V.Target,{children:(0,Q.jsx)(jt,{opened:a,onClick:e=>{e.stopPropagation(),o(e=>!e)}})}),(0,Q.jsxs)(V.Dropdown,{children:[(0,Q.jsx)(V.Label,{children:`Charge`}),(0,Q.jsx)(V.Item,{icon:(0,Q.jsx)(Be,{size:14}),onClick:()=>{v(!0),C()},children:`Edit Charge`}),(0,Q.jsx)(bt,{onConfirm:w,title:`Are you sure you want to delete this charge?`,children:(0,Q.jsx)(V.Item,{icon:(0,Q.jsx)(lt,{size:14}),children:`Delete Charge`})}),(0,Q.jsx)(V.Divider,{}),(0,Q.jsx)(V.Label,{children:`Documents`}),(0,Q.jsx)(V.Item,{icon:(0,Q.jsx)(Ke,{size:14}),onClick:e=>{e.stopPropagation(),b(!0),C()},children:`Insert Document`}),(0,Q.jsx)(V.Item,{icon:(0,Q.jsx)(Dn,{size:14}),onClick:e=>{e.stopPropagation(),S(!0),C()},children:`Upload Documents`}),r&&(0,Q.jsx)(V.Item,{icon:(0,Q.jsx)(Ke,{size:14}),onClick:e=>{e.stopPropagation(),g(!0),C()},children:`Issue Document`}),(0,Q.jsx)(V.Divider,{}),(0,Q.jsx)(V.Label,{children:`Misc Expenses`}),(0,Q.jsx)(V.Item,{icon:(0,Q.jsx)(Ke,{size:14}),onClick:e=>{e.stopPropagation(),C(),d(!0)},children:`Add expense`}),t===`CommonCharge`&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(V.Divider,{}),(0,Q.jsx)(V.Label,{children:`Depreciation`}),(0,Q.jsx)(V.Item,{icon:(0,Q.jsx)(En,{size:14}),onClick:e=>{e.stopPropagation(),c(),C()},children:`Depreciation`})]}),t===`SalaryCharge`&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(V.Divider,{}),(0,Q.jsx)(V.Label,{children:`Salaries`}),(0,Q.jsx)(V.Item,{icon:(0,Q.jsx)(Dn,{size:14}),onClick:e=>{e.stopPropagation(),C(),p()},children:`Payroll file upload`})]})]})]}),(0,Q.jsx)(_t,{withinPortal:!0,size:`xl`,centered:!0,opened:s,onClose:l,title:`Depreciation`,onClick:e=>e.stopPropagation(),children:(0,Q.jsx)(di,{chargeId:e,onChange:()=>{l(),n?.()}})}),(0,Q.jsx)(De,{open:u,onOpenChange:d,children:(0,Q.jsx)(_e,{className:`sm:max-w-[425px]`,onClick:e=>e.stopPropagation(),children:(0,Q.jsx)(Ue,{onDone:()=>{d(!1),n?.()},chargeId:e})})}),(0,Q.jsx)(_t,{centered:!0,opened:f,onClose:m,title:`Upload Payroll File`,onClick:e=>e.stopPropagation(),children:(0,Q.jsx)(Nt,{onDone:()=>{m(),n?.()},chargeId:e})}),(0,Q.jsx)(yt,{open:x,onOpenChange:S,onChange:n,chargeId:e}),(0,Q.jsx)(ft,{chargeId:e,open:h,setOpen:g,onDone:()=>n?.()}),(0,Q.jsx)(ht,{chargeId:_?e:void 0,close:()=>v(!1),onChange:()=>{v(!1),n?.()}}),(0,Q.jsx)(Me,{chargeId:y?e:void 0,onChange:n,close:()=>b(!1)})]})}function mi(e){return Object.prototype.toString.call(e)===`[object Object]`}function hi(e){return mi(e)||Array.isArray(e)}function gi(){return!!(typeof window<`u`&&window.document&&window.document.createElement)}function _i(e,t){let n=Object.keys(e),r=Object.keys(t);return n.length!==r.length||JSON.stringify(Object.keys(e.breakpoints||{}))!==JSON.stringify(Object.keys(t.breakpoints||{}))?!1:n.every(n=>{let r=e[n],i=t[n];return typeof r==`function`?`${r}`==`${i}`:!hi(r)||!hi(i)?r===i:_i(r,i)})}function vi(e){return e.concat().sort((e,t)=>e.name>t.name?1:-1).map(e=>e.options)}function yi(e,t){if(e.length!==t.length)return!1;let n=vi(e),r=vi(t);return n.every((e,t)=>{let n=r[t];return _i(e,n)})}function bi(e){return typeof e==`number`}function xi(e){return typeof e==`string`}function Si(e){return typeof e==`boolean`}function Ci(e){return Object.prototype.toString.call(e)===`[object Object]`}function $(e){return Math.abs(e)}function wi(e){return Math.sign(e)}function Ti(e,t){return $(e-t)}function Ei(e,t){return e===0||t===0||$(e)<=$(t)?0:$(Ti($(e),$(t))/e)}function Di(e){return Math.round(e*100)/100}function Oi(e){return Ni(e).map(Number)}function ki(e){return e[Ai(e)]}function Ai(e){return Math.max(0,e.length-1)}function ji(e,t){return t===Ai(e)}function Mi(e,t=0){return Array.from(Array(e),(e,n)=>t+n)}function Ni(e){return Object.keys(e)}function Pi(e,t){return[e,t].reduce((e,t)=>(Ni(t).forEach(n=>{let r=e[n],i=t[n];e[n]=Ci(r)&&Ci(i)?Pi(r,i):i}),e),{})}function Fi(e,t){return t.MouseEvent!==void 0&&e instanceof t.MouseEvent}function Ii(e,t){let n={start:r,center:i,end:a};function r(){return 0}function i(e){return a(e)/2}function a(e){return t-e}function o(r,i){return xi(e)?n[e](r):e(t,r,i)}return{measure:o}}function Li(){let e=[];function t(t,n,i,a={passive:!0}){let o;if(`addEventListener`in t)t.addEventListener(n,i,a),o=()=>t.removeEventListener(n,i,a);else{let e=t;e.addListener(i),o=()=>e.removeListener(i)}return e.push(o),r}function n(){e=e.filter(e=>e())}let r={add:t,clear:n};return r}function Ri(e,t,n,r){let i=Li(),a=1e3/60,o=null,s=0,c=0;function l(){i.add(e,`visibilitychange`,()=>{e.hidden&&m()})}function u(){p(),i.clear()}function d(e){if(!c)return;o||(o=e,n(),n());let i=e-o;for(o=e,s+=i;s>=a;)n(),s-=a;r(s/a),c&&=t.requestAnimationFrame(d)}function f(){c||=t.requestAnimationFrame(d)}function p(){t.cancelAnimationFrame(c),o=null,s=0,c=0}function m(){o=null,s=0}return{init:l,destroy:u,start:f,stop:p,update:n,render:r}}function zi(e,t){let n=t===`rtl`,r=e===`y`,i=r?`y`:`x`,a=r?`x`:`y`,o=!r&&n?-1:1,s=u(),c=d();function l(e){let{height:t,width:n}=e;return r?t:n}function u(){return r?`top`:n?`right`:`left`}function d(){return r?`bottom`:n?`left`:`right`}function f(e){return e*o}return{scroll:i,cross:a,startEdge:s,endEdge:c,measureSize:l,direction:f}}function Bi(e=0,t=0){let n=$(e-t);function r(t){return t<e}function i(e){return e>t}function a(e){return r(e)||i(e)}function o(n){return a(n)?r(n)?e:t:n}function s(e){return n?e-n*Math.ceil((e-t)/n):e}return{length:n,max:t,min:e,constrain:o,reachedAny:a,reachedMax:i,reachedMin:r,removeOffset:s}}function Vi(e,t,n){let{constrain:r}=Bi(0,e),i=e+1,a=o(t);function o(e){return n?$((i+e)%i):r(e)}function s(){return a}function c(e){return a=o(e),d}function l(e){return u().set(s()+e)}function u(){return Vi(e,s(),n)}let d={get:s,set:c,add:l,clone:u};return d}function Hi(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_,v){let{cross:y,direction:b}=e,x=[`INPUT`,`SELECT`,`TEXTAREA`],S={passive:!1},C=Li(),w=Li(),T=Bi(50,225).constrain(p.measure(20)),E={mouse:300,touch:400},D={mouse:500,touch:600},ee=m?43:25,te=!1,O=0,ne=0,re=!1,k=!1,ie=!1,A=!1;function ae(e){if(!v)return;function n(t){(Si(v)||v(e,t))&&P(t)}let r=t;C.add(r,`dragstart`,e=>e.preventDefault(),S).add(r,`touchmove`,()=>void 0,S).add(r,`touchend`,()=>void 0).add(r,`touchstart`,n).add(r,`mousedown`,n).add(r,`touchcancel`,I).add(r,`contextmenu`,I).add(r,`click`,ce,!0)}function oe(){C.clear(),w.clear()}function j(){let e=A?n:t;w.add(e,`touchmove`,F,S).add(e,`touchend`,I).add(e,`mousemove`,F,S).add(e,`mouseup`,I)}function se(e){let t=e.nodeName||``;return x.includes(t)}function M(){return(m?D:E)[A?`mouse`:`touch`]}function N(e,t){let n=d.add(wi(e)*-1),r=u.byDistance(e,!m).distance;return m||$(e)<T?r:g&&t?r*.5:u.byIndex(n.get(),0).distance}function P(e){let t=Fi(e,r);A=t,ie=m&&t&&!e.buttons&&te,te=Ti(i.get(),o.get())>=2,!(t&&e.button!==0)&&(se(e.target)||(re=!0,a.pointerDown(e),l.useFriction(0).useDuration(0),i.set(o),j(),O=a.readPoint(e),ne=a.readPoint(e,y),f.emit(`pointerDown`)))}function F(e){if(!Fi(e,r)&&e.touches.length>=2)return I(e);let t=a.readPoint(e),n=a.readPoint(e,y),o=Ti(t,O),c=Ti(n,ne);if(!k&&!A&&(!e.cancelable||(k=o>c,!k)))return I(e);let u=a.pointerMove(e);o>h&&(ie=!0),l.useFriction(.3).useDuration(.75),s.start(),i.add(b(u)),e.preventDefault()}function I(e){let t=u.byDistance(0,!1).index!==d.get(),n=a.pointerUp(e)*M(),r=N(b(n),t),i=Ei(n,r),o=ee-10*i,s=_+i/50;k=!1,re=!1,w.clear(),l.useDuration(o).useFriction(s),c.distance(r,!m),A=!1,f.emit(`pointerUp`)}function ce(e){ie&&=(e.stopPropagation(),e.preventDefault(),!1)}function L(){return re}return{init:ae,destroy:oe,pointerDown:L}}function Ui(e,t){let n,r;function i(e){return e.timeStamp}function a(n,r){let i=`client${(r||e.scroll)===`x`?`X`:`Y`}`;return(Fi(n,t)?n:n.touches[0])[i]}function o(e){return n=e,r=e,a(e)}function s(e){let t=a(e)-a(r),o=i(e)-i(n)>170;return r=e,o&&(n=e),t}function c(e){if(!n||!r)return 0;let t=a(r)-a(n),o=i(e)-i(n),s=i(e)-i(r)>170,c=t/o;return o&&!s&&$(c)>.1?c:0}return{pointerDown:o,pointerMove:s,pointerUp:c,readPoint:a}}function Wi(){function e(e){let{offsetTop:t,offsetLeft:n,offsetWidth:r,offsetHeight:i}=e;return{top:t,right:n+r,bottom:t+i,left:n,width:r,height:i}}return{measure:e}}function Gi(e){function t(t){return t/100*e}return{measure:t}}function Ki(e,t,n,r,i,a,o){let s=[e].concat(r),c,l,u=[],d=!1;function f(e){return i.measureSize(o.measure(e))}function p(i){if(!a)return;l=f(e),u=r.map(f);function o(n){for(let a of n){if(d)return;let n=a.target===e,o=r.indexOf(a.target),s=n?l:u[o];if($(f(n?e:r[o])-s)>=.5){i.reInit(),t.emit(`resize`);break}}}c=new ResizeObserver(e=>{(Si(a)||a(i,e))&&o(e)}),n.requestAnimationFrame(()=>{s.forEach(e=>c.observe(e))})}function m(){d=!0,c&&c.disconnect()}return{init:p,destroy:m}}function qi(e,t,n,r,i,a){let o=0,s=0,c=i,l=a,u=e.get(),d=0;function f(){let t=r.get()-e.get(),i=!c,a=0;return i?(o=0,n.set(r),e.set(r),a=t):(n.set(e),o+=t/c,o*=l,u+=o,e.add(o),a=u-d),s=wi(a),d=u,x}function p(){return $(r.get()-t.get())<.001}function m(){return c}function h(){return s}function g(){return o}function _(){return y(i)}function v(){return b(a)}function y(e){return c=e,x}function b(e){return l=e,x}let x={direction:h,duration:m,velocity:g,seek:f,settled:p,useBaseFriction:v,useBaseDuration:_,useFriction:b,useDuration:y};return x}function Ji(e,t,n,r,i){let a=i.measure(10),o=i.measure(50),s=Bi(.1,.99),c=!1;function l(){return!(c||!e.reachedAny(n.get())||!e.reachedAny(t.get()))}function u(i){if(!l())return;let c=$(e[e.reachedMin(t.get())?`min`:`max`]-t.get()),u=n.get()-t.get(),d=s.constrain(c/o);n.subtract(u*d),!i&&$(u)<a&&(n.set(e.constrain(n.get())),r.useDuration(25).useBaseFriction())}function d(e){c=!e}return{shouldConstrain:l,constrain:u,toggleActive:d}}function Yi(e,t,n,r,i){let a=Bi(-t+e,0),o=d(),s=u(),c=f();function l(e,t){return Ti(e,t)<=1}function u(){let e=o[0],t=ki(o);return Bi(o.lastIndexOf(e),o.indexOf(t)+1)}function d(){return n.map((e,t)=>{let{min:r,max:i}=a,o=a.constrain(e),s=!t,c=ji(n,t);return s?i:c||l(r,o)?r:l(i,o)?i:o}).map(e=>parseFloat(e.toFixed(3)))}function f(){if(t<=e+i)return[a.max];if(r===`keepSnaps`)return o;let{min:n,max:c}=s;return o.slice(n,c)}return{snapsContained:c,scrollContainLimit:s}}function Xi(e,t,n){let r=t[0];return{limit:Bi(n?r-e:ki(t),r)}}function Zi(e,t,n,r){let i=.1,{reachedMin:a,reachedMax:o}=Bi(t.min+i,t.max+i);function s(e){return e===1?o(n.get()):e===-1?a(n.get()):!1}function c(t){if(!s(t))return;let n=t*-1*e;r.forEach(e=>e.add(n))}return{loop:c}}function Qi(e){let{max:t,length:n}=e;function r(e){let r=e-t;return n?r/-n:0}return{get:r}}function $i(e,t,n,r,i){let{startEdge:a,endEdge:o}=e,{groupSlides:s}=i,c=d().map(t.measure),l=f(),u=p();function d(){return s(r).map(e=>ki(e)[o]-e[0][a]).map($)}function f(){return r.map(e=>n[a]-e[a]).map(e=>-$(e))}function p(){return s(l).map(e=>e[0]).map((e,t)=>e+c[t])}return{snaps:l,snapsAligned:u}}function ea(e,t,n,r,i,a){let{groupSlides:o}=i,{min:s,max:c}=r,l=u();function u(){let r=o(a),i=!e||t===`keepSnaps`;return n.length===1?[a]:i?r:r.slice(s,c).map((e,t,n)=>{let r=!t,i=ji(n,t);return r?Mi(ki(n[0])+1):i?Mi(Ai(a)-ki(n)[0]+1,ki(n)[0]):e})}return{slideRegistry:l}}function ta(e,t,n,r,i){let{reachedAny:a,removeOffset:o,constrain:s}=r;function c(e){return e.concat().sort((e,t)=>$(e)-$(t))[0]}function l(n){let r=e?o(n):s(n),{index:i}=t.map((e,t)=>({diff:u(e-r,0),index:t})).sort((e,t)=>$(e.diff)-$(t.diff))[0];return{index:i,distance:r}}function u(t,r){let i=[t,t+n,t-n];if(!e)return t;if(!r)return c(i);let a=i.filter(e=>wi(e)===r);return a.length?c(a):ki(i)-n}function d(e,n){return{index:e,distance:u(t[e]-i.get(),n)}}function f(n,r){let o=i.get()+n,{index:s,distance:c}=l(o),d=!e&&a(o);return!r||d?{index:s,distance:n}:{index:s,distance:n+u(t[s]-c,0)}}return{byDistance:f,byIndex:d,shortcut:u}}function na(e,t,n,r,i,a,o){function s(i){let s=i.distance,c=i.index!==t.get();a.add(s),s&&(r.duration()?e.start():(e.update(),e.render(1),e.update())),c&&(n.set(t.get()),t.set(i.index),o.emit(`select`))}function c(e,t){s(i.byDistance(e,t))}function l(e,n){let r=t.clone().set(e);s(i.byIndex(r.get(),n))}return{distance:c,index:l}}function ra(e,t,n,r,i,a,o,s){let c={passive:!0,capture:!0},l=0;function u(u){if(!s)return;function f(t){if(new Date().getTime()-l>10)return;o.emit(`slideFocusStart`),e.scrollLeft=0;let a=n.findIndex(e=>e.includes(t));bi(a)&&(i.useDuration(0),r.index(a,0),o.emit(`slideFocus`))}a.add(document,`keydown`,d,!1),t.forEach((e,t)=>{a.add(e,`focus`,e=>{(Si(s)||s(u,e))&&f(t)},c)})}function d(e){e.code===`Tab`&&(l=new Date().getTime())}return{init:u}}function ia(e){let t=e;function n(){return t}function r(e){t=o(e)}function i(e){t+=o(e)}function a(e){t-=o(e)}function o(e){return bi(e)?e:e.get()}return{get:n,set:r,add:i,subtract:a}}function aa(e,t){let n=e.scroll===`x`?o:s,r=t.style,i=null,a=!1;function o(e){return`translate3d(${e}px,0px,0px)`}function s(e){return`translate3d(0px,${e}px,0px)`}function c(t){if(a)return;let o=Di(e.direction(t));o!==i&&(r.transform=n(o),i=o)}function l(e){a=!e}function u(){a||(r.transform=``,t.getAttribute(`style`)||t.removeAttribute(`style`))}return{clear:u,to:c,toggleActive:l}}function oa(e,t,n,r,i,a,o,s,c){let l=.5,u=Oi(i),d=Oi(i).reverse(),f=_().concat(v());function p(e,t){return e.reduce((e,t)=>e-i[t],t)}function m(e,t){return e.reduce((e,n)=>p(e,t)>0?e.concat([n]):e,[])}function h(e){return a.map((n,i)=>({start:n-r[i]+l+e,end:n+t-l+e}))}function g(t,r,i){let a=h(r);return t.map(t=>{let r=i?0:-n,o=i?n:0,l=i?`end`:`start`,u=a[t][l];return{index:t,loopPoint:u,slideLocation:ia(-1),translate:aa(e,c[t]),target:()=>s.get()>u?r:o}})}function _(){let e=o[0];return g(m(d,e),n,!1)}function v(){return g(m(u,t-o[0]-1),-n,!0)}function y(){return f.every(({index:e})=>p(u.filter(t=>t!==e),t)<=.1)}function b(){f.forEach(e=>{let{target:t,translate:n,slideLocation:r}=e,i=t();i!==r.get()&&(n.to(i),r.set(i))})}function x(){f.forEach(e=>e.translate.clear())}return{canLoop:y,clear:x,loop:b,loopPoints:f}}function sa(e,t,n){let r,i=!1;function a(a){if(!n)return;function o(e){for(let n of e)if(n.type===`childList`){a.reInit(),t.emit(`slidesChanged`);break}}r=new MutationObserver(e=>{i||(Si(n)||n(a,e))&&o(e)}),r.observe(e,{childList:!0})}function o(){r&&r.disconnect(),i=!0}return{init:a,destroy:o}}function ca(e,t,n,r){let i={},a=null,o=null,s,c=!1;function l(){s=new IntersectionObserver(e=>{c||(e.forEach(e=>{let n=t.indexOf(e.target);i[n]=e}),a=null,o=null,n.emit(`slidesInView`))},{root:e.parentElement,threshold:r}),t.forEach(e=>s.observe(e))}function u(){s&&s.disconnect(),c=!0}function d(e){return Ni(i).reduce((t,n)=>{let r=parseInt(n),{isIntersecting:a}=i[r];return(e&&a||!e&&!a)&&t.push(r),t},[])}function f(e=!0){if(e&&a)return a;if(!e&&o)return o;let t=d(e);return e&&(a=t),e||(o=t),t}return{init:l,destroy:u,get:f}}function la(e,t,n,r,i,a){let{measureSize:o,startEdge:s,endEdge:c}=e,l=n[0]&&i,u=m(),d=h(),f=n.map(o),p=g();function m(){if(!l)return 0;let e=n[0];return $(t[s]-e[s])}function h(){if(!l)return 0;let e=a.getComputedStyle(ki(r));return parseFloat(e.getPropertyValue(`margin-${c}`))}function g(){return n.map((e,t,n)=>{let r=!t,i=ji(n,t);return r?f[t]+u:i?f[t]+d:n[t+1][s]-e[s]}).map($)}return{slideSizes:f,slideSizesWithGaps:p,startGap:u,endGap:d}}function ua(e,t,n,r,i,a,o,s,c){let{startEdge:l,endEdge:u,direction:d}=e,f=bi(n);function p(e,t){return Oi(e).filter(e=>e%t===0).map(n=>e.slice(n,n+t))}function m(e){return e.length?Oi(e).reduce((n,f,p)=>{let m=ki(n)||0,h=m===0,g=f===Ai(e),_=i[l]-a[m][l],v=i[l]-a[f][u],y=!r&&h?d(o):0,b=$(v-(!r&&g?d(s):0)-(_+y));return p&&b>t+c&&n.push(f),g&&n.push(e.length),n},[]).map((t,n,r)=>{let i=Math.max(r[n-1]||0);return e.slice(i,t)}):[]}function h(e){return f?p(e,n):m(e)}return{groupSlides:h}}function da(e,t,n,r,i,a,o){let{align:s,axis:c,direction:l,startIndex:u,loop:d,duration:f,dragFree:p,dragThreshold:m,inViewThreshold:h,slidesToScroll:g,skipSnaps:_,containScroll:v,watchResize:y,watchSlides:b,watchDrag:x,watchFocus:S}=a,C=Wi(),w=C.measure(t),T=n.map(C.measure),E=zi(c,l),D=E.measureSize(w),ee=Gi(D),te=Ii(s,D),O=!d&&!!v,{slideSizes:ne,slideSizesWithGaps:re,startGap:k,endGap:ie}=la(E,w,T,n,d||!!v,i),A=ua(E,D,g,d,w,T,k,ie,2),{snaps:ae,snapsAligned:oe}=$i(E,te,w,T,A),j=-ki(ae)+ki(re),{snapsContained:se,scrollContainLimit:M}=Yi(D,j,oe,v,2),N=O?se:oe,{limit:P}=Xi(j,N,d),F=Vi(Ai(N),u,d),I=F.clone(),ce=Oi(n),L=({dragHandler:e,scrollBody:t,scrollBounds:n,options:{loop:r}})=>{r||n.constrain(e.pointerDown()),t.seek()},le=({scrollBody:e,translate:t,location:n,offsetLocation:r,previousLocation:i,scrollLooper:a,slideLooper:o,dragHandler:s,animation:c,eventHandler:l,scrollBounds:u,options:{loop:d}},f)=>{let p=e.settled(),m=!u.shouldConstrain(),h=d?p:p&&m,g=h&&!s.pointerDown();g&&c.stop();let _=n.get()*f+i.get()*(1-f);r.set(_),d&&(a.loop(e.direction()),o.loop()),t.to(r.get()),g&&l.emit(`settle`),h||l.emit(`scroll`)},ue=Ri(r,i,()=>L(Ce),e=>le(Ce,e)),de=.68,fe=N[F.get()],pe=ia(fe),me=ia(fe),he=ia(fe),R=ia(fe),ge=qi(pe,he,me,R,f,de),_e=ta(d,N,j,P,R),ve=na(ue,F,I,ge,_e,R,o),ye=Qi(P),be=Li(),z=ca(t,n,o,h),{slideRegistry:xe}=ea(O,v,N,M,A,ce),Se=ra(e,n,xe,ve,ge,be,o,S),Ce={ownerDocument:r,ownerWindow:i,eventHandler:o,containerRect:w,slideRects:T,animation:ue,axis:E,dragHandler:Hi(E,e,r,i,R,Ui(E,i),pe,ue,ve,ge,_e,F,o,ee,p,m,_,de,x),eventStore:be,percentOfView:ee,index:F,indexPrevious:I,limit:P,location:pe,offsetLocation:he,previousLocation:me,options:a,resizeHandler:Ki(t,o,i,n,E,y,C),scrollBody:ge,scrollBounds:Ji(P,he,R,ge,ee),scrollLooper:Zi(j,P,he,[pe,he,me,R]),scrollProgress:ye,scrollSnapList:N.map(ye.get),scrollSnaps:N,scrollTarget:_e,scrollTo:ve,slideLooper:oa(E,D,j,ne,re,ae,N,he,n),slideFocus:Se,slidesHandler:sa(t,o,b),slidesInView:z,slideIndexes:ce,slideRegistry:xe,slidesToScroll:A,target:R,translate:aa(E,t)};return Ce}function fa(){let e={},t;function n(e){t=e}function r(t){return e[t]||[]}function i(e){return r(e).forEach(n=>n(t,e)),c}function a(t,n){return e[t]=r(t).concat([n]),c}function o(t,n){return e[t]=r(t).filter(e=>e!==n),c}function s(){e={}}let c={init:n,emit:i,off:o,on:a,clear:s};return c}var pa={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 ma(e){function t(e,t){return Pi(e,t||{})}function n(n){let r=n.breakpoints||{};return t(n,Ni(r).filter(t=>e.matchMedia(t).matches).map(e=>r[e]).reduce((e,n)=>t(e,n),{}))}function r(t){return t.map(e=>Ni(e.breakpoints||{})).reduce((e,t)=>e.concat(t),[]).map(e.matchMedia)}return{mergeOptions:t,optionsAtMedia:n,optionsMediaQueries:r}}function ha(e){let t=[];function n(n,r){return t=r.filter(({options:t})=>e.optionsAtMedia(t).active!==!1),t.forEach(t=>t.init(n,e)),r.reduce((e,t)=>Object.assign(e,{[t.name]:t}),{})}function r(){t=t.filter(e=>e.destroy())}return{init:n,destroy:r}}function ga(e,t,n){let r=e.ownerDocument,i=r.defaultView,a=ma(i),o=ha(a),s=Li(),c=fa(),{mergeOptions:l,optionsAtMedia:u,optionsMediaQueries:d}=a,{on:f,off:p,emit:m}=c,h=D,g=!1,_,v=l(pa,ga.globalOptions),y=l(v),b=[],x,S,C;function w(){let{container:t,slides:n}=y;S=(xi(t)?e.querySelector(t):t)||e.children[0];let r=xi(n)?S.querySelectorAll(n):n;C=[].slice.call(r||S.children)}function T(t){let n=da(e,S,C,r,i,t,c);return t.loop&&!n.slideLooper.canLoop()?T(Object.assign({},t,{loop:!1})):n}function E(e,t){g||(v=l(v,e),y=u(v),b=t||b,w(),_=T(y),d([v,...b.map(({options:e})=>e)]).forEach(e=>s.add(e,`change`,D)),y.active&&(_.translate.to(_.location.get()),_.animation.init(),_.slidesInView.init(),_.slideFocus.init(L),_.eventHandler.init(L),_.resizeHandler.init(L),_.slidesHandler.init(L),_.options.loop&&_.slideLooper.loop(),S.offsetParent&&C.length&&_.dragHandler.init(L),x=o.init(L,b)))}function D(e,t){let n=oe();ee(),E(l({startIndex:n},e),t),c.emit(`reInit`)}function ee(){_.dragHandler.destroy(),_.eventStore.clear(),_.translate.clear(),_.slideLooper.clear(),_.resizeHandler.destroy(),_.slidesHandler.destroy(),_.slidesInView.destroy(),_.animation.destroy(),o.destroy(),s.clear()}function te(){g||(g=!0,s.clear(),ee(),c.emit(`destroy`),c.clear())}function O(e,t,n){!y.active||g||(_.scrollBody.useBaseFriction().useDuration(t===!0?0:y.duration),_.scrollTo.index(e,n||0))}function ne(e){O(_.index.add(1).get(),e,-1)}function re(e){O(_.index.add(-1).get(),e,1)}function k(){return _.index.add(1).get()!==oe()}function ie(){return _.index.add(-1).get()!==oe()}function A(){return _.scrollSnapList}function ae(){return _.scrollProgress.get(_.offsetLocation.get())}function oe(){return _.index.get()}function j(){return _.indexPrevious.get()}function se(){return _.slidesInView.get()}function M(){return _.slidesInView.get(!1)}function N(){return x}function P(){return _}function F(){return e}function I(){return S}function ce(){return C}let L={canScrollNext:k,canScrollPrev:ie,containerNode:I,internalEngine:P,destroy:te,off:p,on:f,emit:m,plugins:N,previousScrollSnap:j,reInit:h,rootNode:F,scrollNext:ne,scrollPrev:re,scrollProgress:ae,scrollSnapList:A,scrollTo:O,selectedScrollSnap:oe,slideNodes:ce,slidesInView:se,slidesNotInView:M};return E(t,n),setTimeout(()=>c.emit(`init`),0),L}ga.globalOptions=void 0;function _a(e={},t=[]){let n=(0,Z.useRef)(e),r=(0,Z.useRef)(t),[i,a]=(0,Z.useState)(),[o,s]=(0,Z.useState)(),c=(0,Z.useCallback)(()=>{i&&i.reInit(n.current,r.current)},[i]);return(0,Z.useEffect)(()=>{_i(n.current,e)||(n.current=e,c())},[e,c]),(0,Z.useEffect)(()=>{yi(r.current,t)||(r.current=t,c())},[t,c]),(0,Z.useEffect)(()=>{if(gi()&&o){ga.globalOptions=_a.globalOptions;let e=ga(o,n.current,r.current);return a(e),()=>e.destroy()}else a(void 0)},[o,a]),[s,i]}_a.globalOptions=void 0;var[va,ya]=Je({context:`[@mantine/carousel] Carousel.Slide was rendered outside of Carousel context`}.context),ba=Object.defineProperty,xa=Object.defineProperties,Sa=Object.getOwnPropertyDescriptors,Ca=Object.getOwnPropertySymbols,wa=Object.prototype.hasOwnProperty,Ta=Object.prototype.propertyIsEnumerable,Ea=(e,t,n)=>t in e?ba(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Da=(e,t)=>{for(var n in t||={})wa.call(t,n)&&Ea(e,n,t[n]);if(Ca)for(var n of Ca(t))Ta.call(t,n)&&Ea(e,n,t[n]);return e},Oa=(e,t)=>xa(e,Sa(t)),ka=qt((e,{controlSize:t,controlsOffset:n,orientation:r,height:i,includeGapInSize:a,breakpoints:o=[],slideGap:s})=>{let c=r===`horizontal`,l=t=>{if(!a)return{};let n=q({size:t,sizes:e.spacing});return{[r===`horizontal`?`marginRight`:`marginBottom`]:`calc(${n} * -1)`}},u=o.some(e=>e.slideGap!==void 0||e.slideSize!==void 0)?dt(e,o).reduce((t,n)=>{let r=`maxWidth`in n?`max-width`:`min-width`,i=q({size:r===`max-width`?n.maxWidth:n.minWidth,sizes:e.breakpoints}),a=n.slideGap===void 0?void 0:K(n.slideGap),o=Jt(i)-(r===`max-width`?1:0);return t[`@media (${r}: ${K(o)})`]=l(a),t},{}):null;return{root:{position:`relative`},viewport:{height:K(i),overflow:`hidden`},container:Da(Da({display:`flex`,flexDirection:c?`row`:`column`,height:K(i)},l(s)),u),controls:{position:`absolute`,zIndex:1,left:c?0:`calc(50% - ${K(t)} / 2)`,right:c?0:void 0,top:c?`calc(50% - ${K(t)} / 2)`:0,bottom:c?void 0:0,display:`flex`,flexDirection:c?`row`:`column`,alignItems:`center`,justifyContent:`space-between`,paddingLeft:c?q({size:n,sizes:e.spacing}):void 0,paddingRight:c?q({size:n,sizes:e.spacing}):void 0,paddingTop:c?void 0:q({size:n,sizes:e.spacing}),paddingBottom:c?void 0:q({size:n,sizes:e.spacing}),pointerEvents:`none`},control:Oa(Da({display:`flex`,justifyContent:`center`,alignItems:`center`,minWidth:K(t),minHeight:K(t),borderRadius:K(t),pointerEvents:`all`,backgroundColor:e.white,color:e.black,boxShadow:e.shadows.md,opacity:e.colorScheme===`dark`?.65:.85,border:`${K(1)} solid ${e.colors.gray[3]}`,transition:`opacity 150ms ${e.transitionTimingFunction}`},e.fn.hover({opacity:1})),{"&:active":e.activeStyles}),indicators:{position:`absolute`,bottom:c?e.spacing.md:0,top:c?void 0:0,left:c?0:void 0,right:c?0:e.spacing.md,display:`flex`,flexDirection:c?`row`:`column`,justifyContent:`center`,gap:K(8),pointerEvents:`none`},indicator:{pointerEvents:`all`,width:K(c?25:5),height:K(c?5:25),borderRadius:e.radius.xl,backgroundColor:e.white,boxShadow:e.shadows.sm,opacity:.6,transition:`opacity 150ms ${e.transitionTimingFunction}`,"&[data-active]":{opacity:1}}}}),Aa=Object.defineProperty,ja=Object.getOwnPropertySymbols,Ma=Object.prototype.hasOwnProperty,Na=Object.prototype.propertyIsEnumerable,Pa=(e,t,n)=>t in e?Aa(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Fa=(e,t)=>{for(var n in t||={})Ma.call(t,n)&&Pa(e,n,t[n]);if(ja)for(var n of ja(t))Na.call(t,n)&&Pa(e,n,t[n]);return e},Ia=qt((e,{size:t,gap:n,orientation:r,includeGapInSize:i,breakpoints:a=[]})=>{let o=(t,n)=>{let a=q({size:t,sizes:e.spacing}),o=K(n),s=i?{[r===`horizontal`?`paddingRight`:`paddingBottom`]:a}:{[r===`horizontal`?`marginRight`:`marginBottom`]:a};return Fa({flex:`0 0 ${o}`},s)},s=a.some(e=>e.slideGap!==void 0||e.slideSize!==void 0)?dt(e,a).reduce((t,r)=>{let i=`maxWidth`in r?`max-width`:`min-width`,a=q({size:i===`max-width`?r.maxWidth:r.minWidth,sizes:e.breakpoints}),s=r.slideGap===void 0?n:r.slideGap,c=Jt(a)-(i===`max-width`?1:0);return t[`@media (${i}: ${K(c)})`]=o(s,r.slideSize),t},{}):null;return{slide:Fa(Fa({position:`relative`},o(n,t)),s)}}),La=Object.defineProperty,Ra=Object.getOwnPropertySymbols,za=Object.prototype.hasOwnProperty,Ba=Object.prototype.propertyIsEnumerable,Va=(e,t,n)=>t in e?La(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Ha=(e,t)=>{for(var n in t||={})za.call(t,n)&&Va(e,n,t[n]);if(Ra)for(var n of Ra(t))Ba.call(t,n)&&Va(e,n,t[n]);return e},Ua=(e,t)=>{var n={};for(var r in e)za.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&Ra)for(var r of Ra(e))t.indexOf(r)<0&&Ba.call(e,r)&&(n[r]=e[r]);return n},Wa=(0,Z.forwardRef)((e,t)=>{var n=e,{children:r,className:i,size:a,gap:o}=n,s=Ua(n,[`children`,`className`,`size`,`gap`]);let c=ya(),{classes:l,cx:u}=Ia({gap:o===void 0?c.slideGap:o,size:a===void 0?c.slideSize:a,orientation:c.orientation,includeGapInSize:c.includeGapInSize,breakpoints:c.breakpoints},{name:`Carousel`,classNames:c.classNames,styles:c.styles,unstyled:c.unstyled,variant:c.variant});return Z.createElement(hn,Ha({className:u(l.slide,i),ref:t},s),r)});Wa.displayName=`@mantine/carousel/CarouselSlide`;function Ga({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 Ka=Object.defineProperty,qa=Object.getOwnPropertySymbols,Ja=Object.prototype.hasOwnProperty,Ya=Object.prototype.propertyIsEnumerable,Xa=(e,t,n)=>t in e?Ka(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Za=(e,t)=>{for(var n in t||={})Ja.call(t,n)&&Xa(e,n,t[n]);if(qa)for(var n of qa(t))Ya.call(t,n)&&Xa(e,n,t[n]);return e},Qa=(e,t)=>{var n={};for(var r in e)Ja.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&qa)for(var r of qa(e))t.indexOf(r)<0&&Ya.call(e,r)&&(n[r]=e[r]);return n},$a={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},eo=(0,Z.forwardRef)((e,t)=>{let n=Yt(`Carousel`,$a,e),{children:r,className:i,getEmblaApi:a,onNextSlide:o,onPreviousSlide:s,onSlideChange:c,nextControlLabel:l,previousControlLabel:u,controlSize:d,controlsOffset:f,classNames:p,styles:m,unstyled:h,slideSize:g,slideGap:_,orientation:v,height:y,align:b,slidesToScroll:x,includeGapInSize:S,draggable:C,dragFree:w,loop:T,speed:E,initialSlide:D,inViewThreshold:ee,withControls:te,withIndicators:O,plugins:ne,nextControlIcon:re,previousControlIcon:k,breakpoints:ie,skipSnaps:A,containScroll:ae,withKeyboardEvents:oe,variant:j}=n,se=Qa(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`.split(`.`)),{classes:M,cx:N,theme:P}=ka({controlSize:d,controlsOffset:f,orientation:v,height:y,includeGapInSize:S,breakpoints:ie,slideGap:_},{name:`Carousel`,classNames:p,styles:m,unstyled:h,variant:j}),[F,I]=_a({axis:v===`horizontal`?`x`:`y`,direction:v===`horizontal`?P.dir:void 0,startIndex:D,loop:T,align:b,slidesToScroll:x,draggable:C,dragFree:w,speed:E,inViewThreshold:ee,skipSnaps:A,containScroll:ae},ne),[ce,L]=(0,Z.useState)(0),[le,ue]=(0,Z.useState)(0),de=(0,Z.useCallback)(e=>I&&I.scrollTo(e),[I]),fe=(0,Z.useCallback)(()=>{if(!I)return;let e=I.selectedScrollSnap();L(e),c?.(e)},[I,L]),pe=(0,Z.useCallback)(()=>{I?.scrollPrev(),s?.()},[I]),me=(0,Z.useCallback)(()=>{I?.scrollNext(),o?.()},[I]),he=(0,Z.useCallback)(e=>{oe&&(e.key===`ArrowRight`&&(e.preventDefault(),me()),e.key===`ArrowLeft`&&(e.preventDefault(),pe()))},[I]);(0,Z.useEffect)(()=>{if(I)return a?.(I),fe(),ue(I.scrollSnapList().length),I.on(`select`,fe),()=>{I.off(`select`,fe)}},[I,x]),(0,Z.useEffect)(()=>{I&&(I.reInit(),ue(I.scrollSnapList().length),L(e=>ct(e,0,Z.Children.toArray(r).length-1)))},[Z.Children.toArray(r).length,x]);let R=I?.canScrollPrev()||!1,ge=I?.canScrollNext()||!1,_e=Array(le).fill(0).map((e,t)=>Z.createElement(Le,{key:t,"data-active":t===ce||void 0,className:M.indicator,"aria-hidden":!0,tabIndex:-1,onClick:()=>de(t)}));return Z.createElement(va,{value:{slideGap:_,slideSize:g,embla:I,orientation:v,includeGapInSize:S,breakpoints:ie,classNames:p,styles:m,unstyled:h,variant:j}},Z.createElement(hn,Za({className:N(M.root,i),ref:t,onKeyDownCapture:he},se),Z.createElement(`div`,{className:M.viewport,ref:F},Z.createElement(`div`,{className:M.container},r)),O&&Z.createElement(`div`,{className:M.indicators},_e),te&&Z.createElement(`div`,{className:M.controls},Z.createElement(Le,{onClick:pe,className:M.control,"aria-label":u,"data-inactive":!R||void 0,tabIndex:R?0:-1},k===void 0?Z.createElement(Fe,{style:{transform:`rotate(${Ga({dir:P.dir,orientation:v,direction:`previous`})}deg)`}}):k),Z.createElement(Le,{onClick:me,className:M.control,"aria-label":l,"data-inactive":!ge||void 0,tabIndex:ge?0:-1},re===void 0?Z.createElement(Fe,{style:{transform:`rotate(${Ga({dir:P.dir,orientation:v,direction:`next`})}deg)`}}):re))))});eo.Slide=Wa,eo.displayName=`@mantine/carousel/Carousel`;var to=eo,no=({chargeProps:e,onChange:t})=>{let{additionalDocuments:n}=Y(m,e),[r,i]=(0,Z.useState)(void 0);return(0,Q.jsx)(`div`,{className:`container mx-auto text-gray-600 body-font`,children:n?.length>0?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{className:`flex flex-wrap`,children:(0,Q.jsx)(to,{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(e=>(0,Q.jsx)(to.Slide,{children:(0,Q.jsxs)(`div`,{className:`flex flex-col items-center`,children:[(0,Q.jsx)(`h2`,{className:`text-gray-900 text-base font-medium`,children:`documentType`in e?e.documentType:`Unprocessed`}),(0,Q.jsx)(`button`,{className:`mx-10`,onClick:()=>i(e.id),children:(0,Q.jsx)(`div`,{className:`flex rounded-lg h-full bg-gray-100 p-2 m-2 flex-col`,children:(0,Q.jsx)(gn,{src:e.image?.toString(),withPlaceholder:!0})})})]})},e.id))})}),(0,Q.jsx)(Et,{documentId:r,onDone:()=>i(void 0),onChange:t})]}):(0,Q.jsx)(xr,{color:`red`,children:`No Documents Related`})})},ro=({foreignAmount:e,localAmount:t,diff:n})=>{let r=e!=null&&e.currency!==u.Ils,i=n&&n.localAmount?.formatted!==t?.formatted,a=n&&n.foreignAmount?.formatted!==e?.formatted;return(0,Q.jsx)(`div`,{className:`flex flex-col`,children:(t||i)&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{className:`flex gap-2  items-center`,children:[r&&(0,Q.jsx)(`p`,{className:a?`line-through`:``,children:e.formatted}),a&&n.foreignAmount&&(0,Q.jsx)(`p`,{className:`border-2 border-yellow-500 rounded-md`,children:n.foreignAmount.formatted})]}),(0,Q.jsxs)(`div`,{className:`flex gap-2  items-center`,children:[t!=null&&(0,Q.jsx)(`p`,{className:i?`line-through`:``,children:t.formatted}),i&&n.localAmount&&(0,Q.jsx)(`p`,{className:`border-2 border-yellow-500 rounded-md`,children:n.localAmount.formatted})]})]})})},io=({account:e,diffAccount:t})=>{let n=t&&t?.id!==e?.id;return(0,Q.jsx)(`div`,{className:`flex flex-col whitespace-normal`,children:(e||n)&&(0,Q.jsxs)(Q.Fragment,{children:[e&&(0,Q.jsx)(me,{to:R.BUSINESSES.DETAIL(e.id),target:`_blank`,rel:`noreferrer`,onClick:e=>e.stopPropagation(),className:`inline-flex items-center font-semibold ${n?`line-through`:``}`,children:e.name}),n&&t&&(0,Q.jsx)(`div`,{className:`border-2 border-yellow-500 rounded-md`,children:(0,Q.jsx)(me,{to:R.BUSINESSES.DETAIL(t.id),target:`_blank`,rel:`noreferrer`,onClick:e=>e.stopPropagation(),className:`inline-flex items-center font-semibold`,children:t.name})})]})})},ao=({date:e,diff:t})=>{let n=e?un(new Date(e),`dd/MM/yy`):void 0,r=t?un(new Date(t),`dd/MM/yy`):void 0,i=r&&n!==r;return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`p`,{className:i?`line-through`:``,children:n??`Missing Data`}),i&&(0,Q.jsx)(`div`,{className:`flex flex-col border-2 border-yellow-500 rounded-md`,children:r})]})},oo=(e,t)=>{let n=e.original[t],r=e.original.diff?.[t];return!n&&!r},so=[{accessorKey:`invoiceDate`,header:({column:e})=>(0,Q.jsxs)(H,{variant:`ghost`,onClick:()=>e.toggleSorting(e.getIsSorted()===`asc`),children:[`Invoice Date`,e.getIsSorted()&&(e.getIsSorted()===`asc`?(0,Q.jsx)(z,{className:`ml-2 h-4 w-4`}):(0,Q.jsx)(B,{className:`ml-2 h-4 w-4`}))]}),cell:({row:e})=>(0,Q.jsx)(ao,{date:e.original.invoiceDate,diff:e.original.diff?.invoiceDate})},{accessorKey:`valueDate`,header:({column:e})=>(0,Q.jsxs)(H,{variant:`ghost`,onClick:()=>e.toggleSorting(e.getIsSorted()===`asc`),children:[`Value Date`,e.getIsSorted()&&(e.getIsSorted()===`asc`?(0,Q.jsx)(z,{className:`ml-2 h-4 w-4`}):(0,Q.jsx)(B,{className:`ml-2 h-4 w-4`}))]}),cell:({row:e})=>(0,Q.jsx)(ao,{date:e.original.valueDate,diff:e.original.diff?.valueDate})},{header:`Debit Account (Main)`,columns:[{accessorKey:`debitAccount1.name`,header:({column:e})=>(0,Q.jsxs)(H,{variant:`ghost`,onClick:()=>e.toggleSorting(e.getIsSorted()===`asc`),children:[`Account`,e.getIsSorted()&&(e.getIsSorted()===`asc`?(0,Q.jsx)(z,{className:`ml-2 h-4 w-4`}):(0,Q.jsx)(B,{className:`ml-2 h-4 w-4`}))]}),cell:({row:e})=>(0,Q.jsx)(io,{account:e.original.debitAccount1,diffAccount:e.original.diff?.debitAccount1})},{accessorKey:`localCurrencyDebitAmount1.raw`,header:({column:e})=>(0,Q.jsxs)(H,{variant:`ghost`,onClick:()=>e.toggleSorting(e.getIsSorted()===`asc`),children:[`Amount`,e.getIsSorted()&&(e.getIsSorted()===`asc`?(0,Q.jsx)(z,{className:`ml-2 h-4 w-4`}):(0,Q.jsx)(B,{className:`ml-2 h-4 w-4`}))]}),cell:({row:e})=>oo(e,`debitAccount1`)?null:(0,Q.jsx)(ro,{foreignAmount:e.original.debitAmount1,localAmount:e.original.localCurrencyDebitAmount1,diff:e.original.diff?{foreignAmount:e.original.diff.debitAmount1,localAmount:e.original.diff.localCurrencyDebitAmount1}:void 0})}]},{header:`Credit Account (Main)`,columns:[{accessorKey:`creditAccount1.name`,header:({column:e})=>(0,Q.jsxs)(H,{variant:`ghost`,onClick:()=>e.toggleSorting(e.getIsSorted()===`asc`),children:[`Account`,e.getIsSorted()&&(e.getIsSorted()===`asc`?(0,Q.jsx)(z,{className:`ml-2 h-4 w-4`}):(0,Q.jsx)(B,{className:`ml-2 h-4 w-4`}))]}),cell:({row:e})=>(0,Q.jsx)(io,{account:e.original.creditAccount1,diffAccount:e.original.diff?.creditAccount1})},{accessorKey:`localCurrencyCreditAmount1.raw`,header:({column:e})=>(0,Q.jsxs)(H,{variant:`ghost`,onClick:()=>e.toggleSorting(e.getIsSorted()===`asc`),children:[`Amount`,e.getIsSorted()&&(e.getIsSorted()===`asc`?(0,Q.jsx)(z,{className:`ml-2 h-4 w-4`}):(0,Q.jsx)(B,{className:`ml-2 h-4 w-4`}))]}),cell:({row:e})=>oo(e,`creditAccount1`)?null:(0,Q.jsx)(ro,{foreignAmount:e.original.creditAmount1,localAmount:e.original.localCurrencyCreditAmount1,diff:e.original.diff?{foreignAmount:e.original.diff.creditAmount1,localAmount:e.original.diff.localCurrencyCreditAmount1}:void 0})}]},{header:`Debit Account (Secondary)`,columns:[{accessorKey:`debitAccount2.name`,header:({column:e})=>(0,Q.jsxs)(H,{variant:`ghost`,onClick:()=>e.toggleSorting(e.getIsSorted()===`asc`),children:[`Account`,e.getIsSorted()&&(e.getIsSorted()===`asc`?(0,Q.jsx)(z,{className:`ml-2 h-4 w-4`}):(0,Q.jsx)(B,{className:`ml-2 h-4 w-4`}))]}),cell:({row:e})=>(0,Q.jsx)(io,{account:e.original.debitAccount2,diffAccount:e.original.diff?.debitAccount2})},{accessorKey:`localCurrencyDebitAmount2.raw`,header:({column:e})=>(0,Q.jsxs)(H,{variant:`ghost`,onClick:()=>e.toggleSorting(e.getIsSorted()===`asc`),children:[`Amount`,e.getIsSorted()&&(e.getIsSorted()===`asc`?(0,Q.jsx)(z,{className:`ml-2 h-4 w-4`}):(0,Q.jsx)(B,{className:`ml-2 h-4 w-4`}))]}),cell:({row:e})=>oo(e,`debitAccount2`)?null:(0,Q.jsx)(ro,{foreignAmount:e.original.debitAmount2,localAmount:e.original.localCurrencyDebitAmount2,diff:e.original.diff?{foreignAmount:e.original.diff.debitAmount2,localAmount:e.original.diff.localCurrencyDebitAmount2}:void 0})}]},{header:`Credit Account (Secondary)`,columns:[{accessorKey:`creditAccount2.name`,header:({column:e})=>(0,Q.jsxs)(H,{variant:`ghost`,onClick:()=>e.toggleSorting(e.getIsSorted()===`asc`),children:[`Account`,e.getIsSorted()&&(e.getIsSorted()===`asc`?(0,Q.jsx)(z,{className:`ml-2 h-4 w-4`}):(0,Q.jsx)(B,{className:`ml-2 h-4 w-4`}))]}),cell:({row:e})=>(0,Q.jsx)(io,{account:e.original.creditAccount2,diffAccount:e.original.diff?.creditAccount2})},{accessorKey:`localCurrencyCreditAmount2.raw`,header:({column:e})=>(0,Q.jsxs)(H,{variant:`ghost`,onClick:()=>e.toggleSorting(e.getIsSorted()===`asc`),children:[`Amount`,e.getIsSorted()&&(e.getIsSorted()===`asc`?(0,Q.jsx)(z,{className:`ml-2 h-4 w-4`}):(0,Q.jsx)(B,{className:`ml-2 h-4 w-4`}))]}),cell:({row:e})=>oo(e,`creditAccount2`)?null:(0,Q.jsx)(ro,{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})=>(0,Q.jsxs)(H,{variant:`ghost`,onClick:()=>e.toggleSorting(e.getIsSorted()===`asc`),children:[`Details`,e.getIsSorted()&&(e.getIsSorted()===`asc`?(0,Q.jsx)(z,{className:`ml-2 h-4 w-4`}):(0,Q.jsx)(B,{className:`ml-2 h-4 w-4`}))]}),cell:({row:{original:e}})=>{let t=e.diff&&e.diff.description!==e.description;return(0,Q.jsxs)(`div`,{className:`flex flex-col whitespace-normal`,children:[(0,Q.jsx)(`p`,{className:t?`line-through`:``,children:e.description}),t&&(0,Q.jsx)(`div`,{className:`border-2 border-yellow-500 rounded-md`,children:e.diff?.description})]})}},{accessorKey:`reference`,header:({column:e})=>(0,Q.jsxs)(H,{variant:`ghost`,onClick:()=>e.toggleSorting(e.getIsSorted()===`asc`),children:[`Reference`,e.getIsSorted()&&(e.getIsSorted()===`asc`?(0,Q.jsx)(z,{className:`ml-2 h-4 w-4`}):(0,Q.jsx)(B,{className:`ml-2 h-4 w-4`}))]}),cell:({row:{original:e}})=>{let t=e.diff&&e.diff.reference!==e.reference;return(0,Q.jsxs)(`div`,{className:`flex flex-col whitespace-normal`,children:[(0,Q.jsx)(`p`,{className:t?`line-through`:``,children:e.reference}),t&&(0,Q.jsx)(`div`,{className:`border-2 border-yellow-500 rounded-md`,children:e.diff?.reference})]})}},{accessorKey:`matchingStatus`,header:({column:e})=>(0,Q.jsxs)(H,{variant:`ghost`,onClick:()=>e.toggleSorting(e.getIsSorted()===`asc`),children:[`Status`,e.getIsSorted()&&(e.getIsSorted()===`asc`?(0,Q.jsx)(z,{className:`ml-2 h-4 w-4`}):(0,Q.jsx)(B,{className:`ml-2 h-4 w-4`}))]}),cell:({row:{original:{matchingStatus:e}}})=>e?(0,Q.jsx)(rn,{variant:`default`,className:e===`Deleted`?`bg-red-500`:e===`Diff`?`bg-yellow-500`:`bg-green-500`,children:e}):null}];function co(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}var lo=({ledgerRecordsData:e,ledgerDiffData:t,matches:n})=>{let[r,i]=(0,Z.useState)([]),a=tn({data:(0,Z.useMemo)(()=>{let r=e.map(e=>Y(y,e)),i=t?.map(e=>Y(y,e)),a=r.map(e=>{let t=i?.find(t=>t.id===e.id);return{...e,matchingStatus:!n||n?.includes(e.id)?void 0:t?`Diff`:`Deleted`,diff:t}}),o=i?.filter(e=>e.id===`00000000-0000-0000-0000-000000000000`).map(e=>({...e,matchingStatus:`New`}))??[];return a.push(...o),a},[e,t,n]),columns:so,getCoreRowModel:mn(),onSortingChange:i,getSortedRowModel:sn(),getPaginationRowModel:dn(),state:{sorting:r},initialState:{pagination:{pageIndex:0,pageSize:100},sorting:[{id:`invoiceDate`,desc:!0}]}});return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(pn,{children:[(0,Q.jsx)(en,{children:a.getHeaderGroups().map(e=>(0,Q.jsx)(ln,{children:e.headers.map(e=>(0,Q.jsx)(an,{className:`text-center`,colSpan:e.colSpan,children:e.isPlaceholder?null:fn(e.column.columnDef.header,e.getContext())},e.id))},e.id))}),(0,Q.jsx)(cn,{children:a.getRowModel().rows?.length?a.getRowModel().rows.map(e=>(0,Q.jsx)(ln,{"data-state":e.getIsSelected()&&`selected`,className:co(e.original.matchingStatus),children:e.getVisibleCells().map(e=>(0,Q.jsx)(X,{children:fn(e.column.columnDef.cell,e.getContext())},e.id))},e.id)):(0,Q.jsx)(ln,{children:(0,Q.jsx)(X,{colSpan:so.length,className:`h-24 text-center`,children:`No results.`})})})]}),(0,Q.jsx)(`div`,{className:`flex items-center justify-end space-x-2 py-4`,children:(0,Q.jsx)(pt,{currentPageIndex:a.getState().pagination.pageIndex,totalPages:a.getPageCount(),onChange:e=>a.setPageIndex(e)})})]})},uo=({data:e})=>{let t=Y(E,e);return t?.errorsLedger?.validate?.errors?.length?(0,Q.jsxs)($e,{shadow:`xs`,p:`md`,children:[(0,Q.jsx)(Zt,{c:`red`,children:`Errors:`}),(0,Q.jsx)(at,{size:`sm`,withPadding:!0,children:t.errorsLedger.validate.errors.map((e,t)=>(0,Q.jsx)(at.Item,{children:(0,Q.jsx)(Zt,{c:`red`,children:e})},t))})]}):null},fo=({transactionsProps:e,onChange:t})=>{let{transactions:n}=Y(C,e);return(0,Q.jsx)(Tn,{transactionsProps:n,onChange:t,enableEdit:!0})},po=`createDeposit`,mo=()=>{let[{fetching:e},t]=c(f);return{creating:e,createDeposit:(0,Z.useCallback)(async e=>{let n=`Error creating new deposit in currency ${e.currency}`,r=`${po}-${e.currency}`;I.loading(`Creating deposit`,{id:r});try{let i=le(await t(e),n,r);if(i)return I.success(`Deposit created`,{id:r,description:`Deposit ${i.createDeposit.id} (${i.createDeposit.currency}) created successfully`}),i.createDeposit.id}catch(e){console.error(`${n}: ${e}`),I.error(`Error`,{id:r,description:n,duration:1e5,closeButton:!0})}return null},[t])}},ho=({chargeId:e,onChange:t})=>{let[{data:n,fetching:r}]=w({query:p,variables:{chargeId:e}}),[{data:i,fetching:a}]=w({query:d}),{creating:o,createDeposit:s}=mo(),{assigning:c,assignChargeToDeposit:l}=Ft(),[f,m]=(0,Z.useState)(void 0),[h,g]=(0,Z.useState)(!1),[_,v]=(0,Z.useState)(`ILS`),y=(0,Z.useMemo)(()=>(i?.allDeposits??[]).filter(e=>e.isOpen),[i?.allDeposits]),b=(0,Z.useCallback)(async()=>{let n=await s({currency:_});n&&(await l({chargeId:e,depositId:n}),g(!1),t?.())},[s,l,_,e,t]),x=(0,Z.useCallback)(async()=>{f&&(await l({chargeId:e,depositId:f}),t?.())},[l,f,e,t]);return r||a||o||c?(0,Q.jsx)(ye,{className:`h-10 w-10 animate-spin`}):n?.depositByCharge?(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`div`,{className:`text-lg font-semibold mb-4`,children:[`Bank Deposit "`,n?.depositByCharge?.id,`" Balance:`,` `,n?.depositByCharge?.currentBalance.formatted]}),(0,Q.jsx)(`div`,{className:`mb-4`,children:(0,Q.jsx)(`span`,{className:`text-sm text-gray-500`,children:n?.depositByCharge?.isOpen?`Deposit is open`:`Deposit is closed`})}),(0,Q.jsx)(It,{depositId:n.depositByCharge.id})]}):(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsx)(`div`,{className:`text-sm text-gray-500`,children:`No bank deposit found for this charge.`}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-4 flex-wrap`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsxs)(Oe,{value:f,onValueChange:e=>m(e),children:[(0,Q.jsx)(Ce,{className:`min-w-[220px]`,children:(0,Q.jsx)(ge,{placeholder:y.length?`Select open deposit`:`No open deposits`})}),(0,Q.jsx)(we,{children:y.map(e=>(0,Q.jsxs)(Ee,{value:e.id,children:[e.id,` (`,e.currency,`)`]},e.id))})]}),(0,Q.jsx)(H,{variant:`secondary`,disabled:!f||c,onClick:x,children:c?`Assigning…`:`Assign`})]}),(0,Q.jsx)(H,{variant:`outline`,onClick:()=>g(!0),children:`Create New Deposit`})]}),(0,Q.jsx)(De,{open:h,onOpenChange:g,children:(0,Q.jsxs)(_e,{children:[(0,Q.jsx)(ve,{children:(0,Q.jsx)(be,{children:`Create Bank Deposit`})}),(0,Q.jsx)(`div`,{className:`space-y-4`,children:(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Q.jsx)(Te,{htmlFor:`deposit-currency-select`,children:`Currency`}),(0,Q.jsxs)(Oe,{value:_,onValueChange:e=>v(e),children:[(0,Q.jsx)(Ce,{className:`w-40`,children:(0,Q.jsx)(ge,{id:`deposit-currency-select`})}),(0,Q.jsx)(we,{children:Object.entries(u).map(([e,t])=>(0,Q.jsx)(Ee,{value:t,children:t},e))})]})]})}),(0,Q.jsx)(ke,{children:(0,Q.jsx)(H,{variant:`secondary`,disabled:o,onClick:b,children:o?`Creating…`:`Create`})})]})})]})};function go({row:e}){let[t,n]=(0,Z.useState)([`transactions`,`documents`]),[{data:r,fetching:i}]=w({query:s,variables:{chargeId:e.original.id??``},pause:!e.original.id}),a=r?.charge.transactions,o=!!a&&a.length>0,c=r?.charge.additionalDocuments,l=!!c&&c.length>0;return(0,Q.jsxs)(Ht,{type:`multiple`,value:t,onValueChange:n,className:`space-y-4`,children:[o&&(0,Q.jsxs)(G,{value:`transactions`,className:`rounded-lg border-2`,children:[(0,Q.jsx)(`div`,{className:`px-2 bg-gray-600/10 rounded-t-lg`,children:(0,Q.jsx)(U,{className:`p-2`,disabled:!o,children:(0,Q.jsx)(`h3`,{className:`font-semibold text-lg`,children:`Transactions`})})}),i?(0,Q.jsx)(W,{children:(0,Q.jsx)(`div`,{className:`p-2`,children:(0,Q.jsx)(gt,{})})}):(0,Q.jsx)(W,{children:a&&(0,Q.jsx)(`div`,{className:`p-2`,children:(0,Q.jsx)(Tn,{transactionsProps:a})})})]}),l&&(0,Q.jsxs)(G,{value:`documents`,className:`rounded-lg border-2`,children:[(0,Q.jsx)(`div`,{className:`px-2 bg-gray-600/10 rounded-t-lg`,children:(0,Q.jsx)(U,{className:`p-2`,disabled:!l,children:(0,Q.jsx)(`h3`,{className:`font-semibold text-lg`,children:`Documents`})})}),i?(0,Q.jsx)(W,{children:(0,Q.jsx)(`div`,{className:`p-2`,children:(0,Q.jsx)(gt,{})})}):(0,Q.jsx)(W,{children:c&&(0,Q.jsx)(`div`,{className:`p-2`,children:(0,Q.jsx)(Ot,{documentsProps:c})})})]})]})}var _o=({row:e})=>{let[t,n]=(0,Z.useState)(!1);return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(ln,{children:[e.getVisibleCells().map(e=>(0,Q.jsx)(X,{children:fn(e.column.columnDef.cell,e.getContext())},e.id)),(0,Q.jsx)(X,{children:(0,Q.jsx)(Re,{toggleExpansion:n,isExpanded:t})})]},e.id),t&&(0,Q.jsx)(ln,{children:(0,Q.jsx)(X,{colSpan:e.getVisibleCells().length+1,children:(0,Q.jsx)(go,{row:e})})},`${e.id}-extensions`)]})},vo=({business:e})=>e.id?(0,Q.jsx)(me,{to:R.BUSINESSES.DETAIL(e.id),target:`_blank`,rel:`noreferrer`,onClick:e=>e.stopPropagation(),className:`inline-flex items-center font-semibold`,children:e.name}):(0,Q.jsx)(`div`,{}),yo=({date:e})=>(0,Q.jsx)(`p`,{className:`text-sm font-medium`,children:e?ot(e):``}),bo=({tags:e})=>(0,Q.jsx)(St,{items:e.map(e=>(0,Q.jsx)(Xe,{children:(0,Q.jsxs)(`div`,{children:[e.namePath&&(0,Q.jsx)(Zt,{size:`xs`,opacity:.65,children:`${e.namePath.join(` > `)} >`}),(0,Q.jsx)(Zt,{size:`sm`,children:e.name})]})},e.id))}),xo=({taxCategory:e})=>(0,Q.jsx)(`p`,{className:`text-sm font-medium`,children:e?.name}),So=({type:e})=>{let{text:t,icon:n}=(0,Z.useMemo)(()=>({text:Pe(e),icon:He(e)}),[e]);return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{children:t}),(0,Q.jsx)(Ur,{radius:`xl`,size:`xl`,children:n})]})},Co=[{id:`select`,cell:({row:e})=>(0,Q.jsx)(Ne,{checked:e.original.isSelected,onCheckedChange:t=>(e.original.selectCharge(t?e.original.id:null),t),"aria-label":`Select charge`}),enableSorting:!1,enableHiding:!1},{accessorKey:`confidenceScore`,header:({column:e})=>(0,Q.jsx)(Ge,{column:e,title:`Score`}),cell:({row:e})=>(0,Q.jsx)(Ct,{value:e.getValue(`confidenceScore`)*100,size:`sm`})},{accessorKey:`type`,header:({column:e})=>(0,Q.jsx)(Ge,{column:e,title:`Type`}),cell:({row:e})=>(0,Q.jsx)(So,{type:e.getValue(`type`)})},{accessorKey:`date`,header:({column:e})=>(0,Q.jsx)(Ge,{column:e,title:`Date`}),cell:({row:e})=>(0,Q.jsx)(yo,{date:e.getValue(`date`)})},{accessorKey:`amountRaw`,header:({column:e})=>(0,Q.jsx)(Ge,{column:e,title:`Amount`}),cell:({row:e})=>{let t=e.original.amountFormatted;return(0,Q.jsx)(`p`,{className:`text-sm font-medium`,children:t})}},{accessorKey:`vatAmountRaw`,header:({column:e})=>(0,Q.jsx)(Ge,{column:e,title:`VAT`}),cell:({row:e})=>{let t=e.original.vatAmountFormatted;return(0,Q.jsx)(`p`,{className:`text-sm font-medium`,children:t})}},{accessorKey:`businessName`,header:({column:e})=>(0,Q.jsx)(Ge,{column:e,title:`Main Business`}),cell:({row:e})=>(0,Q.jsx)(vo,{business:{id:e.original.businessId,name:e.original.businessName}})},{accessorKey:`description`,header:({column:e})=>(0,Q.jsx)(Ge,{column:e,title:`Description`}),cell:({row:e})=>(0,Q.jsx)(`p`,{className:`text-sm font-medium max-w-100 whitespace-normal`,children:e.getValue(`description`)})},{accessorKey:`tags`,header:({column:e})=>(0,Q.jsx)(Ge,{column:e,title:`Tags`}),cell:({row:e})=>(0,Q.jsx)(bo,{tags:e.getValue(`tags`)}),enableSorting:!1},{accessorKey:`taxCategoryName`,header:({column:e})=>(0,Q.jsx)(Ge,{column:e,title:`Tax Category`}),cell:({row:e})=>(0,Q.jsx)(xo,{taxCategory:{id:e.original.taxCategoryId,name:e.original.taxCategoryName}})}];function wo(e,t,n){let r=Y(F,e),i=r.charge.minDocumentsDate||r.charge.minEventDate||r.charge.minDebitDate||void 0;return{id:r.charge.id,confidenceScore:r.confidenceScore,type:r.charge.__typename,date:i?new Date(i):void 0,amountRaw:r.charge.totalAmount?.raw,amountFormatted:r.charge.totalAmount?.formatted,vatAmountRaw:r.charge.vat?.raw,vatAmountFormatted:r.charge.vat?.formatted,businessId:r.charge.counterparty?.id,businessName:r.charge.counterparty?.name,description:r.charge.userDescription??void 0,tags:r.charge.tags.map(e=>({id:e.id,name:e.name,namePath:e.namePath??void 0})),taxCategoryId:r.charge.taxCategory?.id,taxCategoryName:r.charge.taxCategory?.name,selectCharge:t,isSelected:r.charge.id===n}}var To=({originChargeId:e,chargesProps:t,onChange:n})=>{let[r,i]=(0,Z.useState)([{id:`confidenceScore`,desc:!0},{id:`amountRaw`,desc:!0}]),[a,o]=(0,Z.useState)([]),[s,c]=(0,Z.useState)(null),[l,u]=(0,Z.useState)([{id:e,onChange:n}]);(0,Z.useEffect)(()=>{u([e,...s?[s]:[]].map(e=>({id:e,onChange:n})))},[s,n,e]);let d=tn({data:(0,Z.useMemo)(()=>t?.map(e=>wo(e,c,s)).sort((e,t)=>t.confidenceScore-e.confidenceScore)??[],[t,s]),columns:Co,getCoreRowModel:mn(),onSortingChange:i,getSortedRowModel:sn(),onColumnFiltersChange:o,getFilteredRowModel:nn(),state:{sorting:r,columnFilters:a}});return(0,Q.jsxs)(`div`,{className:`max-w-[90vw]`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center py-4 gap-4`,children:[(0,Q.jsx)(Qe,{selected:l,resetMerge:()=>c(null)}),(0,Q.jsxs)(zt,{children:[(0,Q.jsx)(Rt,{asChild:!0,className:`ml-auto`,children:(0,Q.jsxs)(H,{variant:`outline`,children:[`Columns `,(0,Q.jsx)(B,{})]})}),(0,Q.jsx)(Bt,{align:`end`,children:d.getAllColumns().filter(e=>e.getCanHide()).map(e=>(0,Q.jsx)(Lt,{className:`capitalize`,checked:e.getIsVisible(),onCheckedChange:t=>e.toggleVisibility(!!t),children:e.id},e.id))})]})]}),(0,Q.jsx)(`div`,{className:`overflow-hidden rounded-md border`,children:(0,Q.jsxs)(pn,{children:[(0,Q.jsx)(en,{children:d.getHeaderGroups().map(e=>(0,Q.jsxs)(ln,{children:[e.headers.map(e=>(0,Q.jsx)(an,{colSpan:e.colSpan,children:e.isPlaceholder?null:fn(e.column.columnDef.header,e.getContext())},e.id)),(0,Q.jsx)(an,{})]},e.id))}),(0,Q.jsx)(cn,{children:d.getRowModel().rows?.length?d.getRowModel().rows.map(e=>(0,Q.jsx)(_o,{row:e},e.id)):(0,Q.jsx)(ln,{children:(0,Q.jsx)(X,{colSpan:Co.length,className:`h-24 text-center`,children:`No results.`})})})]})})]})},Eo=({chargeId:e,isOpened:t,onChange:n})=>{let[{data:r,fetching:i}]=w({query:l,variables:{chargeId:e},pause:!t});return(0,Q.jsxs)(G,{value:`charges-matches`,children:[(0,Q.jsx)(U,{children:`Charge Matches`}),(0,Q.jsx)(W,{children:i?(0,Q.jsx)(ye,{className:`h-10 w-10 animate-spin`}):(0,Q.jsx)(To,{originChargeId:e,chargesProps:r?.findChargeMatches.matches,onChange:n})})]})},Do=({chargeProps:e})=>{let t=Y(fe,e);if(t.__typename!==`ConversionCharge`)return(0,Q.jsx)(Q.Fragment,{});let{eventRate:n,officialRate:r}=t;return(0,Q.jsxs)(kt,{justify:`center`,children:[r&&(0,Q.jsx)(kt.Col,{span:`content`,children:(0,Q.jsx)(_n,{shadow:`sm`,padding:`xs`,radius:`md`,withBorder:!0,children:(0,Q.jsxs)(Xe,{position:`apart`,children:[(0,Q.jsx)(Zt,{weight:500,children:`Official Conversion Rate`}),(0,Q.jsx)(xr,{color:`green`,variant:`light`,children:`${Number(r.rate)} ${Ze(r.from)} => ${Ze(r.to)}`})]})})}),n&&(0,Q.jsx)(kt.Col,{span:`content`,children:(0,Q.jsx)(_n,{shadow:`sm`,padding:`xs`,radius:`md`,withBorder:!0,children:(0,Q.jsxs)(Xe,{position:`apart`,children:[(0,Q.jsx)(Zt,{weight:500,children:`Bank Conversion Rate`}),(0,Q.jsx)(xr,{color:`green`,variant:`light`,children:`${Number(n.rate)} ${Ze(n.from)} => ${Ze(n.to)}`})]})})})]})},Oo=({chargeProps:e})=>{let t=Y(ie,e),n=(0,Z.useMemo)(()=>t.__typename===`CreditcardBankCharge`&&t.creditCardTransactions?t.creditCardTransactions.map(e=>Y(a,e)):[],[t]);return n.length?(0,Q.jsxs)(pn,{children:[(0,Q.jsx)(en,{children:(0,Q.jsxs)(ln,{children:[(0,Q.jsx)(an,{children:`Event Date`}),(0,Q.jsx)(an,{children:`Debit Date`}),(0,Q.jsx)(an,{children:`Amount`}),(0,Q.jsx)(an,{children:`Account`}),(0,Q.jsx)(an,{children:`Description`}),(0,Q.jsx)(an,{children:`Reference#`}),(0,Q.jsx)(an,{children:`Counterparty`}),(0,Q.jsx)(an,{children:`Charge`})]})}),(0,Q.jsx)(cn,{children:n.map(e=>{let t={...e,onUpdate:()=>void 0,editTransaction:()=>void 0,enableEdit:!1,enableChargeLink:!1};return(0,Q.jsxs)(ln,{children:[(0,Q.jsx)(X,{children:(0,Q.jsx)(wn,{transaction:t})}),(0,Q.jsx)(X,{children:(0,Q.jsx)(yn,{transaction:t})}),(0,Q.jsx)(X,{children:(0,Q.jsx)(Sn,{transaction:t})}),(0,Q.jsx)(X,{children:(0,Q.jsx)(vn,{transaction:t})}),(0,Q.jsx)(X,{children:(0,Q.jsx)(bn,{transaction:t})}),(0,Q.jsx)(X,{children:(0,Q.jsx)(Cn,{transaction:t})}),(0,Q.jsx)(X,{children:(0,Q.jsx)(xn,{transaction:t})}),(0,Q.jsx)(X,{children:(0,Q.jsx)(wt,{chargeId:e.chargeId})})]},e.id)})})]}):null},ko=({chargeProps:e})=>{let t=Y(ee,e),n=(0,Z.useMemo)(()=>t.__typename===`FinancialCharge`?Object.entries(t.exchangeRates??{}).sort((e,t)=>e[0].localeCompare(t[0])):[],[t]);return t.__typename===`FinancialCharge`?(0,Q.jsx)(`div`,{className:`flex flex-row flex-wrap gap-2 px-2`,children:n.map(([e,t])=>(0,Q.jsx)(Gt,{className:`gap-0 py-2`,children:(0,Q.jsxs)(Ut,{className:`flex flex-col px-2`,children:[(0,Q.jsx)(Wt,{className:`text-xl font-semibold`,children:e.toLocaleUpperCase()}),(0,Q.jsxs)(`div`,{className:`flex items-center space-x-2`,children:[(0,Q.jsxs)(`span`,{className:`whitespace-nowrap`,children:[Ze(e.toLocaleUpperCase()),`1=`]}),(0,Q.jsxs)(rn,{variant:`default`,className:`flex gap-1 rounded-lg text-md`,children:[Ze(u.Ils),t]})]})]})},e))}):(0,Q.jsx)(Q.Fragment,{})},Ao=`deleteMiscExpense`,jo=()=>{let[{fetching:e},t]=c(v);return{fetching:e,deleteMiscExpense:(0,Z.useCallback)(async e=>{let n=`Error deleting misc expense`,r=`${Ao}-${e.id}`;I.loading(`Deleting misc expense`,{id:r});try{let i=le(await t(e),n,r);if(i)return I.success(`Success`,{id:r,description:`Misc expense was deleted successfully`}),i.deleteMiscExpense}catch(e){console.error(`${n}: ${e}`),I.error(`Error`,{id:r,description:n,duration:1e5,closeButton:!0})}},[t])}};function Mo({miscExpenseId:e,onChange:t}){let{deleteMiscExpense:n}=jo();async function r(){try{await n({id:e}),t?.()}catch(e){let t=`Failed to delete misc expense`;console.error(`${t}: ${e}`),I.error(`Error`,{description:t})}}return(0,Q.jsx)(bt,{onConfirm:r,title:`Are you sure you want to delete this expense?`,children:(0,Q.jsx)(H,{className:`size-7.5 text-red-500`,variant:`ghost`,children:(0,Q.jsx)(lt,{className:`size-5`})})})}var No=({miscExpensesData:e,onChange:t})=>{let{miscExpenses:n}=Y(i,e);return(0,Q.jsxs)(`table`,{className:`w-full h-full`,children:[(0,Q.jsx)(`thead`,{children:(0,Q.jsxs)(`tr`,{children:[(0,Q.jsx)(`th`,{children:`Creditor`}),(0,Q.jsx)(`th`,{children:`Debtor`}),(0,Q.jsx)(`th`,{children:`Amount`}),(0,Q.jsx)(`th`,{children:`Invoice Date`}),(0,Q.jsx)(`th`,{children:`Value Date`}),(0,Q.jsx)(`th`,{children:`Description`}),(0,Q.jsx)(`th`,{children:`Actions`})]})}),(0,Q.jsx)(`tbody`,{children:n?.map(e=>(0,Q.jsxs)(`tr`,{children:[(0,Q.jsx)(`td`,{children:(0,Q.jsx)(`div`,{children:e.creditor?.name})}),(0,Q.jsx)(`td`,{children:(0,Q.jsx)(`div`,{children:e.debtor?.name})}),(0,Q.jsx)(`td`,{children:(0,Q.jsx)(`div`,{children:e.amount?.formatted})}),(0,Q.jsx)(`td`,{children:(0,Q.jsx)(`div`,{children:e.invoiceDate})}),(0,Q.jsx)(`td`,{children:(0,Q.jsx)(`div`,{children:e.valueDate&&un(new Date(e.valueDate),`yyyy-MM-dd`)})}),(0,Q.jsx)(`td`,{children:(0,Q.jsx)(`div`,{children:e.description})}),(0,Q.jsxs)(`td`,{children:[(0,Q.jsx)(nt,{onDone:t,data:e}),(0,Q.jsx)(Mo,{miscExpenseId:e.id,onChange:t})]})]},e?.id))})]})},Po=({salaryRecordsProps:e})=>{let t=Y(_,e);if(t.__typename!==`SalaryCharge`)return(0,Q.jsx)(Q.Fragment,{});let{salaryRecords:n}=t;return(0,Q.jsxs)(`table`,{className:`w-full h-full`,children:[(0,Q.jsx)(`thead`,{children:(0,Q.jsxs)(`tr`,{children:[(0,Q.jsx)(`th`,{children:`Employee`}),(0,Q.jsx)(`th`,{children:`Direct Salary`}),(0,Q.jsx)(`th`,{children:`Base Salary`}),(0,Q.jsx)(`th`,{children:`Pension`}),(0,Q.jsx)(`th`,{children:`Training Fund`}),(0,Q.jsx)(`th`,{children:`Social Security`}),(0,Q.jsx)(`th`,{children:`Tax`})]})}),(0,Q.jsx)(`tbody`,{children:n?.map(e=>(0,Q.jsxs)(`tr`,{children:[(0,Q.jsx)(`td`,{children:(0,Q.jsx)(`div`,{children:e.employee?.name??`Missing`})}),(0,Q.jsx)(`td`,{children:(0,Q.jsx)(`div`,{children:e.directAmount.formatted})}),(0,Q.jsx)(`td`,{children:(0,Q.jsx)(`div`,{children:e.baseAmount?.formatted})}),(0,Q.jsxs)(`td`,{children:[(0,Q.jsx)(`div`,{children:e.pensionFund?.name}),(0,Q.jsxs)(`div`,{children:[`Employee: `,e.pensionEmployeeAmount?.formatted]}),(0,Q.jsxs)(`div`,{children:[`Employer: `,e.pensionEmployerAmount?.formatted]}),(0,Q.jsxs)(`div`,{children:[`Compensation: `,e.compensationsAmount?.formatted]})]}),(0,Q.jsxs)(`td`,{children:[(0,Q.jsx)(`div`,{children:e.trainingFund?.name}),(0,Q.jsxs)(`div`,{children:[`Employee: `,e.trainingFundEmployeeAmount?.formatted]}),(0,Q.jsxs)(`div`,{children:[`Employer: `,e.trainingFundEmployerAmount?.formatted]})]}),(0,Q.jsxs)(`td`,{children:[(0,Q.jsxs)(`div`,{children:[`Employee: `,e.socialSecurityEmployeeAmount?.formatted]}),(0,Q.jsxs)(`div`,{children:[`Employer: `,e.socialSecurityEmployerAmount?.formatted]}),(0,Q.jsxs)(`div`,{children:[`Health: `,e.healthInsuranceAmount?.formatted]})]}),(0,Q.jsx)(`td`,{children:(0,Q.jsx)(`div`,{children:e.incomeTaxAmount?.formatted})})]},`${e.employee?.name}-${e.baseAmount}`))})]})};function Fo({chargeID:e,onChange:t=()=>void 0,fetching:n}){let[r,a]=(0,Z.useState)([]),[s,c]=(0,Z.useState)(e),[l,{toggle:u}]=Ye(!1),[d,f]=(0,Z.useState)(void 0),[{data:p,fetching:g},v]=w({query:j,variables:{chargeId:s}}),y=(0,Z.useCallback)(()=>{v(),t()},[v,t]);(0,Z.useEffect)(()=>{p?.charge&&f(p.charge)},[p]),(0,Z.useEffect)(()=>{n&&v()},[n,v]),(0,Z.useEffect)(()=>{e!==s&&(c(e),v())},[e,s,v]);let b=d?.__typename,x=!!d?.metadata?.ledgerCount,S=!!d?.metadata?.transactionsCount,T=!!d?.metadata?.documentsCount,D=!!d?.metadata?.receiptsCount,te=!!d?.metadata?.invoicesCount,O=b===`SalaryCharge`,ne=!!d?.miscExpenses?.length,re=d?.metadata?.openDocuments,k=(d?.totalAmount?.raw??0)>0&&!D,A=!(te||D)||!S;(0,Z.useEffect)(()=>{S&&a(e=>e.includes(`transactions`)?e:[...e,`transactions`])},[S]),(0,Z.useEffect)(()=>{T&&a(e=>e.includes(`documents`)?e:[...e,`documents`])},[T]),(0,Z.useEffect)(()=>{x&&a(e=>e.includes(`ledger`)?e:[...e,`ledger`])},[x]),(0,Z.useEffect)(()=>{O&&a(e=>e.includes(`salaries`)?e:[...e,`salaries`])},[O]),(0,Z.useEffect)(()=>{ne&&a(e=>e.includes(`miscExpenses`)?e:[...e,`miscExpenses`])},[ne]);let ae=J(j,m,d),oe=J(j,h,d),se=J(j,o,d),M=J(j,C,d),N=J(j,i,d),P=(0,Z.useMemo)(()=>b===`ConversionCharge`&&J(j,fe,d),[d,b]),F=(0,Z.useMemo)(()=>b===`FinancialCharge`&&J(j,ee,d),[d,b]),I=b===`SalaryCharge`&&J(j,_,d),ce=(0,Z.useMemo)(()=>b===`CreditcardBankCharge`&&J(j,ie,d),[d,b]);return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[g&&(0,Q.jsx)(Kt,{className:`flex self-center my-5`,color:`dark`,size:`xl`,variant:`dots`}),J(j,E,d)&&(0,Q.jsx)(uo,{data:d}),d&&(0,Q.jsxs)(`div`,{className:`flex flex-row`,children:[(0,Q.jsxs)(Ht,{className:`w-full`,type:`multiple`,value:r,onValueChange:a,children:[b===`ConversionCharge`&&(0,Q.jsxs)(G,{value:`conversion`,children:[(0,Q.jsx)(U,{disabled:!S,children:`Conversion Info`}),(0,Q.jsx)(W,{children:P&&(0,Q.jsx)(Do,{chargeProps:d})})]}),b===`FinancialCharge`&&(0,Q.jsxs)(G,{value:`exchangeRates`,children:[(0,Q.jsx)(U,{disabled:!F,children:`Exchange Rates`}),(0,Q.jsx)(W,{children:F&&(0,Q.jsx)(ko,{chargeProps:d})})]}),S&&(0,Q.jsxs)(G,{value:`transactions`,children:[(0,Q.jsx)(U,{disabled:!S,children:(0,Q.jsxs)(`div`,{className:`flex flex-row items-center gap-2 justify-between w-full`,children:[`Transactions`,k&&(0,Q.jsx)(ft,{chargeId:d.id})]})}),(0,Q.jsx)(W,{children:M&&(0,Q.jsx)(fo,{transactionsProps:d,onChange:y})})]}),ne&&(0,Q.jsxs)(G,{value:`miscExpenses`,children:[(0,Q.jsx)(U,{disabled:!ne,children:`Misc Expenses`}),(0,Q.jsx)(W,{children:N&&(0,Q.jsx)(No,{miscExpensesData:d,onChange:y})})]}),T&&(0,Q.jsxs)(G,{value:`documents`,children:[(0,Q.jsx)(U,{disabled:!T,children:(0,Q.jsxs)(`div`,{className:`flex flex-row items-center gap-2 justify-between w-full`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-row items-center gap-2 justify-start`,children:[T&&(0,Q.jsx)(At,{content:`Documents Gallery`,children:(0,Q.jsx)(H,{onClick:e=>{e.stopPropagation(),u()},variant:`outline`,disabled:!ae,size:`icon`,className:`size-7.5 text-gray-500`,children:(0,Q.jsx)(We,{className:`size-5`})})}),`Documents`]}),re&&(0,Q.jsx)(ft,{chargeId:d.id})]})}),(0,Q.jsx)(W,{children:oe&&(0,Q.jsx)(Ot,{documentsProps:Y(h,d)?.additionalDocuments,onChange:y})})]}),b===`SalaryCharge`&&(0,Q.jsxs)(G,{value:`salaries`,children:[(0,Q.jsx)(U,{disabled:!O,children:`Salaries`}),(0,Q.jsx)(W,{children:I&&(0,Q.jsx)(Po,{salaryRecordsProps:d})})]}),d.__typename===`BusinessTripCharge`&&(0,Q.jsxs)(G,{value:`businessTrip`,children:[(0,Q.jsx)(U,{children:`Business Trip`}),(0,Q.jsx)(W,{children:(0,Q.jsx)(mt,{data:d.businessTrip})})]}),b===`CreditcardBankCharge`&&(0,Q.jsxs)(G,{value:`creditcard`,children:[(0,Q.jsx)(U,{children:`CreditCard Transactions`}),(0,Q.jsx)(W,{children:ce&&(0,Q.jsx)(Oo,{chargeProps:d})})]}),x&&(0,Q.jsxs)(G,{value:`ledger`,children:[(0,Q.jsx)(U,{disabled:!x,onClick:e=>{e.stopPropagation()},children:(0,Q.jsxs)(`div`,{className:`flex flex-row items-center gap-2 justify-start w-full`,children:[!d.metadata?.isLedgerLocked&&(0,Q.jsx)(vt,{chargeId:d.id,onChange:y,variant:`outline`}),`Ledger Records`]})}),(0,Q.jsx)(W,{children:se&&(0,Q.jsx)(Io,{data:d})})]}),b===`BankDepositCharge`&&(0,Q.jsxs)(G,{value:`bankDeposit`,children:[(0,Q.jsx)(U,{children:`Bank Deposit`}),(0,Q.jsx)(W,{children:(0,Q.jsx)(ho,{chargeId:d.id})})]}),A&&(0,Q.jsx)(Eo,{chargeId:d.id,onChange:y,isOpened:r.includes(`charges-matches`)})]}),ae&&(0,Q.jsx)(hn,{maw:`1/6`,children:(0,Q.jsx)(Zn,{in:l,transitionDuration:500,transitionTimingFunction:`linear`,children:(0,Q.jsx)(no,{chargeProps:d,onChange:y})})})]}),!g&&!d&&(0,Q.jsx)(`p`,{children:`Error fetching extended information for this charge`})]})}var Io=({data:e})=>{let{ledger:t}=Y(o,e);return(0,Q.jsx)(lo,{ledgerRecordsData:t.records,ledgerDiffData:t.validate?.differences,matches:t.validate?.matches})},Lo=({toggleMergeCharge:e,isSelectedForMerge:t,data:n,isAllOpened:r})=>{let[i,a]=(0,Z.useState)(!1),[o,s]=(0,Z.useState)(Y(D,n)),[{data:c,fetching:l},u]=w({query:S,pause:!0,variables:{chargeId:n.id}}),d=u;(0,Z.useEffect)(()=>{let e=c?.charge;e&&s(Y(D,e))},[c]),(0,Z.useEffect)(()=>{s(Y(D,n))},[n]),(0,Z.useEffect)(()=>{a(r)},[r]);let f=(0,Z.useMemo)(()=>!!(o.metadata?.documentsCount||o.metadata?.transactionsCount||o.metadata?.ledgerCount||o.metadata?.miscExpensesCount),[o.metadata?.documentsCount,o.metadata?.transactionsCount,o.metadata?.ledgerCount,o.metadata?.miscExpensesCount]),p=(o?.totalAmount?.raw??0)>0;return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`tr`,{onClick:()=>{f&&(a(e=>!e),d())},children:[(0,Q.jsx)($r,{data:o}),(0,Q.jsx)(Jr,{data:o}),(0,Q.jsx)(Gr,{data:o}),(0,Q.jsx)(ei,{data:o}),J(D,k,o)?(0,Q.jsx)(qr,{data:o}):(0,Q.jsx)(`td`,{}),(0,Q.jsx)(Yr,{data:o,onChange:d}),J(D,ae,o)?(0,Q.jsx)(Zr,{data:o,onChange:d}):(0,Q.jsx)(`td`,{}),J(D,de,o)?(0,Q.jsx)(Qr,{data:o}):(0,Q.jsx)(`td`,{}),J(D,ue,o)?(0,Q.jsx)(Kr,{data:o}):(0,Q.jsx)(`td`,{}),(0,Q.jsx)(Xr,{data:o}),(0,Q.jsx)(Wr,{data:o,onChange:d}),(0,Q.jsx)(`td`,{children:(0,Q.jsx)(`div`,{className:`flex flex-col gap-2`,children:e&&(0,Q.jsx)(Ie,{toggleMergeSelected:()=>e(d),mergeSelected:t})})}),(0,Q.jsx)(`td`,{children:(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Q.jsx)(pi,{chargeId:o.id,chargeType:o.__typename,onChange:d,isIncome:p}),f&&(0,Q.jsx)(Re,{toggleExpansion:a,isExpanded:i,onClickAction:()=>d()})]})})]}),f&&i&&(0,Q.jsx)(`tr`,{children:(0,Q.jsx)(`td`,{colSpan:13,children:(0,Q.jsx)($e,{style:{width:`100%`},withBorder:!0,shadow:`lg`,children:(0,Q.jsx)(Fo,{chargeID:o.id,onChange:d,fetching:l})})})})]})},Ro=({toggleMergeCharge:e,mergeSelectedCharges:t,data:n,isAllOpened:r})=>{let i=n?.map(e=>Y(M,e))??[];return(0,Q.jsxs)(xt,{striped:!0,highlightOnHover:!0,children:[(0,Q.jsx)(`thead`,{className:`sticky top-0 z-20`,children:(0,Q.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:[(0,Q.jsx)(`th`,{children:`Type`}),(0,Q.jsx)(`th`,{children:`Date`}),(0,Q.jsx)(`th`,{children:`Amount`}),(0,Q.jsx)(`th`,{children:`Vat`}),(0,Q.jsx)(`th`,{children:`Counterparty`}),(0,Q.jsx)(`th`,{children:`Description`}),(0,Q.jsx)(`th`,{children:`Tags`}),(0,Q.jsx)(`th`,{children:`Tax Category`}),(0,Q.jsx)(`th`,{children:`Business Trip`}),(0,Q.jsx)(`th`,{children:`More Info`}),(0,Q.jsx)(`th`,{children:`Accountant Approval`}),(0,Q.jsx)(`th`,{children:`Edit`}),(0,Q.jsx)(`th`,{children:`More Info`})]})}),(0,Q.jsx)(`tbody`,{children:i?.map(n=>(0,Q.jsx)(Lo,{data:n,toggleMergeCharge:e?t=>e(n.id,t):void 0,isSelectedForMerge:t?.has(n.id)??!1,isAllOpened:r},n.id))})]})};export{Zn as a,Ur as i,Fo as n,lo as r,Ro as t};