@accounter/client 0.0.8-alpha-20251028004106-c68eb69188c4db0b88ba601e289828a33323cff6 → 0.0.8-alpha-20251028104443-6b90cabe7ee7130c620071b538fad7f55aadfde0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/CHANGELOG.md +8 -1
  2. package/dist/assets/{Checkbox-DjollWGm.js → Checkbox-StVWX8SV.js} +2 -2
  3. package/dist/assets/{Progress-AG7ZMAJu.js → Progress-mCoilW8a.js} +1 -1
  4. package/dist/assets/{Typography-Cd0kk1vc.js → Typography-nwkjB2uH.js} +1 -1
  5. package/dist/assets/{accordion-s9Ku08QQ.js → accordion-BJgt5vqo.js} +1 -1
  6. package/dist/assets/{accountant-approvals-Bqrsn1y5.js → accountant-approvals-DjkngqVI.js} +1 -1
  7. package/dist/assets/{all-charges-BQcsaMon.js → all-charges-BTWHzN8W.js} +1 -1
  8. package/dist/assets/{arrow-up-down-J-i_WnHP.js → arrow-up-down-Dc_JXNej.js} +2 -2
  9. package/dist/assets/{building-2-B92gXbOj.js → building-2-ClFm6mRd.js} +2 -2
  10. package/dist/assets/{business-CfqFJUkR.js → business-Rici9LJV.js} +7 -7
  11. package/dist/assets/{business-header-Cr5S_Mz7.js → business-header-BdKqniFy.js} +1 -1
  12. package/dist/assets/{business-transactions-single-BD4bLNv2.js → business-transactions-single-C9O13CYq.js} +1 -1
  13. package/dist/assets/{business-trip-DYkKK6Gk.js → business-trip-BX8ibyls.js} +1 -1
  14. package/dist/assets/{charges-filters-CoFkjW00.js → charges-filters-DOzODl9I.js} +1 -1
  15. package/dist/assets/{charges-ledger-validation-D_cg1bn-.js → charges-ledger-validation-CGhcwN-9.js} +1 -1
  16. package/dist/assets/{chart-CQ9Opsuw.js → chart-DJ8eRZgf.js} +1 -1
  17. package/dist/assets/{data-table-pagination-CN5CnGZV.js → data-table-pagination-BxG_nDcy.js} +3 -3
  18. package/dist/assets/{editable-business-trip--kNXo9tv.js → editable-business-trip-Ci_VRH4_.js} +4 -4
  19. package/dist/assets/{index-DfI9E1Fb.js → index-B9S5s-Ek.js} +97 -97
  20. package/dist/assets/{index-Cc4HfGhd.js → index-BMF6LQA_.js} +1 -1
  21. package/dist/assets/{index-C3pV-XkD.js → index-BNyi9p4R.js} +2 -2
  22. package/dist/assets/{index-CS40C1qp.js → index-BSGULXKk.js} +1 -1
  23. package/dist/assets/{index-DzNfXERJ.js → index-BcEle39T.js} +1 -1
  24. package/dist/assets/{index-DepseT6D.js → index-BgI9TyP-.js} +1 -1
  25. package/dist/assets/{index-DS_RReq_.js → index-Bicl-N_l.js} +1 -1
  26. package/dist/assets/{index-BWpLPx22.js → index-BoX2wDaq.js} +1 -1
  27. package/dist/assets/{index-n3bzj3IE.js → index-COkkiGA7.js} +1 -1
  28. package/dist/assets/{index-C66UYUUf.js → index-CUVdKjE4.js} +1 -1
  29. package/dist/assets/{index-C7al3ztL.js → index-Cb1trfXZ.js} +1 -1
  30. package/dist/assets/{index-CC_fLCrA.js → index-Ch50_8Vf.js} +7 -7
  31. package/dist/assets/{index-Cw9zbBbJ.js → index-ChD_fUFd.js} +1 -1
  32. package/dist/assets/{index-BSmbKLQe.js → index-CruPjjz7.js} +2 -2
  33. package/dist/assets/{index--XWh2RKR.js → index-DEUtVf1q.js} +1 -1
  34. package/dist/assets/{index-Au8Djmrz.js → index-DTqMRf6z.js} +1 -1
  35. package/dist/assets/{index-BNtiIPMq.js → index-Dbp9vffm.js} +1 -1
  36. package/dist/assets/{index-hr9hQe_a.js → index-DgNqZKRT.js} +1 -1
  37. package/dist/assets/{index-BGHdyfCs.js → index-DzOBVc67.js} +1 -1
  38. package/dist/assets/{index-DDGgWxhe.js → index-Hh1wVSCb.js} +3 -3
  39. package/dist/assets/{index-fwXllLnH.js → index-fkBrNyzZ.js} +1 -1
  40. package/dist/assets/{index-DVbMTBK4.js → index-ilIoUSGi.js} +1 -1
  41. package/dist/assets/{index-DNTlYcfH.js → index-wr9WcP9o.js} +1 -1
  42. package/dist/assets/{index.es-CKlpQqlO.js → index.es-Cx9yITXs.js} +1 -1
  43. package/dist/assets/{issue-document-B4kkfOo0.js → issue-document-BcS5_dW5.js} +1 -1
  44. package/dist/assets/{login-page-NvQKYh34.js → login-page-BsqoZbOr.js} +1 -1
  45. package/dist/assets/{missing-info-charges-DrF2b0mO.js → missing-info-charges-jo3EazSy.js} +1 -1
  46. package/dist/assets/{page-not-found-7AAOkZhu.js → page-not-found-Bg4Wi3Ik.js} +1 -1
  47. package/dist/assets/{pencil-DNPAJOPL.js → pencil-BArynLn7.js} +2 -2
  48. package/dist/assets/{report-commentary-row-CF-l1YIC.js → report-commentary-row-5CDlBkOP.js} +1 -1
  49. package/dist/assets/{save-D84vX5ea.js → save-ZDLsO-Uf.js} +2 -2
  50. package/dist/assets/{sub-BbpGm1pj.js → sub-DWCpbavW.js} +1 -1
  51. package/dist/assets/subMonths-DpFGzG8Q.js +1 -0
  52. package/dist/index.html +1 -1
  53. package/package.json +3 -3
  54. package/dist/assets/subMonths-0tIJizDp.js +0 -1
@@ -1,4 +1,4 @@
1
- import{d3 as so,d4 as Ds,d5 as Fs,d6 as zs,r as v,ai as Ie,d7 as $e,d8 as Ns,j as x,d9 as or,da as io,u as Bs,cZ as oo,c_ as ao,B as lo,c$ as co,V as uo,bO as In,bT as Br,db as Vr,H as Le,bP as fo,b1 as En,d0 as ho,dc as b,dd as Vs,X as po,de as mo,F as go,a as xo,df as yo,c as vo,L as bo,dg as wo}from"./index-DfI9E1Fb.js";import{u as Pt,g as De,a as Fe,c as je,s as W,_ as X,b as Ao,T as Mn}from"./Typography-Cd0kk1vc.js";import{c as Ue,t as jn,a as Co,d as hn,b as Po,e as ko,f as So,g as Io,h as Hs,o as Hr,i as Eo,s as Mo,l as jo,u as Oo,j as Us,k as Ro,p as To,m as _o,n as $o,q as Lo,r as Do,v as Fo,w as zo}from"./sequential-CAnleQny.js";import{s as Gs}from"./sub-BbpGm1pj.js";import"./subMonths-0tIJizDp.js";function No(e){const{theme:t,name:n,props:r}=e;return!t||!t.components||!t.components[n]||!t.components[n].defaultProps?r:so(t.components[n].defaultProps,r)}function Bo({props:e,name:t,defaultTheme:n,themeId:r}){let s=Ds(n);return s=s[r]||s,No({theme:s,name:t,props:e})}function Lt(){const e=Ds(Fs);return e[zs]||e}function ze({props:e,name:t}){return Bo({props:e,name:t,defaultTheme:Fs,themeId:zs})}function Un(e){return e&&e.ownerDocument||document}function Vo(e){return Un(e).defaultView||window}function Ur(e,t){typeof e=="function"?e(t):e&&(e.current=t)}function Ho(e){const{controlled:t,default:n}=e,{current:r}=v.useRef(t!==void 0),[s,i]=v.useState(n),o=r?t:s,a=v.useCallback(c=>{r||i(c)},[]);return[o,a]}function Uo(e){return typeof e=="string"}function Go(e,t,n){return e===void 0||Uo(e)?t:{...t,ownerState:{...t.ownerState,...n}}}function Xo(e,t,n){return typeof e=="function"?e(t,n):e}function Wo(e,t=[]){if(e===void 0)return{};const n={};return Object.keys(e).filter(r=>r.match(/^on[A-Z]/)&&typeof e[r]=="function"&&!t.includes(r)).forEach(r=>{n[r]=e[r]}),n}function Gr(e){if(e===void 0)return{};const t={};return Object.keys(e).filter(n=>!(n.match(/^on[A-Z]/)&&typeof e[n]=="function")).forEach(n=>{t[n]=e[n]}),t}function Yo(e){const{getSlotProps:t,additionalProps:n,externalSlotProps:r,externalForwardedProps:s,className:i}=e;if(!t){const h=Ie(n?.className,i,s?.className,r?.className),m={...n?.style,...s?.style,...r?.style},p={...n,...s,...r};return h.length>0&&(p.className=h),Object.keys(m).length>0&&(p.style=m),{props:p,internalRef:void 0}}const o=Wo({...s,...r}),a=Gr(r),c=Gr(s),l=t(o),u=Ie(l?.className,n?.className,i,s?.className,r?.className),d={...l?.style,...n?.style,...s?.style,...r?.style},f={...l,...n,...c,...a};return u.length>0&&(f.className=u),Object.keys(d).length>0&&(f.style=d),{props:f,internalRef:l.ref}}var re="top",fe="bottom",he="right",se="left",ar="auto",Dt=[re,fe,he,se],nt="start",kt="end",Ko="clippingParents",Xs="viewport",ht="popper",qo="reference",Xr=Dt.reduce(function(e,t){return e.concat([t+"-"+nt,t+"-"+kt])},[]),Ws=[].concat(Dt,[ar]).reduce(function(e,t){return e.concat([t,t+"-"+nt,t+"-"+kt])},[]),Qo="beforeRead",Zo="read",Jo="afterRead",ea="beforeMain",ta="main",na="afterMain",ra="beforeWrite",sa="write",ia="afterWrite",oa=[Qo,Zo,Jo,ea,ta,na,ra,sa,ia];function Ae(e){return e?(e.nodeName||"").toLowerCase():null}function ae(e){if(e==null)return window;if(e.toString()!=="[object Window]"){var t=e.ownerDocument;return t&&t.defaultView||window}return e}function Ke(e){var t=ae(e).Element;return e instanceof t||e instanceof Element}function ue(e){var t=ae(e).HTMLElement;return e instanceof t||e instanceof HTMLElement}function lr(e){if(typeof ShadowRoot>"u")return!1;var t=ae(e).ShadowRoot;return e instanceof t||e instanceof ShadowRoot}function aa(e){var t=e.state;Object.keys(t.elements).forEach(function(n){var r=t.styles[n]||{},s=t.attributes[n]||{},i=t.elements[n];!ue(i)||!Ae(i)||(Object.assign(i.style,r),Object.keys(s).forEach(function(o){var a=s[o];a===!1?i.removeAttribute(o):i.setAttribute(o,a===!0?"":a)}))})}function la(e){var t=e.state,n={popper:{position:t.options.strategy,left:"0",top:"0",margin:"0"},arrow:{position:"absolute"},reference:{}};return Object.assign(t.elements.popper.style,n.popper),t.styles=n,t.elements.arrow&&Object.assign(t.elements.arrow.style,n.arrow),function(){Object.keys(t.elements).forEach(function(r){var s=t.elements[r],i=t.attributes[r]||{},o=Object.keys(t.styles.hasOwnProperty(r)?t.styles[r]:n[r]),a=o.reduce(function(c,l){return c[l]="",c},{});!ue(s)||!Ae(s)||(Object.assign(s.style,a),Object.keys(i).forEach(function(c){s.removeAttribute(c)}))})}}const ca={name:"applyStyles",enabled:!0,phase:"write",fn:aa,effect:la,requires:["computeStyles"]};function we(e){return e.split("-")[0]}var Ye=Math.max,sn=Math.min,rt=Math.round;function Gn(){var e=navigator.userAgentData;return e!=null&&e.brands&&Array.isArray(e.brands)?e.brands.map(function(t){return t.brand+"/"+t.version}).join(" "):navigator.userAgent}function Ys(){return!/^((?!chrome|android).)*safari/i.test(Gn())}function st(e,t,n){t===void 0&&(t=!1),n===void 0&&(n=!1);var r=e.getBoundingClientRect(),s=1,i=1;t&&ue(e)&&(s=e.offsetWidth>0&&rt(r.width)/e.offsetWidth||1,i=e.offsetHeight>0&&rt(r.height)/e.offsetHeight||1);var o=Ke(e)?ae(e):window,a=o.visualViewport,c=!Ys()&&n,l=(r.left+(c&&a?a.offsetLeft:0))/s,u=(r.top+(c&&a?a.offsetTop:0))/i,d=r.width/s,f=r.height/i;return{width:d,height:f,top:u,right:l+d,bottom:u+f,left:l,x:l,y:u}}function cr(e){var t=st(e),n=e.offsetWidth,r=e.offsetHeight;return Math.abs(t.width-n)<=1&&(n=t.width),Math.abs(t.height-r)<=1&&(r=t.height),{x:e.offsetLeft,y:e.offsetTop,width:n,height:r}}function Ks(e,t){var n=t.getRootNode&&t.getRootNode();if(e.contains(t))return!0;if(n&&lr(n)){var r=t;do{if(r&&e.isSameNode(r))return!0;r=r.parentNode||r.host}while(r)}return!1}function Me(e){return ae(e).getComputedStyle(e)}function ua(e){return["table","td","th"].indexOf(Ae(e))>=0}function Ne(e){return((Ke(e)?e.ownerDocument:e.document)||window.document).documentElement}function pn(e){return Ae(e)==="html"?e:e.assignedSlot||e.parentNode||(lr(e)?e.host:null)||Ne(e)}function Wr(e){return!ue(e)||Me(e).position==="fixed"?null:e.offsetParent}function da(e){var t=/firefox/i.test(Gn()),n=/Trident/i.test(Gn());if(n&&ue(e)){var r=Me(e);if(r.position==="fixed")return null}var s=pn(e);for(lr(s)&&(s=s.host);ue(s)&&["html","body"].indexOf(Ae(s))<0;){var i=Me(s);if(i.transform!=="none"||i.perspective!=="none"||i.contain==="paint"||["transform","perspective"].indexOf(i.willChange)!==-1||t&&i.willChange==="filter"||t&&i.filter&&i.filter!=="none")return s;s=s.parentNode}return null}function Ft(e){for(var t=ae(e),n=Wr(e);n&&ua(n)&&Me(n).position==="static";)n=Wr(n);return n&&(Ae(n)==="html"||Ae(n)==="body"&&Me(n).position==="static")?t:n||da(e)||t}function ur(e){return["top","bottom"].indexOf(e)>=0?"x":"y"}function yt(e,t,n){return Ye(e,sn(t,n))}function fa(e,t,n){var r=yt(e,t,n);return r>n?n:r}function qs(){return{top:0,right:0,bottom:0,left:0}}function Qs(e){return Object.assign({},qs(),e)}function Zs(e,t){return t.reduce(function(n,r){return n[r]=e,n},{})}var ha=function(t,n){return t=typeof t=="function"?t(Object.assign({},n.rects,{placement:n.placement})):t,Qs(typeof t!="number"?t:Zs(t,Dt))};function pa(e){var t,n=e.state,r=e.name,s=e.options,i=n.elements.arrow,o=n.modifiersData.popperOffsets,a=we(n.placement),c=ur(a),l=[se,he].indexOf(a)>=0,u=l?"height":"width";if(!(!i||!o)){var d=ha(s.padding,n),f=cr(i),h=c==="y"?re:se,m=c==="y"?fe:he,p=n.rects.reference[u]+n.rects.reference[c]-o[c]-n.rects.popper[u],g=o[c]-n.rects.reference[c],y=Ft(i),w=y?c==="y"?y.clientHeight||0:y.clientWidth||0:0,A=p/2-g/2,C=d[h],P=w-f[u]-d[m],k=w/2-f[u]/2+A,E=yt(C,k,P),R=c;n.modifiersData[r]=(t={},t[R]=E,t.centerOffset=E-k,t)}}function ma(e){var t=e.state,n=e.options,r=n.element,s=r===void 0?"[data-popper-arrow]":r;s!=null&&(typeof s=="string"&&(s=t.elements.popper.querySelector(s),!s)||Ks(t.elements.popper,s)&&(t.elements.arrow=s))}const ga={name:"arrow",enabled:!0,phase:"main",fn:pa,effect:ma,requires:["popperOffsets"],requiresIfExists:["preventOverflow"]};function it(e){return e.split("-")[1]}var xa={top:"auto",right:"auto",bottom:"auto",left:"auto"};function ya(e,t){var n=e.x,r=e.y,s=t.devicePixelRatio||1;return{x:rt(n*s)/s||0,y:rt(r*s)/s||0}}function Yr(e){var t,n=e.popper,r=e.popperRect,s=e.placement,i=e.variation,o=e.offsets,a=e.position,c=e.gpuAcceleration,l=e.adaptive,u=e.roundOffsets,d=e.isFixed,f=o.x,h=f===void 0?0:f,m=o.y,p=m===void 0?0:m,g=typeof u=="function"?u({x:h,y:p}):{x:h,y:p};h=g.x,p=g.y;var y=o.hasOwnProperty("x"),w=o.hasOwnProperty("y"),A=se,C=re,P=window;if(l){var k=Ft(n),E="clientHeight",R="clientWidth";if(k===ae(n)&&(k=Ne(n),Me(k).position!=="static"&&a==="absolute"&&(E="scrollHeight",R="scrollWidth")),k=k,s===re||(s===se||s===he)&&i===kt){C=fe;var O=d&&k===P&&P.visualViewport?P.visualViewport.height:k[E];p-=O-r.height,p*=c?1:-1}if(s===se||(s===re||s===fe)&&i===kt){A=he;var j=d&&k===P&&P.visualViewport?P.visualViewport.width:k[R];h-=j-r.width,h*=c?1:-1}}var T=Object.assign({position:a},l&&xa),L=u===!0?ya({x:h,y:p},ae(n)):{x:h,y:p};if(h=L.x,p=L.y,c){var $;return Object.assign({},T,($={},$[C]=w?"0":"",$[A]=y?"0":"",$.transform=(P.devicePixelRatio||1)<=1?"translate("+h+"px, "+p+"px)":"translate3d("+h+"px, "+p+"px, 0)",$))}return Object.assign({},T,(t={},t[C]=w?p+"px":"",t[A]=y?h+"px":"",t.transform="",t))}function va(e){var t=e.state,n=e.options,r=n.gpuAcceleration,s=r===void 0?!0:r,i=n.adaptive,o=i===void 0?!0:i,a=n.roundOffsets,c=a===void 0?!0:a,l={placement:we(t.placement),variation:it(t.placement),popper:t.elements.popper,popperRect:t.rects.popper,gpuAcceleration:s,isFixed:t.options.strategy==="fixed"};t.modifiersData.popperOffsets!=null&&(t.styles.popper=Object.assign({},t.styles.popper,Yr(Object.assign({},l,{offsets:t.modifiersData.popperOffsets,position:t.options.strategy,adaptive:o,roundOffsets:c})))),t.modifiersData.arrow!=null&&(t.styles.arrow=Object.assign({},t.styles.arrow,Yr(Object.assign({},l,{offsets:t.modifiersData.arrow,position:"absolute",adaptive:!1,roundOffsets:c})))),t.attributes.popper=Object.assign({},t.attributes.popper,{"data-popper-placement":t.placement})}const ba={name:"computeStyles",enabled:!0,phase:"beforeWrite",fn:va,data:{}};var Ut={passive:!0};function wa(e){var t=e.state,n=e.instance,r=e.options,s=r.scroll,i=s===void 0?!0:s,o=r.resize,a=o===void 0?!0:o,c=ae(t.elements.popper),l=[].concat(t.scrollParents.reference,t.scrollParents.popper);return i&&l.forEach(function(u){u.addEventListener("scroll",n.update,Ut)}),a&&c.addEventListener("resize",n.update,Ut),function(){i&&l.forEach(function(u){u.removeEventListener("scroll",n.update,Ut)}),a&&c.removeEventListener("resize",n.update,Ut)}}const Aa={name:"eventListeners",enabled:!0,phase:"write",fn:function(){},effect:wa,data:{}};var Ca={left:"right",right:"left",bottom:"top",top:"bottom"};function en(e){return e.replace(/left|right|bottom|top/g,function(t){return Ca[t]})}var Pa={start:"end",end:"start"};function Kr(e){return e.replace(/start|end/g,function(t){return Pa[t]})}function dr(e){var t=ae(e),n=t.pageXOffset,r=t.pageYOffset;return{scrollLeft:n,scrollTop:r}}function fr(e){return st(Ne(e)).left+dr(e).scrollLeft}function ka(e,t){var n=ae(e),r=Ne(e),s=n.visualViewport,i=r.clientWidth,o=r.clientHeight,a=0,c=0;if(s){i=s.width,o=s.height;var l=Ys();(l||!l&&t==="fixed")&&(a=s.offsetLeft,c=s.offsetTop)}return{width:i,height:o,x:a+fr(e),y:c}}function Sa(e){var t,n=Ne(e),r=dr(e),s=(t=e.ownerDocument)==null?void 0:t.body,i=Ye(n.scrollWidth,n.clientWidth,s?s.scrollWidth:0,s?s.clientWidth:0),o=Ye(n.scrollHeight,n.clientHeight,s?s.scrollHeight:0,s?s.clientHeight:0),a=-r.scrollLeft+fr(e),c=-r.scrollTop;return Me(s||n).direction==="rtl"&&(a+=Ye(n.clientWidth,s?s.clientWidth:0)-i),{width:i,height:o,x:a,y:c}}function hr(e){var t=Me(e),n=t.overflow,r=t.overflowX,s=t.overflowY;return/auto|scroll|overlay|hidden/.test(n+s+r)}function Js(e){return["html","body","#document"].indexOf(Ae(e))>=0?e.ownerDocument.body:ue(e)&&hr(e)?e:Js(pn(e))}function vt(e,t){var n;t===void 0&&(t=[]);var r=Js(e),s=r===((n=e.ownerDocument)==null?void 0:n.body),i=ae(r),o=s?[i].concat(i.visualViewport||[],hr(r)?r:[]):r,a=t.concat(o);return s?a:a.concat(vt(pn(o)))}function Xn(e){return Object.assign({},e,{left:e.x,top:e.y,right:e.x+e.width,bottom:e.y+e.height})}function Ia(e,t){var n=st(e,!1,t==="fixed");return n.top=n.top+e.clientTop,n.left=n.left+e.clientLeft,n.bottom=n.top+e.clientHeight,n.right=n.left+e.clientWidth,n.width=e.clientWidth,n.height=e.clientHeight,n.x=n.left,n.y=n.top,n}function qr(e,t,n){return t===Xs?Xn(ka(e,n)):Ke(t)?Ia(t,n):Xn(Sa(Ne(e)))}function Ea(e){var t=vt(pn(e)),n=["absolute","fixed"].indexOf(Me(e).position)>=0,r=n&&ue(e)?Ft(e):e;return Ke(r)?t.filter(function(s){return Ke(s)&&Ks(s,r)&&Ae(s)!=="body"}):[]}function Ma(e,t,n,r){var s=t==="clippingParents"?Ea(e):[].concat(t),i=[].concat(s,[n]),o=i[0],a=i.reduce(function(c,l){var u=qr(e,l,r);return c.top=Ye(u.top,c.top),c.right=sn(u.right,c.right),c.bottom=sn(u.bottom,c.bottom),c.left=Ye(u.left,c.left),c},qr(e,o,r));return a.width=a.right-a.left,a.height=a.bottom-a.top,a.x=a.left,a.y=a.top,a}function ei(e){var t=e.reference,n=e.element,r=e.placement,s=r?we(r):null,i=r?it(r):null,o=t.x+t.width/2-n.width/2,a=t.y+t.height/2-n.height/2,c;switch(s){case re:c={x:o,y:t.y-n.height};break;case fe:c={x:o,y:t.y+t.height};break;case he:c={x:t.x+t.width,y:a};break;case se:c={x:t.x-n.width,y:a};break;default:c={x:t.x,y:t.y}}var l=s?ur(s):null;if(l!=null){var u=l==="y"?"height":"width";switch(i){case nt:c[l]=c[l]-(t[u]/2-n[u]/2);break;case kt:c[l]=c[l]+(t[u]/2-n[u]/2);break}}return c}function St(e,t){t===void 0&&(t={});var n=t,r=n.placement,s=r===void 0?e.placement:r,i=n.strategy,o=i===void 0?e.strategy:i,a=n.boundary,c=a===void 0?Ko:a,l=n.rootBoundary,u=l===void 0?Xs:l,d=n.elementContext,f=d===void 0?ht:d,h=n.altBoundary,m=h===void 0?!1:h,p=n.padding,g=p===void 0?0:p,y=Qs(typeof g!="number"?g:Zs(g,Dt)),w=f===ht?qo:ht,A=e.rects.popper,C=e.elements[m?w:f],P=Ma(Ke(C)?C:C.contextElement||Ne(e.elements.popper),c,u,o),k=st(e.elements.reference),E=ei({reference:k,element:A,placement:s}),R=Xn(Object.assign({},A,E)),O=f===ht?R:k,j={top:P.top-O.top+y.top,bottom:O.bottom-P.bottom+y.bottom,left:P.left-O.left+y.left,right:O.right-P.right+y.right},T=e.modifiersData.offset;if(f===ht&&T){var L=T[s];Object.keys(j).forEach(function($){var I=[he,fe].indexOf($)>=0?1:-1,M=[re,fe].indexOf($)>=0?"y":"x";j[$]+=L[M]*I})}return j}function ja(e,t){t===void 0&&(t={});var n=t,r=n.placement,s=n.boundary,i=n.rootBoundary,o=n.padding,a=n.flipVariations,c=n.allowedAutoPlacements,l=c===void 0?Ws:c,u=it(r),d=u?a?Xr:Xr.filter(function(m){return it(m)===u}):Dt,f=d.filter(function(m){return l.indexOf(m)>=0});f.length===0&&(f=d);var h=f.reduce(function(m,p){return m[p]=St(e,{placement:p,boundary:s,rootBoundary:i,padding:o})[we(p)],m},{});return Object.keys(h).sort(function(m,p){return h[m]-h[p]})}function Oa(e){if(we(e)===ar)return[];var t=en(e);return[Kr(e),t,Kr(t)]}function Ra(e){var t=e.state,n=e.options,r=e.name;if(!t.modifiersData[r]._skip){for(var s=n.mainAxis,i=s===void 0?!0:s,o=n.altAxis,a=o===void 0?!0:o,c=n.fallbackPlacements,l=n.padding,u=n.boundary,d=n.rootBoundary,f=n.altBoundary,h=n.flipVariations,m=h===void 0?!0:h,p=n.allowedAutoPlacements,g=t.options.placement,y=we(g),w=y===g,A=c||(w||!m?[en(g)]:Oa(g)),C=[g].concat(A).reduce(function(q,H){return q.concat(we(H)===ar?ja(t,{placement:H,boundary:u,rootBoundary:d,padding:l,flipVariations:m,allowedAutoPlacements:p}):H)},[]),P=t.rects.reference,k=t.rects.popper,E=new Map,R=!0,O=C[0],j=0;j<C.length;j++){var T=C[j],L=we(T),$=it(T)===nt,I=[re,fe].indexOf(L)>=0,M=I?"width":"height",_=St(t,{placement:T,boundary:u,rootBoundary:d,altBoundary:f,padding:l}),D=I?$?he:se:$?fe:re;P[M]>k[M]&&(D=en(D));var F=en(D),V=[];if(i&&V.push(_[L]<=0),a&&V.push(_[D]<=0,_[F]<=0),V.every(function(q){return q})){O=T,R=!1;break}E.set(T,V)}if(R)for(var N=m?3:1,U=function(H){var Q=C.find(function(Y){var K=E.get(Y);if(K)return K.slice(0,H).every(function(Z){return Z})});if(Q)return O=Q,"break"},G=N;G>0;G--){var ie=U(G);if(ie==="break")break}t.placement!==O&&(t.modifiersData[r]._skip=!0,t.placement=O,t.reset=!0)}}const Ta={name:"flip",enabled:!0,phase:"main",fn:Ra,requiresIfExists:["offset"],data:{_skip:!1}};function Qr(e,t,n){return n===void 0&&(n={x:0,y:0}),{top:e.top-t.height-n.y,right:e.right-t.width+n.x,bottom:e.bottom-t.height+n.y,left:e.left-t.width-n.x}}function Zr(e){return[re,he,fe,se].some(function(t){return e[t]>=0})}function _a(e){var t=e.state,n=e.name,r=t.rects.reference,s=t.rects.popper,i=t.modifiersData.preventOverflow,o=St(t,{elementContext:"reference"}),a=St(t,{altBoundary:!0}),c=Qr(o,r),l=Qr(a,s,i),u=Zr(c),d=Zr(l);t.modifiersData[n]={referenceClippingOffsets:c,popperEscapeOffsets:l,isReferenceHidden:u,hasPopperEscaped:d},t.attributes.popper=Object.assign({},t.attributes.popper,{"data-popper-reference-hidden":u,"data-popper-escaped":d})}const $a={name:"hide",enabled:!0,phase:"main",requiresIfExists:["preventOverflow"],fn:_a};function La(e,t,n){var r=we(e),s=[se,re].indexOf(r)>=0?-1:1,i=typeof n=="function"?n(Object.assign({},t,{placement:e})):n,o=i[0],a=i[1];return o=o||0,a=(a||0)*s,[se,he].indexOf(r)>=0?{x:a,y:o}:{x:o,y:a}}function Da(e){var t=e.state,n=e.options,r=e.name,s=n.offset,i=s===void 0?[0,0]:s,o=Ws.reduce(function(u,d){return u[d]=La(d,t.rects,i),u},{}),a=o[t.placement],c=a.x,l=a.y;t.modifiersData.popperOffsets!=null&&(t.modifiersData.popperOffsets.x+=c,t.modifiersData.popperOffsets.y+=l),t.modifiersData[r]=o}const Fa={name:"offset",enabled:!0,phase:"main",requires:["popperOffsets"],fn:Da};function za(e){var t=e.state,n=e.name;t.modifiersData[n]=ei({reference:t.rects.reference,element:t.rects.popper,placement:t.placement})}const Na={name:"popperOffsets",enabled:!0,phase:"read",fn:za,data:{}};function Ba(e){return e==="x"?"y":"x"}function Va(e){var t=e.state,n=e.options,r=e.name,s=n.mainAxis,i=s===void 0?!0:s,o=n.altAxis,a=o===void 0?!1:o,c=n.boundary,l=n.rootBoundary,u=n.altBoundary,d=n.padding,f=n.tether,h=f===void 0?!0:f,m=n.tetherOffset,p=m===void 0?0:m,g=St(t,{boundary:c,rootBoundary:l,padding:d,altBoundary:u}),y=we(t.placement),w=it(t.placement),A=!w,C=ur(y),P=Ba(C),k=t.modifiersData.popperOffsets,E=t.rects.reference,R=t.rects.popper,O=typeof p=="function"?p(Object.assign({},t.rects,{placement:t.placement})):p,j=typeof O=="number"?{mainAxis:O,altAxis:O}:Object.assign({mainAxis:0,altAxis:0},O),T=t.modifiersData.offset?t.modifiersData.offset[t.placement]:null,L={x:0,y:0};if(k){if(i){var $,I=C==="y"?re:se,M=C==="y"?fe:he,_=C==="y"?"height":"width",D=k[C],F=D+g[I],V=D-g[M],N=h?-R[_]/2:0,U=w===nt?E[_]:R[_],G=w===nt?-R[_]:-E[_],ie=t.elements.arrow,q=h&&ie?cr(ie):{width:0,height:0},H=t.modifiersData["arrow#persistent"]?t.modifiersData["arrow#persistent"].padding:qs(),Q=H[I],Y=H[M],K=yt(0,E[_],q[_]),Z=A?E[_]/2-N-K-Q-j.mainAxis:U-K-Q-j.mainAxis,oe=A?-E[_]/2+N+K+Y+j.mainAxis:G+K+Y+j.mainAxis,J=t.elements.arrow&&Ft(t.elements.arrow),Pe=J?C==="y"?J.clientTop||0:J.clientLeft||0:0,ke=($=T?.[C])!=null?$:0,ct=D+Z-ke-Pe,ut=D+oe-ke,Ve=yt(h?sn(F,ct):F,D,h?Ye(V,ut):V);k[C]=Ve,L[C]=Ve-D}if(a){var He,dt=C==="x"?re:se,ft=C==="x"?fe:he,ve=k[P],Ht=P==="y"?"height":"width",$r=ve+g[dt],Lr=ve-g[ft],Sn=[re,se].indexOf(y)!==-1,Dr=(He=T?.[P])!=null?He:0,Fr=Sn?$r:ve-E[Ht]-R[Ht]-Dr+j.altAxis,zr=Sn?ve+E[Ht]+R[Ht]-Dr-j.altAxis:Lr,Nr=h&&Sn?fa(Fr,ve,zr):yt(h?Fr:$r,ve,h?zr:Lr);k[P]=Nr,L[P]=Nr-ve}t.modifiersData[r]=L}}const Ha={name:"preventOverflow",enabled:!0,phase:"main",fn:Va,requiresIfExists:["offset"]};function Ua(e){return{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}}function Ga(e){return e===ae(e)||!ue(e)?dr(e):Ua(e)}function Xa(e){var t=e.getBoundingClientRect(),n=rt(t.width)/e.offsetWidth||1,r=rt(t.height)/e.offsetHeight||1;return n!==1||r!==1}function Wa(e,t,n){n===void 0&&(n=!1);var r=ue(t),s=ue(t)&&Xa(t),i=Ne(t),o=st(e,s,n),a={scrollLeft:0,scrollTop:0},c={x:0,y:0};return(r||!r&&!n)&&((Ae(t)!=="body"||hr(i))&&(a=Ga(t)),ue(t)?(c=st(t,!0),c.x+=t.clientLeft,c.y+=t.clientTop):i&&(c.x=fr(i))),{x:o.left+a.scrollLeft-c.x,y:o.top+a.scrollTop-c.y,width:o.width,height:o.height}}function Ya(e){var t=new Map,n=new Set,r=[];e.forEach(function(i){t.set(i.name,i)});function s(i){n.add(i.name);var o=[].concat(i.requires||[],i.requiresIfExists||[]);o.forEach(function(a){if(!n.has(a)){var c=t.get(a);c&&s(c)}}),r.push(i)}return e.forEach(function(i){n.has(i.name)||s(i)}),r}function Ka(e){var t=Ya(e);return oa.reduce(function(n,r){return n.concat(t.filter(function(s){return s.phase===r}))},[])}function qa(e){var t;return function(){return t||(t=new Promise(function(n){Promise.resolve().then(function(){t=void 0,n(e())})})),t}}function Qa(e){var t=e.reduce(function(n,r){var s=n[r.name];return n[r.name]=s?Object.assign({},s,r,{options:Object.assign({},s.options,r.options),data:Object.assign({},s.data,r.data)}):r,n},{});return Object.keys(t).map(function(n){return t[n]})}var Jr={placement:"bottom",modifiers:[],strategy:"absolute"};function es(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return!t.some(function(r){return!(r&&typeof r.getBoundingClientRect=="function")})}function Za(e){e===void 0&&(e={});var t=e,n=t.defaultModifiers,r=n===void 0?[]:n,s=t.defaultOptions,i=s===void 0?Jr:s;return function(a,c,l){l===void 0&&(l=i);var u={placement:"bottom",orderedModifiers:[],options:Object.assign({},Jr,i),modifiersData:{},elements:{reference:a,popper:c},attributes:{},styles:{}},d=[],f=!1,h={state:u,setOptions:function(y){var w=typeof y=="function"?y(u.options):y;p(),u.options=Object.assign({},i,u.options,w),u.scrollParents={reference:Ke(a)?vt(a):a.contextElement?vt(a.contextElement):[],popper:vt(c)};var A=Ka(Qa([].concat(r,u.options.modifiers)));return u.orderedModifiers=A.filter(function(C){return C.enabled}),m(),h.update()},forceUpdate:function(){if(!f){var y=u.elements,w=y.reference,A=y.popper;if(es(w,A)){u.rects={reference:Wa(w,Ft(A),u.options.strategy==="fixed"),popper:cr(A)},u.reset=!1,u.placement=u.options.placement,u.orderedModifiers.forEach(function(j){return u.modifiersData[j.name]=Object.assign({},j.data)});for(var C=0;C<u.orderedModifiers.length;C++){if(u.reset===!0){u.reset=!1,C=-1;continue}var P=u.orderedModifiers[C],k=P.fn,E=P.options,R=E===void 0?{}:E,O=P.name;typeof k=="function"&&(u=k({state:u,options:R,name:O,instance:h})||u)}}}},update:qa(function(){return new Promise(function(g){h.forceUpdate(),g(u)})}),destroy:function(){p(),f=!0}};if(!es(a,c))return h;h.setOptions(l).then(function(g){!f&&l.onFirstUpdate&&l.onFirstUpdate(g)});function m(){u.orderedModifiers.forEach(function(g){var y=g.name,w=g.options,A=w===void 0?{}:w,C=g.effect;if(typeof C=="function"){var P=C({state:u,name:y,instance:h,options:A}),k=function(){};d.push(P||k)}})}function p(){d.forEach(function(g){return g()}),d=[]}return h}}var Ja=[Aa,Na,ba,ca,Fa,Ta,Ha,ga,$a],el=Za({defaultModifiers:Ja});function de(e){const{elementType:t,externalSlotProps:n,ownerState:r,skipResolvingSlotProps:s=!1,...i}=e,o=s?{}:Xo(n,r),{props:a,internalRef:c}=Yo({...i,externalSlotProps:o}),l=Pt(c,o?.ref,e.additionalProps?.ref);return Go(t,{...a,ref:l},r)}function tl(e){return parseInt(v.version,10)>=19?e?.props?.ref||null:e?.ref||null}function nl(e){return typeof e=="function"?e():e}const rl=v.forwardRef(function(t,n){const{children:r,container:s,disablePortal:i=!1}=t,[o,a]=v.useState(null),c=Pt(v.isValidElement(r)?tl(r):null,n);if($e(()=>{i||a(nl(s)||document.body)},[s,i]),$e(()=>{if(o&&!i)return Ur(n,o),()=>{Ur(n,null)}},[n,o,i]),i){if(v.isValidElement(r)){const l={ref:c};return v.cloneElement(r,l)}return r}return o&&Ns.createPortal(r,o)});function sl(e){return De("MuiPopper",e)}Fe("MuiPopper",["root"]);function il(e,t){if(t==="ltr")return e;switch(e){case"bottom-end":return"bottom-start";case"bottom-start":return"bottom-end";case"top-end":return"top-start";case"top-start":return"top-end";default:return e}}function Wn(e){return typeof e=="function"?e():e}function ol(e){return e.nodeType!==void 0}const al=e=>{const{classes:t}=e;return je({root:["root"]},sl,t)},ll={},cl=v.forwardRef(function(t,n){const{anchorEl:r,children:s,direction:i,disablePortal:o,modifiers:a,open:c,placement:l,popperOptions:u,popperRef:d,slotProps:f={},slots:h={},TransitionProps:m,ownerState:p,...g}=t,y=v.useRef(null),w=Pt(y,n),A=v.useRef(null),C=Pt(A,d),P=v.useRef(C);$e(()=>{P.current=C},[C]),v.useImperativeHandle(d,()=>A.current,[]);const k=il(l,i),[E,R]=v.useState(k),[O,j]=v.useState(Wn(r));v.useEffect(()=>{A.current&&A.current.forceUpdate()}),v.useEffect(()=>{r&&j(Wn(r))},[r]),$e(()=>{if(!O||!c)return;const M=F=>{R(F.placement)};let _=[{name:"preventOverflow",options:{altBoundary:o}},{name:"flip",options:{altBoundary:o}},{name:"onUpdate",enabled:!0,phase:"afterWrite",fn:({state:F})=>{M(F)}}];a!=null&&(_=_.concat(a)),u&&u.modifiers!=null&&(_=_.concat(u.modifiers));const D=el(O,y.current,{placement:k,...u,modifiers:_});return P.current(D),()=>{D.destroy(),P.current(null)}},[O,o,a,c,u,k]);const T={placement:E};m!==null&&(T.TransitionProps=m);const L=al(t),$=h.root??"div",I=de({elementType:$,externalSlotProps:f.root,externalForwardedProps:g,additionalProps:{role:"tooltip",ref:w},ownerState:t,className:L.root});return x.jsx($,{...I,children:typeof s=="function"?s(T):s})}),ul=v.forwardRef(function(t,n){const{anchorEl:r,children:s,container:i,direction:o="ltr",disablePortal:a=!1,keepMounted:c=!1,modifiers:l,open:u,placement:d="bottom",popperOptions:f=ll,popperRef:h,style:m,transition:p=!1,slotProps:g={},slots:y={},...w}=t,[A,C]=v.useState(!0),P=()=>{C(!1)},k=()=>{C(!0)};if(!c&&!u&&(!p||A))return null;let E;if(i)E=i;else if(r){const j=Wn(r);E=j&&ol(j)?Un(j).body:Un(null).body}const R=!u&&c&&(!p||A)?"none":void 0,O=p?{in:u,onEnter:P,onExited:k}:void 0;return x.jsx(rl,{disablePortal:a,container:E,children:x.jsx(cl,{anchorEl:r,direction:o,disablePortal:a,modifiers:l,ref:n,open:p?!A:u,placement:d,popperOptions:f,popperRef:h,slotProps:g,slots:y,...w,style:{position:"fixed",top:0,left:0,display:R,...m},TransitionProps:O,children:s})})}),dl=W(ul,{name:"MuiPopper",slot:"Root"})({}),fl=v.forwardRef(function(t,n){const r=or(),s=io({props:t,name:"MuiPopper"}),{anchorEl:i,component:o,components:a,componentsProps:c,container:l,disablePortal:u,keepMounted:d,modifiers:f,open:h,placement:m,popperOptions:p,popperRef:g,transition:y,slots:w,slotProps:A,...C}=s,P=w?.root??a?.Root,k={anchorEl:i,container:l,disablePortal:u,keepMounted:d,modifiers:f,open:h,placement:m,popperOptions:p,popperRef:g,transition:y,...C};return x.jsx(dl,{as:o,direction:r?"rtl":"ltr",slots:{root:P},slotProps:A??c,...k,ref:n})});function ti(e){const{children:t,defer:n=!1,fallback:r=null}=e,[s,i]=v.useState(!1);return $e(()=>{n||i(!0)},[n]),v.useEffect(()=>{n&&i(!0)},[n]),s?t:r}function hl(e,t){return t<e?-1:t>e?1:t>=e?0:NaN}function pl(e){return e}function ml(){var e=pl,t=hl,n=null,r=Ue(0),s=Ue(jn),i=Ue(0);function o(a){var c,l=(a=Co(a)).length,u,d,f=0,h=new Array(l),m=new Array(l),p=+r.apply(this,arguments),g=Math.min(jn,Math.max(-jn,s.apply(this,arguments)-p)),y,w=Math.min(Math.abs(g)/l,i.apply(this,arguments)),A=w*(g<0?-1:1),C;for(c=0;c<l;++c)(C=m[h[c]=c]=+e(a[c],c,a))>0&&(f+=C);for(t!=null?h.sort(function(P,k){return t(m[P],m[k])}):n!=null&&h.sort(function(P,k){return n(a[P],a[k])}),c=0,d=f?(g-l*A)/f:0;c<l;++c,p=y)u=h[c],C=m[u],y=p+(C>0?C*d:0)+A,m[u]={data:a[u],index:c,value:C,startAngle:p,endAngle:y,padAngle:w};return m}return o.value=function(a){return arguments.length?(e=typeof a=="function"?a:Ue(+a),o):e},o.sortValues=function(a){return arguments.length?(t=a,n=null,o):t},o.sort=function(a){return arguments.length?(n=a,t=null,o):n},o.startAngle=function(a){return arguments.length?(r=typeof a=="function"?a:Ue(+a),o):r},o.endAngle=function(a){return arguments.length?(s=typeof a=="function"?a:Ue(+a),o):s},o.padAngle=function(a){return arguments.length?(i=typeof a=="function"?a:Ue(+a),o):i},o}function gl(e,t){if((c=e.length)>0)for(var n,r=0,s,i,o,a,c,l=e[t[0]].length;r<l;++r)for(o=a=0,n=0;n<c;++n)(i=(s=e[t[n]][r])[1]-s[0])>0?(s[0]=o,s[1]=o+=i):i<0?(s[1]=a,s[0]=a+=i):(s[0]=0,s[1]=i)}function ni(e){var t=e.map(xl);return hn(e).sort(function(n,r){return t[n]-t[r]})}function xl(e){for(var t=-1,n=0,r=e.length,s,i=-1/0;++t<r;)(s=+e[t][1])>i&&(i=s,n=t);return n}function ri(e){var t=e.map(si);return hn(e).sort(function(n,r){return t[n]-t[r]})}function si(e){for(var t=0,n=-1,r=e.length,s;++n<r;)(s=+e[n][1])&&(t+=s);return t}function yl(e){return ri(e).reverse()}function vl(e){var t=e.length,n,r,s=e.map(si),i=ni(e),o=0,a=0,c=[],l=[];for(n=0;n<t;++n)r=i[n],o<a?(o+=s[r],c.push(r)):(a+=s[r],l.push(r));return l.reverse().concat(c)}function bl(e){return hn(e).reverse()}function wl({filter:e,setFilter:t,closeModal:n}){const{handleSubmit:r,control:s,trigger:i}=uo({defaultValues:{...e}}),o=a=>{t(a),n()};return x.jsxs("form",{onSubmit:r(o),children:[x.jsx(In,{name:"fromDate",control:s,rules:{pattern:{value:Br,message:"Date must be im format yyyy-mm-dd"}},render:({field:a,fieldState:c})=>x.jsx(Vr,{...a,label:"From Date",value:new Date(a.value),onChange:l=>{i("fromDate"),a.onChange(l?Le(l,"yyyy-MM-dd"):void 0)},error:c.error?.message,popoverProps:{withinPortal:!0}})}),x.jsx(In,{name:"toDate",control:s,rules:{pattern:{value:Br,message:"Date must be im format yyyy-mm-dd"}},render:({field:a,fieldState:c})=>x.jsx(Vr,{...a,label:"To Date",value:new Date(a.value),onChange:l=>{i("toDate"),a.onChange(l?Le(l,"yyyy-MM-dd"):void 0)},error:c.error?.message,popoverProps:{withinPortal:!0}})}),x.jsx(In,{name:"currency",control:s,render:({field:a,fieldState:c})=>x.jsx(fo,{...a,label:"Currency",defaultValue:En.Usd,error:c.error?.message,data:Object.keys(En).map(l=>En[l])})}),x.jsxs("div",{className:"flex justify-center mt-5 gap-3",children:[x.jsx("button",{type:"submit",className:"text-white bg-indigo-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-indigo-600 rounded-sm text-lg",children:"Filter"}),x.jsx("button",{type:"button",className:"text-white bg-rose-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-rose-600 rounded-sm text-lg",onClick:n,children:"Cancel"})]})]})}function Al({filter:e,setFilter:t}){const[n,r]=v.useState(!1),{get:s,set:i}=Bs();function o(a){a||={fromDate:Le(new Date,"yyyy-MM-DD"),toDate:Le(new Date,"yyyy-MM-DD")},ho(a,e)||t(a)}return v.useEffect(()=>{const a=oo(e??{})?null:encodeURIComponent(JSON.stringify(e)),c=s("MonthlyIncomeExpenseChartFilters");a!==c&&i("MonthlyIncomeExpenseChartFilters",a)},[e,s,i]),x.jsxs(x.Fragment,{children:[x.jsx(ao,{opened:n,onClose:()=>r(!1),content:x.jsx(wl,{filter:e,setFilter:o,closeModal:()=>r(!1)})}),x.jsx(lo,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>r(!0),children:x.jsx(co,{className:"size-5"})})]})}const pr="DEFAULT_X_AXIS_KEY",mr="DEFAULT_Y_AXIS_KEY",Cl={top:50,bottom:50,left:50,right:50},ii=v.createContext({isInitialized:!1,data:{highlightedItem:null,setHighlighted:()=>{},clearHighlighted:()=>{},isHighlighted:()=>!1,isFaded:()=>!1}}),Pl=(e,t)=>n=>e?e.fade==="series"?n.seriesId===t?.seriesId&&n.dataIndex!==t?.dataIndex:e.fade==="global"?n.seriesId!==t?.seriesId||n.dataIndex!==t?.dataIndex:!1:!1,kl=(e,t)=>n=>e?e.highlight==="series"?n.seriesId===t?.seriesId:e.highlight==="item"?n.dataIndex===t?.dataIndex&&n.seriesId===t?.seriesId:!1:!1,Sl=["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"];function Il(e,t,n=Sl){return e.type==="pie"?b({},e,{data:e.data.map((r,s)=>b({color:n[s%n.length]},r))}):b({color:n[t%n.length]},e)}const El=({series:e,colors:t,seriesFormatters:n,dataset:r})=>{const s={};e.forEach((o,a)=>{const{id:c=`auto-generated-id-${a}`,type:l}=o;if(s[l]===void 0&&(s[l]={series:{},seriesOrder:[]}),s[l]?.series[c]!==void 0)throw new Error(`MUI X: series' id "${c}" is not unique.`);s[l].series[c]=b({id:c},Il(o,a,t)),s[l].seriesOrder.push(c)});const i={};return Object.keys(n).forEach(o=>{const a=s[o];a!==void 0&&(i[o]=n[o]?.(a,r)??s[o])}),i},Ml=["#02B2AF","#2E96FF","#B800D8","#60009B","#2731C8","#03008D"],jl=["#02B2AF","#72CCFF","#DA00FF","#9001CB","#2E96FF","#3B48E0"],Ol=e=>e==="dark"?jl:Ml,oi=v.createContext({isInitialized:!1,data:{}}),zt=v.createContext({isInitialized:!1,data:{colorProcessors:{},seriesFormatters:{},xExtremumGetters:{},yExtremumGetters:{},rotationExtremumGetters:{},radiusExtremumGetters:{}}}),ts=(e,t)=>t==="x"?{x:e,y:null}:{x:null,y:e},ai=e=>{const{axis:t,getFilters:n,isDefaultAxis:r}=e,s=n?.({currentAxisId:t.id,isDefaultAxis:r}),i=s?t.data?.filter((c,l)=>s({x:null,y:null},l)):t.data,o=Math.min(...i??[]),a=Math.max(...i??[]);return[o,a]},li=e=>t=>{const{series:n,axis:r,getFilters:s,isDefaultAxis:i}=t;return Object.keys(n).filter(o=>{const a=n[o].yAxisId??n[o].yAxisKey;return a===r.id||i&&a===void 0}).reduce((o,a)=>{const{stackedData:c}=n[a],l=s?.({currentAxisId:r.id,isDefaultAxis:i,seriesXAxisId:n[a].xAxisId??n[a].xAxisKey,seriesYAxisId:n[a].yAxisId??n[a].yAxisKey}),[u,d]=c?.reduce((f,h,m)=>l&&(!l(ts(h[0],e),m)||!l(ts(h[1],e),m))?f:[Math.min(...h,f[0]),Math.max(...h,f[1])],[1/0,-1/0])??[1/0,-1/0];return[Math.min(u,o[0]),Math.max(d,o[1])]},[1/0,-1/0])},Rl=e=>Object.keys(e.series).some(n=>e.series[n].layout==="horizontal")?li("x")(e):ai(e),Tl=e=>Object.keys(e.series).some(n=>e.series[n].layout==="horizontal")?ai(e):li("y")(e),On={appearance:ni,ascending:ri,descending:yl,insideOut:vl,none:hn,reverse:bl},Rn={expand:Io,diverging:gl,none:Po,silhouette:So,wiggle:ko},ci=e=>{const{series:t,seriesOrder:n,defaultStrategy:r}=e,s=[],i={};return n.forEach(o=>{const{stack:a,stackOrder:c,stackOffset:l}=t[o];a===void 0?s.push({ids:[o],stackingOrder:On.none,stackingOffset:Rn.none}):i[a]===void 0?(i[a]=s.length,s.push({ids:[o],stackingOrder:On[c??r?.stackOrder??"none"],stackingOffset:Rn[l??r?.stackOffset??"diverging"]})):(s[i[a]].ids.push(o),c!==void 0&&(s[i[a]].stackingOrder=On[c]),l!==void 0&&(s[i[a]].stackingOffset=Rn[l]))}),s};function ui(e,t){const n={};return Object.keys(e).forEach(r=>{n[r]=b({},e[r],{valueFormatter:e[r].valueFormatter??t})}),n}const _l=(e,t)=>{const{seriesOrder:n,series:r}=e,s=ci(e),i=t??[];n.forEach(a=>{const c=r[a].data;if(c!==void 0)c.forEach((l,u)=>{i.length<=u?i.push({[a]:l}):i[u][a]=l});else if(t===void 0)throw new Error([`MUI X: bar series with id='${a}' has no data.`,"Either provide a data property to the series or use the dataset prop."].join(`
1
+ import{d3 as so,d4 as Ds,d5 as Fs,d6 as zs,r as v,ai as Ie,d7 as $e,d8 as Ns,j as x,d9 as or,da as io,u as Bs,cZ as oo,c_ as ao,B as lo,c$ as co,V as uo,bO as In,bT as Br,db as Vr,H as Le,bP as fo,b1 as En,d0 as ho,dc as b,dd as Vs,X as po,de as mo,F as go,a as xo,df as yo,c as vo,L as bo,dg as wo}from"./index-B9S5s-Ek.js";import{u as Pt,g as De,a as Fe,c as je,s as W,_ as X,b as Ao,T as Mn}from"./Typography-nwkjB2uH.js";import{c as Ue,t as jn,a as Co,d as hn,b as Po,e as ko,f as So,g as Io,h as Hs,o as Hr,i as Eo,s as Mo,l as jo,u as Oo,j as Us,k as Ro,p as To,m as _o,n as $o,q as Lo,r as Do,v as Fo,w as zo}from"./sequential-CAnleQny.js";import{s as Gs}from"./sub-DWCpbavW.js";import"./subMonths-DpFGzG8Q.js";function No(e){const{theme:t,name:n,props:r}=e;return!t||!t.components||!t.components[n]||!t.components[n].defaultProps?r:so(t.components[n].defaultProps,r)}function Bo({props:e,name:t,defaultTheme:n,themeId:r}){let s=Ds(n);return s=s[r]||s,No({theme:s,name:t,props:e})}function Lt(){const e=Ds(Fs);return e[zs]||e}function ze({props:e,name:t}){return Bo({props:e,name:t,defaultTheme:Fs,themeId:zs})}function Un(e){return e&&e.ownerDocument||document}function Vo(e){return Un(e).defaultView||window}function Ur(e,t){typeof e=="function"?e(t):e&&(e.current=t)}function Ho(e){const{controlled:t,default:n}=e,{current:r}=v.useRef(t!==void 0),[s,i]=v.useState(n),o=r?t:s,a=v.useCallback(c=>{r||i(c)},[]);return[o,a]}function Uo(e){return typeof e=="string"}function Go(e,t,n){return e===void 0||Uo(e)?t:{...t,ownerState:{...t.ownerState,...n}}}function Xo(e,t,n){return typeof e=="function"?e(t,n):e}function Wo(e,t=[]){if(e===void 0)return{};const n={};return Object.keys(e).filter(r=>r.match(/^on[A-Z]/)&&typeof e[r]=="function"&&!t.includes(r)).forEach(r=>{n[r]=e[r]}),n}function Gr(e){if(e===void 0)return{};const t={};return Object.keys(e).filter(n=>!(n.match(/^on[A-Z]/)&&typeof e[n]=="function")).forEach(n=>{t[n]=e[n]}),t}function Yo(e){const{getSlotProps:t,additionalProps:n,externalSlotProps:r,externalForwardedProps:s,className:i}=e;if(!t){const h=Ie(n?.className,i,s?.className,r?.className),m={...n?.style,...s?.style,...r?.style},p={...n,...s,...r};return h.length>0&&(p.className=h),Object.keys(m).length>0&&(p.style=m),{props:p,internalRef:void 0}}const o=Wo({...s,...r}),a=Gr(r),c=Gr(s),l=t(o),u=Ie(l?.className,n?.className,i,s?.className,r?.className),d={...l?.style,...n?.style,...s?.style,...r?.style},f={...l,...n,...c,...a};return u.length>0&&(f.className=u),Object.keys(d).length>0&&(f.style=d),{props:f,internalRef:l.ref}}var re="top",fe="bottom",he="right",se="left",ar="auto",Dt=[re,fe,he,se],nt="start",kt="end",Ko="clippingParents",Xs="viewport",ht="popper",qo="reference",Xr=Dt.reduce(function(e,t){return e.concat([t+"-"+nt,t+"-"+kt])},[]),Ws=[].concat(Dt,[ar]).reduce(function(e,t){return e.concat([t,t+"-"+nt,t+"-"+kt])},[]),Qo="beforeRead",Zo="read",Jo="afterRead",ea="beforeMain",ta="main",na="afterMain",ra="beforeWrite",sa="write",ia="afterWrite",oa=[Qo,Zo,Jo,ea,ta,na,ra,sa,ia];function Ae(e){return e?(e.nodeName||"").toLowerCase():null}function ae(e){if(e==null)return window;if(e.toString()!=="[object Window]"){var t=e.ownerDocument;return t&&t.defaultView||window}return e}function Ke(e){var t=ae(e).Element;return e instanceof t||e instanceof Element}function ue(e){var t=ae(e).HTMLElement;return e instanceof t||e instanceof HTMLElement}function lr(e){if(typeof ShadowRoot>"u")return!1;var t=ae(e).ShadowRoot;return e instanceof t||e instanceof ShadowRoot}function aa(e){var t=e.state;Object.keys(t.elements).forEach(function(n){var r=t.styles[n]||{},s=t.attributes[n]||{},i=t.elements[n];!ue(i)||!Ae(i)||(Object.assign(i.style,r),Object.keys(s).forEach(function(o){var a=s[o];a===!1?i.removeAttribute(o):i.setAttribute(o,a===!0?"":a)}))})}function la(e){var t=e.state,n={popper:{position:t.options.strategy,left:"0",top:"0",margin:"0"},arrow:{position:"absolute"},reference:{}};return Object.assign(t.elements.popper.style,n.popper),t.styles=n,t.elements.arrow&&Object.assign(t.elements.arrow.style,n.arrow),function(){Object.keys(t.elements).forEach(function(r){var s=t.elements[r],i=t.attributes[r]||{},o=Object.keys(t.styles.hasOwnProperty(r)?t.styles[r]:n[r]),a=o.reduce(function(c,l){return c[l]="",c},{});!ue(s)||!Ae(s)||(Object.assign(s.style,a),Object.keys(i).forEach(function(c){s.removeAttribute(c)}))})}}const ca={name:"applyStyles",enabled:!0,phase:"write",fn:aa,effect:la,requires:["computeStyles"]};function we(e){return e.split("-")[0]}var Ye=Math.max,sn=Math.min,rt=Math.round;function Gn(){var e=navigator.userAgentData;return e!=null&&e.brands&&Array.isArray(e.brands)?e.brands.map(function(t){return t.brand+"/"+t.version}).join(" "):navigator.userAgent}function Ys(){return!/^((?!chrome|android).)*safari/i.test(Gn())}function st(e,t,n){t===void 0&&(t=!1),n===void 0&&(n=!1);var r=e.getBoundingClientRect(),s=1,i=1;t&&ue(e)&&(s=e.offsetWidth>0&&rt(r.width)/e.offsetWidth||1,i=e.offsetHeight>0&&rt(r.height)/e.offsetHeight||1);var o=Ke(e)?ae(e):window,a=o.visualViewport,c=!Ys()&&n,l=(r.left+(c&&a?a.offsetLeft:0))/s,u=(r.top+(c&&a?a.offsetTop:0))/i,d=r.width/s,f=r.height/i;return{width:d,height:f,top:u,right:l+d,bottom:u+f,left:l,x:l,y:u}}function cr(e){var t=st(e),n=e.offsetWidth,r=e.offsetHeight;return Math.abs(t.width-n)<=1&&(n=t.width),Math.abs(t.height-r)<=1&&(r=t.height),{x:e.offsetLeft,y:e.offsetTop,width:n,height:r}}function Ks(e,t){var n=t.getRootNode&&t.getRootNode();if(e.contains(t))return!0;if(n&&lr(n)){var r=t;do{if(r&&e.isSameNode(r))return!0;r=r.parentNode||r.host}while(r)}return!1}function Me(e){return ae(e).getComputedStyle(e)}function ua(e){return["table","td","th"].indexOf(Ae(e))>=0}function Ne(e){return((Ke(e)?e.ownerDocument:e.document)||window.document).documentElement}function pn(e){return Ae(e)==="html"?e:e.assignedSlot||e.parentNode||(lr(e)?e.host:null)||Ne(e)}function Wr(e){return!ue(e)||Me(e).position==="fixed"?null:e.offsetParent}function da(e){var t=/firefox/i.test(Gn()),n=/Trident/i.test(Gn());if(n&&ue(e)){var r=Me(e);if(r.position==="fixed")return null}var s=pn(e);for(lr(s)&&(s=s.host);ue(s)&&["html","body"].indexOf(Ae(s))<0;){var i=Me(s);if(i.transform!=="none"||i.perspective!=="none"||i.contain==="paint"||["transform","perspective"].indexOf(i.willChange)!==-1||t&&i.willChange==="filter"||t&&i.filter&&i.filter!=="none")return s;s=s.parentNode}return null}function Ft(e){for(var t=ae(e),n=Wr(e);n&&ua(n)&&Me(n).position==="static";)n=Wr(n);return n&&(Ae(n)==="html"||Ae(n)==="body"&&Me(n).position==="static")?t:n||da(e)||t}function ur(e){return["top","bottom"].indexOf(e)>=0?"x":"y"}function yt(e,t,n){return Ye(e,sn(t,n))}function fa(e,t,n){var r=yt(e,t,n);return r>n?n:r}function qs(){return{top:0,right:0,bottom:0,left:0}}function Qs(e){return Object.assign({},qs(),e)}function Zs(e,t){return t.reduce(function(n,r){return n[r]=e,n},{})}var ha=function(t,n){return t=typeof t=="function"?t(Object.assign({},n.rects,{placement:n.placement})):t,Qs(typeof t!="number"?t:Zs(t,Dt))};function pa(e){var t,n=e.state,r=e.name,s=e.options,i=n.elements.arrow,o=n.modifiersData.popperOffsets,a=we(n.placement),c=ur(a),l=[se,he].indexOf(a)>=0,u=l?"height":"width";if(!(!i||!o)){var d=ha(s.padding,n),f=cr(i),h=c==="y"?re:se,m=c==="y"?fe:he,p=n.rects.reference[u]+n.rects.reference[c]-o[c]-n.rects.popper[u],g=o[c]-n.rects.reference[c],y=Ft(i),w=y?c==="y"?y.clientHeight||0:y.clientWidth||0:0,A=p/2-g/2,C=d[h],P=w-f[u]-d[m],k=w/2-f[u]/2+A,E=yt(C,k,P),R=c;n.modifiersData[r]=(t={},t[R]=E,t.centerOffset=E-k,t)}}function ma(e){var t=e.state,n=e.options,r=n.element,s=r===void 0?"[data-popper-arrow]":r;s!=null&&(typeof s=="string"&&(s=t.elements.popper.querySelector(s),!s)||Ks(t.elements.popper,s)&&(t.elements.arrow=s))}const ga={name:"arrow",enabled:!0,phase:"main",fn:pa,effect:ma,requires:["popperOffsets"],requiresIfExists:["preventOverflow"]};function it(e){return e.split("-")[1]}var xa={top:"auto",right:"auto",bottom:"auto",left:"auto"};function ya(e,t){var n=e.x,r=e.y,s=t.devicePixelRatio||1;return{x:rt(n*s)/s||0,y:rt(r*s)/s||0}}function Yr(e){var t,n=e.popper,r=e.popperRect,s=e.placement,i=e.variation,o=e.offsets,a=e.position,c=e.gpuAcceleration,l=e.adaptive,u=e.roundOffsets,d=e.isFixed,f=o.x,h=f===void 0?0:f,m=o.y,p=m===void 0?0:m,g=typeof u=="function"?u({x:h,y:p}):{x:h,y:p};h=g.x,p=g.y;var y=o.hasOwnProperty("x"),w=o.hasOwnProperty("y"),A=se,C=re,P=window;if(l){var k=Ft(n),E="clientHeight",R="clientWidth";if(k===ae(n)&&(k=Ne(n),Me(k).position!=="static"&&a==="absolute"&&(E="scrollHeight",R="scrollWidth")),k=k,s===re||(s===se||s===he)&&i===kt){C=fe;var O=d&&k===P&&P.visualViewport?P.visualViewport.height:k[E];p-=O-r.height,p*=c?1:-1}if(s===se||(s===re||s===fe)&&i===kt){A=he;var j=d&&k===P&&P.visualViewport?P.visualViewport.width:k[R];h-=j-r.width,h*=c?1:-1}}var T=Object.assign({position:a},l&&xa),L=u===!0?ya({x:h,y:p},ae(n)):{x:h,y:p};if(h=L.x,p=L.y,c){var $;return Object.assign({},T,($={},$[C]=w?"0":"",$[A]=y?"0":"",$.transform=(P.devicePixelRatio||1)<=1?"translate("+h+"px, "+p+"px)":"translate3d("+h+"px, "+p+"px, 0)",$))}return Object.assign({},T,(t={},t[C]=w?p+"px":"",t[A]=y?h+"px":"",t.transform="",t))}function va(e){var t=e.state,n=e.options,r=n.gpuAcceleration,s=r===void 0?!0:r,i=n.adaptive,o=i===void 0?!0:i,a=n.roundOffsets,c=a===void 0?!0:a,l={placement:we(t.placement),variation:it(t.placement),popper:t.elements.popper,popperRect:t.rects.popper,gpuAcceleration:s,isFixed:t.options.strategy==="fixed"};t.modifiersData.popperOffsets!=null&&(t.styles.popper=Object.assign({},t.styles.popper,Yr(Object.assign({},l,{offsets:t.modifiersData.popperOffsets,position:t.options.strategy,adaptive:o,roundOffsets:c})))),t.modifiersData.arrow!=null&&(t.styles.arrow=Object.assign({},t.styles.arrow,Yr(Object.assign({},l,{offsets:t.modifiersData.arrow,position:"absolute",adaptive:!1,roundOffsets:c})))),t.attributes.popper=Object.assign({},t.attributes.popper,{"data-popper-placement":t.placement})}const ba={name:"computeStyles",enabled:!0,phase:"beforeWrite",fn:va,data:{}};var Ut={passive:!0};function wa(e){var t=e.state,n=e.instance,r=e.options,s=r.scroll,i=s===void 0?!0:s,o=r.resize,a=o===void 0?!0:o,c=ae(t.elements.popper),l=[].concat(t.scrollParents.reference,t.scrollParents.popper);return i&&l.forEach(function(u){u.addEventListener("scroll",n.update,Ut)}),a&&c.addEventListener("resize",n.update,Ut),function(){i&&l.forEach(function(u){u.removeEventListener("scroll",n.update,Ut)}),a&&c.removeEventListener("resize",n.update,Ut)}}const Aa={name:"eventListeners",enabled:!0,phase:"write",fn:function(){},effect:wa,data:{}};var Ca={left:"right",right:"left",bottom:"top",top:"bottom"};function en(e){return e.replace(/left|right|bottom|top/g,function(t){return Ca[t]})}var Pa={start:"end",end:"start"};function Kr(e){return e.replace(/start|end/g,function(t){return Pa[t]})}function dr(e){var t=ae(e),n=t.pageXOffset,r=t.pageYOffset;return{scrollLeft:n,scrollTop:r}}function fr(e){return st(Ne(e)).left+dr(e).scrollLeft}function ka(e,t){var n=ae(e),r=Ne(e),s=n.visualViewport,i=r.clientWidth,o=r.clientHeight,a=0,c=0;if(s){i=s.width,o=s.height;var l=Ys();(l||!l&&t==="fixed")&&(a=s.offsetLeft,c=s.offsetTop)}return{width:i,height:o,x:a+fr(e),y:c}}function Sa(e){var t,n=Ne(e),r=dr(e),s=(t=e.ownerDocument)==null?void 0:t.body,i=Ye(n.scrollWidth,n.clientWidth,s?s.scrollWidth:0,s?s.clientWidth:0),o=Ye(n.scrollHeight,n.clientHeight,s?s.scrollHeight:0,s?s.clientHeight:0),a=-r.scrollLeft+fr(e),c=-r.scrollTop;return Me(s||n).direction==="rtl"&&(a+=Ye(n.clientWidth,s?s.clientWidth:0)-i),{width:i,height:o,x:a,y:c}}function hr(e){var t=Me(e),n=t.overflow,r=t.overflowX,s=t.overflowY;return/auto|scroll|overlay|hidden/.test(n+s+r)}function Js(e){return["html","body","#document"].indexOf(Ae(e))>=0?e.ownerDocument.body:ue(e)&&hr(e)?e:Js(pn(e))}function vt(e,t){var n;t===void 0&&(t=[]);var r=Js(e),s=r===((n=e.ownerDocument)==null?void 0:n.body),i=ae(r),o=s?[i].concat(i.visualViewport||[],hr(r)?r:[]):r,a=t.concat(o);return s?a:a.concat(vt(pn(o)))}function Xn(e){return Object.assign({},e,{left:e.x,top:e.y,right:e.x+e.width,bottom:e.y+e.height})}function Ia(e,t){var n=st(e,!1,t==="fixed");return n.top=n.top+e.clientTop,n.left=n.left+e.clientLeft,n.bottom=n.top+e.clientHeight,n.right=n.left+e.clientWidth,n.width=e.clientWidth,n.height=e.clientHeight,n.x=n.left,n.y=n.top,n}function qr(e,t,n){return t===Xs?Xn(ka(e,n)):Ke(t)?Ia(t,n):Xn(Sa(Ne(e)))}function Ea(e){var t=vt(pn(e)),n=["absolute","fixed"].indexOf(Me(e).position)>=0,r=n&&ue(e)?Ft(e):e;return Ke(r)?t.filter(function(s){return Ke(s)&&Ks(s,r)&&Ae(s)!=="body"}):[]}function Ma(e,t,n,r){var s=t==="clippingParents"?Ea(e):[].concat(t),i=[].concat(s,[n]),o=i[0],a=i.reduce(function(c,l){var u=qr(e,l,r);return c.top=Ye(u.top,c.top),c.right=sn(u.right,c.right),c.bottom=sn(u.bottom,c.bottom),c.left=Ye(u.left,c.left),c},qr(e,o,r));return a.width=a.right-a.left,a.height=a.bottom-a.top,a.x=a.left,a.y=a.top,a}function ei(e){var t=e.reference,n=e.element,r=e.placement,s=r?we(r):null,i=r?it(r):null,o=t.x+t.width/2-n.width/2,a=t.y+t.height/2-n.height/2,c;switch(s){case re:c={x:o,y:t.y-n.height};break;case fe:c={x:o,y:t.y+t.height};break;case he:c={x:t.x+t.width,y:a};break;case se:c={x:t.x-n.width,y:a};break;default:c={x:t.x,y:t.y}}var l=s?ur(s):null;if(l!=null){var u=l==="y"?"height":"width";switch(i){case nt:c[l]=c[l]-(t[u]/2-n[u]/2);break;case kt:c[l]=c[l]+(t[u]/2-n[u]/2);break}}return c}function St(e,t){t===void 0&&(t={});var n=t,r=n.placement,s=r===void 0?e.placement:r,i=n.strategy,o=i===void 0?e.strategy:i,a=n.boundary,c=a===void 0?Ko:a,l=n.rootBoundary,u=l===void 0?Xs:l,d=n.elementContext,f=d===void 0?ht:d,h=n.altBoundary,m=h===void 0?!1:h,p=n.padding,g=p===void 0?0:p,y=Qs(typeof g!="number"?g:Zs(g,Dt)),w=f===ht?qo:ht,A=e.rects.popper,C=e.elements[m?w:f],P=Ma(Ke(C)?C:C.contextElement||Ne(e.elements.popper),c,u,o),k=st(e.elements.reference),E=ei({reference:k,element:A,placement:s}),R=Xn(Object.assign({},A,E)),O=f===ht?R:k,j={top:P.top-O.top+y.top,bottom:O.bottom-P.bottom+y.bottom,left:P.left-O.left+y.left,right:O.right-P.right+y.right},T=e.modifiersData.offset;if(f===ht&&T){var L=T[s];Object.keys(j).forEach(function($){var I=[he,fe].indexOf($)>=0?1:-1,M=[re,fe].indexOf($)>=0?"y":"x";j[$]+=L[M]*I})}return j}function ja(e,t){t===void 0&&(t={});var n=t,r=n.placement,s=n.boundary,i=n.rootBoundary,o=n.padding,a=n.flipVariations,c=n.allowedAutoPlacements,l=c===void 0?Ws:c,u=it(r),d=u?a?Xr:Xr.filter(function(m){return it(m)===u}):Dt,f=d.filter(function(m){return l.indexOf(m)>=0});f.length===0&&(f=d);var h=f.reduce(function(m,p){return m[p]=St(e,{placement:p,boundary:s,rootBoundary:i,padding:o})[we(p)],m},{});return Object.keys(h).sort(function(m,p){return h[m]-h[p]})}function Oa(e){if(we(e)===ar)return[];var t=en(e);return[Kr(e),t,Kr(t)]}function Ra(e){var t=e.state,n=e.options,r=e.name;if(!t.modifiersData[r]._skip){for(var s=n.mainAxis,i=s===void 0?!0:s,o=n.altAxis,a=o===void 0?!0:o,c=n.fallbackPlacements,l=n.padding,u=n.boundary,d=n.rootBoundary,f=n.altBoundary,h=n.flipVariations,m=h===void 0?!0:h,p=n.allowedAutoPlacements,g=t.options.placement,y=we(g),w=y===g,A=c||(w||!m?[en(g)]:Oa(g)),C=[g].concat(A).reduce(function(q,H){return q.concat(we(H)===ar?ja(t,{placement:H,boundary:u,rootBoundary:d,padding:l,flipVariations:m,allowedAutoPlacements:p}):H)},[]),P=t.rects.reference,k=t.rects.popper,E=new Map,R=!0,O=C[0],j=0;j<C.length;j++){var T=C[j],L=we(T),$=it(T)===nt,I=[re,fe].indexOf(L)>=0,M=I?"width":"height",_=St(t,{placement:T,boundary:u,rootBoundary:d,altBoundary:f,padding:l}),D=I?$?he:se:$?fe:re;P[M]>k[M]&&(D=en(D));var F=en(D),V=[];if(i&&V.push(_[L]<=0),a&&V.push(_[D]<=0,_[F]<=0),V.every(function(q){return q})){O=T,R=!1;break}E.set(T,V)}if(R)for(var N=m?3:1,U=function(H){var Q=C.find(function(Y){var K=E.get(Y);if(K)return K.slice(0,H).every(function(Z){return Z})});if(Q)return O=Q,"break"},G=N;G>0;G--){var ie=U(G);if(ie==="break")break}t.placement!==O&&(t.modifiersData[r]._skip=!0,t.placement=O,t.reset=!0)}}const Ta={name:"flip",enabled:!0,phase:"main",fn:Ra,requiresIfExists:["offset"],data:{_skip:!1}};function Qr(e,t,n){return n===void 0&&(n={x:0,y:0}),{top:e.top-t.height-n.y,right:e.right-t.width+n.x,bottom:e.bottom-t.height+n.y,left:e.left-t.width-n.x}}function Zr(e){return[re,he,fe,se].some(function(t){return e[t]>=0})}function _a(e){var t=e.state,n=e.name,r=t.rects.reference,s=t.rects.popper,i=t.modifiersData.preventOverflow,o=St(t,{elementContext:"reference"}),a=St(t,{altBoundary:!0}),c=Qr(o,r),l=Qr(a,s,i),u=Zr(c),d=Zr(l);t.modifiersData[n]={referenceClippingOffsets:c,popperEscapeOffsets:l,isReferenceHidden:u,hasPopperEscaped:d},t.attributes.popper=Object.assign({},t.attributes.popper,{"data-popper-reference-hidden":u,"data-popper-escaped":d})}const $a={name:"hide",enabled:!0,phase:"main",requiresIfExists:["preventOverflow"],fn:_a};function La(e,t,n){var r=we(e),s=[se,re].indexOf(r)>=0?-1:1,i=typeof n=="function"?n(Object.assign({},t,{placement:e})):n,o=i[0],a=i[1];return o=o||0,a=(a||0)*s,[se,he].indexOf(r)>=0?{x:a,y:o}:{x:o,y:a}}function Da(e){var t=e.state,n=e.options,r=e.name,s=n.offset,i=s===void 0?[0,0]:s,o=Ws.reduce(function(u,d){return u[d]=La(d,t.rects,i),u},{}),a=o[t.placement],c=a.x,l=a.y;t.modifiersData.popperOffsets!=null&&(t.modifiersData.popperOffsets.x+=c,t.modifiersData.popperOffsets.y+=l),t.modifiersData[r]=o}const Fa={name:"offset",enabled:!0,phase:"main",requires:["popperOffsets"],fn:Da};function za(e){var t=e.state,n=e.name;t.modifiersData[n]=ei({reference:t.rects.reference,element:t.rects.popper,placement:t.placement})}const Na={name:"popperOffsets",enabled:!0,phase:"read",fn:za,data:{}};function Ba(e){return e==="x"?"y":"x"}function Va(e){var t=e.state,n=e.options,r=e.name,s=n.mainAxis,i=s===void 0?!0:s,o=n.altAxis,a=o===void 0?!1:o,c=n.boundary,l=n.rootBoundary,u=n.altBoundary,d=n.padding,f=n.tether,h=f===void 0?!0:f,m=n.tetherOffset,p=m===void 0?0:m,g=St(t,{boundary:c,rootBoundary:l,padding:d,altBoundary:u}),y=we(t.placement),w=it(t.placement),A=!w,C=ur(y),P=Ba(C),k=t.modifiersData.popperOffsets,E=t.rects.reference,R=t.rects.popper,O=typeof p=="function"?p(Object.assign({},t.rects,{placement:t.placement})):p,j=typeof O=="number"?{mainAxis:O,altAxis:O}:Object.assign({mainAxis:0,altAxis:0},O),T=t.modifiersData.offset?t.modifiersData.offset[t.placement]:null,L={x:0,y:0};if(k){if(i){var $,I=C==="y"?re:se,M=C==="y"?fe:he,_=C==="y"?"height":"width",D=k[C],F=D+g[I],V=D-g[M],N=h?-R[_]/2:0,U=w===nt?E[_]:R[_],G=w===nt?-R[_]:-E[_],ie=t.elements.arrow,q=h&&ie?cr(ie):{width:0,height:0},H=t.modifiersData["arrow#persistent"]?t.modifiersData["arrow#persistent"].padding:qs(),Q=H[I],Y=H[M],K=yt(0,E[_],q[_]),Z=A?E[_]/2-N-K-Q-j.mainAxis:U-K-Q-j.mainAxis,oe=A?-E[_]/2+N+K+Y+j.mainAxis:G+K+Y+j.mainAxis,J=t.elements.arrow&&Ft(t.elements.arrow),Pe=J?C==="y"?J.clientTop||0:J.clientLeft||0:0,ke=($=T?.[C])!=null?$:0,ct=D+Z-ke-Pe,ut=D+oe-ke,Ve=yt(h?sn(F,ct):F,D,h?Ye(V,ut):V);k[C]=Ve,L[C]=Ve-D}if(a){var He,dt=C==="x"?re:se,ft=C==="x"?fe:he,ve=k[P],Ht=P==="y"?"height":"width",$r=ve+g[dt],Lr=ve-g[ft],Sn=[re,se].indexOf(y)!==-1,Dr=(He=T?.[P])!=null?He:0,Fr=Sn?$r:ve-E[Ht]-R[Ht]-Dr+j.altAxis,zr=Sn?ve+E[Ht]+R[Ht]-Dr-j.altAxis:Lr,Nr=h&&Sn?fa(Fr,ve,zr):yt(h?Fr:$r,ve,h?zr:Lr);k[P]=Nr,L[P]=Nr-ve}t.modifiersData[r]=L}}const Ha={name:"preventOverflow",enabled:!0,phase:"main",fn:Va,requiresIfExists:["offset"]};function Ua(e){return{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}}function Ga(e){return e===ae(e)||!ue(e)?dr(e):Ua(e)}function Xa(e){var t=e.getBoundingClientRect(),n=rt(t.width)/e.offsetWidth||1,r=rt(t.height)/e.offsetHeight||1;return n!==1||r!==1}function Wa(e,t,n){n===void 0&&(n=!1);var r=ue(t),s=ue(t)&&Xa(t),i=Ne(t),o=st(e,s,n),a={scrollLeft:0,scrollTop:0},c={x:0,y:0};return(r||!r&&!n)&&((Ae(t)!=="body"||hr(i))&&(a=Ga(t)),ue(t)?(c=st(t,!0),c.x+=t.clientLeft,c.y+=t.clientTop):i&&(c.x=fr(i))),{x:o.left+a.scrollLeft-c.x,y:o.top+a.scrollTop-c.y,width:o.width,height:o.height}}function Ya(e){var t=new Map,n=new Set,r=[];e.forEach(function(i){t.set(i.name,i)});function s(i){n.add(i.name);var o=[].concat(i.requires||[],i.requiresIfExists||[]);o.forEach(function(a){if(!n.has(a)){var c=t.get(a);c&&s(c)}}),r.push(i)}return e.forEach(function(i){n.has(i.name)||s(i)}),r}function Ka(e){var t=Ya(e);return oa.reduce(function(n,r){return n.concat(t.filter(function(s){return s.phase===r}))},[])}function qa(e){var t;return function(){return t||(t=new Promise(function(n){Promise.resolve().then(function(){t=void 0,n(e())})})),t}}function Qa(e){var t=e.reduce(function(n,r){var s=n[r.name];return n[r.name]=s?Object.assign({},s,r,{options:Object.assign({},s.options,r.options),data:Object.assign({},s.data,r.data)}):r,n},{});return Object.keys(t).map(function(n){return t[n]})}var Jr={placement:"bottom",modifiers:[],strategy:"absolute"};function es(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return!t.some(function(r){return!(r&&typeof r.getBoundingClientRect=="function")})}function Za(e){e===void 0&&(e={});var t=e,n=t.defaultModifiers,r=n===void 0?[]:n,s=t.defaultOptions,i=s===void 0?Jr:s;return function(a,c,l){l===void 0&&(l=i);var u={placement:"bottom",orderedModifiers:[],options:Object.assign({},Jr,i),modifiersData:{},elements:{reference:a,popper:c},attributes:{},styles:{}},d=[],f=!1,h={state:u,setOptions:function(y){var w=typeof y=="function"?y(u.options):y;p(),u.options=Object.assign({},i,u.options,w),u.scrollParents={reference:Ke(a)?vt(a):a.contextElement?vt(a.contextElement):[],popper:vt(c)};var A=Ka(Qa([].concat(r,u.options.modifiers)));return u.orderedModifiers=A.filter(function(C){return C.enabled}),m(),h.update()},forceUpdate:function(){if(!f){var y=u.elements,w=y.reference,A=y.popper;if(es(w,A)){u.rects={reference:Wa(w,Ft(A),u.options.strategy==="fixed"),popper:cr(A)},u.reset=!1,u.placement=u.options.placement,u.orderedModifiers.forEach(function(j){return u.modifiersData[j.name]=Object.assign({},j.data)});for(var C=0;C<u.orderedModifiers.length;C++){if(u.reset===!0){u.reset=!1,C=-1;continue}var P=u.orderedModifiers[C],k=P.fn,E=P.options,R=E===void 0?{}:E,O=P.name;typeof k=="function"&&(u=k({state:u,options:R,name:O,instance:h})||u)}}}},update:qa(function(){return new Promise(function(g){h.forceUpdate(),g(u)})}),destroy:function(){p(),f=!0}};if(!es(a,c))return h;h.setOptions(l).then(function(g){!f&&l.onFirstUpdate&&l.onFirstUpdate(g)});function m(){u.orderedModifiers.forEach(function(g){var y=g.name,w=g.options,A=w===void 0?{}:w,C=g.effect;if(typeof C=="function"){var P=C({state:u,name:y,instance:h,options:A}),k=function(){};d.push(P||k)}})}function p(){d.forEach(function(g){return g()}),d=[]}return h}}var Ja=[Aa,Na,ba,ca,Fa,Ta,Ha,ga,$a],el=Za({defaultModifiers:Ja});function de(e){const{elementType:t,externalSlotProps:n,ownerState:r,skipResolvingSlotProps:s=!1,...i}=e,o=s?{}:Xo(n,r),{props:a,internalRef:c}=Yo({...i,externalSlotProps:o}),l=Pt(c,o?.ref,e.additionalProps?.ref);return Go(t,{...a,ref:l},r)}function tl(e){return parseInt(v.version,10)>=19?e?.props?.ref||null:e?.ref||null}function nl(e){return typeof e=="function"?e():e}const rl=v.forwardRef(function(t,n){const{children:r,container:s,disablePortal:i=!1}=t,[o,a]=v.useState(null),c=Pt(v.isValidElement(r)?tl(r):null,n);if($e(()=>{i||a(nl(s)||document.body)},[s,i]),$e(()=>{if(o&&!i)return Ur(n,o),()=>{Ur(n,null)}},[n,o,i]),i){if(v.isValidElement(r)){const l={ref:c};return v.cloneElement(r,l)}return r}return o&&Ns.createPortal(r,o)});function sl(e){return De("MuiPopper",e)}Fe("MuiPopper",["root"]);function il(e,t){if(t==="ltr")return e;switch(e){case"bottom-end":return"bottom-start";case"bottom-start":return"bottom-end";case"top-end":return"top-start";case"top-start":return"top-end";default:return e}}function Wn(e){return typeof e=="function"?e():e}function ol(e){return e.nodeType!==void 0}const al=e=>{const{classes:t}=e;return je({root:["root"]},sl,t)},ll={},cl=v.forwardRef(function(t,n){const{anchorEl:r,children:s,direction:i,disablePortal:o,modifiers:a,open:c,placement:l,popperOptions:u,popperRef:d,slotProps:f={},slots:h={},TransitionProps:m,ownerState:p,...g}=t,y=v.useRef(null),w=Pt(y,n),A=v.useRef(null),C=Pt(A,d),P=v.useRef(C);$e(()=>{P.current=C},[C]),v.useImperativeHandle(d,()=>A.current,[]);const k=il(l,i),[E,R]=v.useState(k),[O,j]=v.useState(Wn(r));v.useEffect(()=>{A.current&&A.current.forceUpdate()}),v.useEffect(()=>{r&&j(Wn(r))},[r]),$e(()=>{if(!O||!c)return;const M=F=>{R(F.placement)};let _=[{name:"preventOverflow",options:{altBoundary:o}},{name:"flip",options:{altBoundary:o}},{name:"onUpdate",enabled:!0,phase:"afterWrite",fn:({state:F})=>{M(F)}}];a!=null&&(_=_.concat(a)),u&&u.modifiers!=null&&(_=_.concat(u.modifiers));const D=el(O,y.current,{placement:k,...u,modifiers:_});return P.current(D),()=>{D.destroy(),P.current(null)}},[O,o,a,c,u,k]);const T={placement:E};m!==null&&(T.TransitionProps=m);const L=al(t),$=h.root??"div",I=de({elementType:$,externalSlotProps:f.root,externalForwardedProps:g,additionalProps:{role:"tooltip",ref:w},ownerState:t,className:L.root});return x.jsx($,{...I,children:typeof s=="function"?s(T):s})}),ul=v.forwardRef(function(t,n){const{anchorEl:r,children:s,container:i,direction:o="ltr",disablePortal:a=!1,keepMounted:c=!1,modifiers:l,open:u,placement:d="bottom",popperOptions:f=ll,popperRef:h,style:m,transition:p=!1,slotProps:g={},slots:y={},...w}=t,[A,C]=v.useState(!0),P=()=>{C(!1)},k=()=>{C(!0)};if(!c&&!u&&(!p||A))return null;let E;if(i)E=i;else if(r){const j=Wn(r);E=j&&ol(j)?Un(j).body:Un(null).body}const R=!u&&c&&(!p||A)?"none":void 0,O=p?{in:u,onEnter:P,onExited:k}:void 0;return x.jsx(rl,{disablePortal:a,container:E,children:x.jsx(cl,{anchorEl:r,direction:o,disablePortal:a,modifiers:l,ref:n,open:p?!A:u,placement:d,popperOptions:f,popperRef:h,slotProps:g,slots:y,...w,style:{position:"fixed",top:0,left:0,display:R,...m},TransitionProps:O,children:s})})}),dl=W(ul,{name:"MuiPopper",slot:"Root"})({}),fl=v.forwardRef(function(t,n){const r=or(),s=io({props:t,name:"MuiPopper"}),{anchorEl:i,component:o,components:a,componentsProps:c,container:l,disablePortal:u,keepMounted:d,modifiers:f,open:h,placement:m,popperOptions:p,popperRef:g,transition:y,slots:w,slotProps:A,...C}=s,P=w?.root??a?.Root,k={anchorEl:i,container:l,disablePortal:u,keepMounted:d,modifiers:f,open:h,placement:m,popperOptions:p,popperRef:g,transition:y,...C};return x.jsx(dl,{as:o,direction:r?"rtl":"ltr",slots:{root:P},slotProps:A??c,...k,ref:n})});function ti(e){const{children:t,defer:n=!1,fallback:r=null}=e,[s,i]=v.useState(!1);return $e(()=>{n||i(!0)},[n]),v.useEffect(()=>{n&&i(!0)},[n]),s?t:r}function hl(e,t){return t<e?-1:t>e?1:t>=e?0:NaN}function pl(e){return e}function ml(){var e=pl,t=hl,n=null,r=Ue(0),s=Ue(jn),i=Ue(0);function o(a){var c,l=(a=Co(a)).length,u,d,f=0,h=new Array(l),m=new Array(l),p=+r.apply(this,arguments),g=Math.min(jn,Math.max(-jn,s.apply(this,arguments)-p)),y,w=Math.min(Math.abs(g)/l,i.apply(this,arguments)),A=w*(g<0?-1:1),C;for(c=0;c<l;++c)(C=m[h[c]=c]=+e(a[c],c,a))>0&&(f+=C);for(t!=null?h.sort(function(P,k){return t(m[P],m[k])}):n!=null&&h.sort(function(P,k){return n(a[P],a[k])}),c=0,d=f?(g-l*A)/f:0;c<l;++c,p=y)u=h[c],C=m[u],y=p+(C>0?C*d:0)+A,m[u]={data:a[u],index:c,value:C,startAngle:p,endAngle:y,padAngle:w};return m}return o.value=function(a){return arguments.length?(e=typeof a=="function"?a:Ue(+a),o):e},o.sortValues=function(a){return arguments.length?(t=a,n=null,o):t},o.sort=function(a){return arguments.length?(n=a,t=null,o):n},o.startAngle=function(a){return arguments.length?(r=typeof a=="function"?a:Ue(+a),o):r},o.endAngle=function(a){return arguments.length?(s=typeof a=="function"?a:Ue(+a),o):s},o.padAngle=function(a){return arguments.length?(i=typeof a=="function"?a:Ue(+a),o):i},o}function gl(e,t){if((c=e.length)>0)for(var n,r=0,s,i,o,a,c,l=e[t[0]].length;r<l;++r)for(o=a=0,n=0;n<c;++n)(i=(s=e[t[n]][r])[1]-s[0])>0?(s[0]=o,s[1]=o+=i):i<0?(s[1]=a,s[0]=a+=i):(s[0]=0,s[1]=i)}function ni(e){var t=e.map(xl);return hn(e).sort(function(n,r){return t[n]-t[r]})}function xl(e){for(var t=-1,n=0,r=e.length,s,i=-1/0;++t<r;)(s=+e[t][1])>i&&(i=s,n=t);return n}function ri(e){var t=e.map(si);return hn(e).sort(function(n,r){return t[n]-t[r]})}function si(e){for(var t=0,n=-1,r=e.length,s;++n<r;)(s=+e[n][1])&&(t+=s);return t}function yl(e){return ri(e).reverse()}function vl(e){var t=e.length,n,r,s=e.map(si),i=ni(e),o=0,a=0,c=[],l=[];for(n=0;n<t;++n)r=i[n],o<a?(o+=s[r],c.push(r)):(a+=s[r],l.push(r));return l.reverse().concat(c)}function bl(e){return hn(e).reverse()}function wl({filter:e,setFilter:t,closeModal:n}){const{handleSubmit:r,control:s,trigger:i}=uo({defaultValues:{...e}}),o=a=>{t(a),n()};return x.jsxs("form",{onSubmit:r(o),children:[x.jsx(In,{name:"fromDate",control:s,rules:{pattern:{value:Br,message:"Date must be im format yyyy-mm-dd"}},render:({field:a,fieldState:c})=>x.jsx(Vr,{...a,label:"From Date",value:new Date(a.value),onChange:l=>{i("fromDate"),a.onChange(l?Le(l,"yyyy-MM-dd"):void 0)},error:c.error?.message,popoverProps:{withinPortal:!0}})}),x.jsx(In,{name:"toDate",control:s,rules:{pattern:{value:Br,message:"Date must be im format yyyy-mm-dd"}},render:({field:a,fieldState:c})=>x.jsx(Vr,{...a,label:"To Date",value:new Date(a.value),onChange:l=>{i("toDate"),a.onChange(l?Le(l,"yyyy-MM-dd"):void 0)},error:c.error?.message,popoverProps:{withinPortal:!0}})}),x.jsx(In,{name:"currency",control:s,render:({field:a,fieldState:c})=>x.jsx(fo,{...a,label:"Currency",defaultValue:En.Usd,error:c.error?.message,data:Object.keys(En).map(l=>En[l])})}),x.jsxs("div",{className:"flex justify-center mt-5 gap-3",children:[x.jsx("button",{type:"submit",className:"text-white bg-indigo-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-indigo-600 rounded-sm text-lg",children:"Filter"}),x.jsx("button",{type:"button",className:"text-white bg-rose-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-rose-600 rounded-sm text-lg",onClick:n,children:"Cancel"})]})]})}function Al({filter:e,setFilter:t}){const[n,r]=v.useState(!1),{get:s,set:i}=Bs();function o(a){a||={fromDate:Le(new Date,"yyyy-MM-DD"),toDate:Le(new Date,"yyyy-MM-DD")},ho(a,e)||t(a)}return v.useEffect(()=>{const a=oo(e??{})?null:encodeURIComponent(JSON.stringify(e)),c=s("MonthlyIncomeExpenseChartFilters");a!==c&&i("MonthlyIncomeExpenseChartFilters",a)},[e,s,i]),x.jsxs(x.Fragment,{children:[x.jsx(ao,{opened:n,onClose:()=>r(!1),content:x.jsx(wl,{filter:e,setFilter:o,closeModal:()=>r(!1)})}),x.jsx(lo,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>r(!0),children:x.jsx(co,{className:"size-5"})})]})}const pr="DEFAULT_X_AXIS_KEY",mr="DEFAULT_Y_AXIS_KEY",Cl={top:50,bottom:50,left:50,right:50},ii=v.createContext({isInitialized:!1,data:{highlightedItem:null,setHighlighted:()=>{},clearHighlighted:()=>{},isHighlighted:()=>!1,isFaded:()=>!1}}),Pl=(e,t)=>n=>e?e.fade==="series"?n.seriesId===t?.seriesId&&n.dataIndex!==t?.dataIndex:e.fade==="global"?n.seriesId!==t?.seriesId||n.dataIndex!==t?.dataIndex:!1:!1,kl=(e,t)=>n=>e?e.highlight==="series"?n.seriesId===t?.seriesId:e.highlight==="item"?n.dataIndex===t?.dataIndex&&n.seriesId===t?.seriesId:!1:!1,Sl=["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"];function Il(e,t,n=Sl){return e.type==="pie"?b({},e,{data:e.data.map((r,s)=>b({color:n[s%n.length]},r))}):b({color:n[t%n.length]},e)}const El=({series:e,colors:t,seriesFormatters:n,dataset:r})=>{const s={};e.forEach((o,a)=>{const{id:c=`auto-generated-id-${a}`,type:l}=o;if(s[l]===void 0&&(s[l]={series:{},seriesOrder:[]}),s[l]?.series[c]!==void 0)throw new Error(`MUI X: series' id "${c}" is not unique.`);s[l].series[c]=b({id:c},Il(o,a,t)),s[l].seriesOrder.push(c)});const i={};return Object.keys(n).forEach(o=>{const a=s[o];a!==void 0&&(i[o]=n[o]?.(a,r)??s[o])}),i},Ml=["#02B2AF","#2E96FF","#B800D8","#60009B","#2731C8","#03008D"],jl=["#02B2AF","#72CCFF","#DA00FF","#9001CB","#2E96FF","#3B48E0"],Ol=e=>e==="dark"?jl:Ml,oi=v.createContext({isInitialized:!1,data:{}}),zt=v.createContext({isInitialized:!1,data:{colorProcessors:{},seriesFormatters:{},xExtremumGetters:{},yExtremumGetters:{},rotationExtremumGetters:{},radiusExtremumGetters:{}}}),ts=(e,t)=>t==="x"?{x:e,y:null}:{x:null,y:e},ai=e=>{const{axis:t,getFilters:n,isDefaultAxis:r}=e,s=n?.({currentAxisId:t.id,isDefaultAxis:r}),i=s?t.data?.filter((c,l)=>s({x:null,y:null},l)):t.data,o=Math.min(...i??[]),a=Math.max(...i??[]);return[o,a]},li=e=>t=>{const{series:n,axis:r,getFilters:s,isDefaultAxis:i}=t;return Object.keys(n).filter(o=>{const a=n[o].yAxisId??n[o].yAxisKey;return a===r.id||i&&a===void 0}).reduce((o,a)=>{const{stackedData:c}=n[a],l=s?.({currentAxisId:r.id,isDefaultAxis:i,seriesXAxisId:n[a].xAxisId??n[a].xAxisKey,seriesYAxisId:n[a].yAxisId??n[a].yAxisKey}),[u,d]=c?.reduce((f,h,m)=>l&&(!l(ts(h[0],e),m)||!l(ts(h[1],e),m))?f:[Math.min(...h,f[0]),Math.max(...h,f[1])],[1/0,-1/0])??[1/0,-1/0];return[Math.min(u,o[0]),Math.max(d,o[1])]},[1/0,-1/0])},Rl=e=>Object.keys(e.series).some(n=>e.series[n].layout==="horizontal")?li("x")(e):ai(e),Tl=e=>Object.keys(e.series).some(n=>e.series[n].layout==="horizontal")?ai(e):li("y")(e),On={appearance:ni,ascending:ri,descending:yl,insideOut:vl,none:hn,reverse:bl},Rn={expand:Io,diverging:gl,none:Po,silhouette:So,wiggle:ko},ci=e=>{const{series:t,seriesOrder:n,defaultStrategy:r}=e,s=[],i={};return n.forEach(o=>{const{stack:a,stackOrder:c,stackOffset:l}=t[o];a===void 0?s.push({ids:[o],stackingOrder:On.none,stackingOffset:Rn.none}):i[a]===void 0?(i[a]=s.length,s.push({ids:[o],stackingOrder:On[c??r?.stackOrder??"none"],stackingOffset:Rn[l??r?.stackOffset??"diverging"]})):(s[i[a]].ids.push(o),c!==void 0&&(s[i[a]].stackingOrder=On[c]),l!==void 0&&(s[i[a]].stackingOffset=Rn[l]))}),s};function ui(e,t){const n={};return Object.keys(e).forEach(r=>{n[r]=b({},e[r],{valueFormatter:e[r].valueFormatter??t})}),n}const _l=(e,t)=>{const{seriesOrder:n,series:r}=e,s=ci(e),i=t??[];n.forEach(a=>{const c=r[a].data;if(c!==void 0)c.forEach((l,u)=>{i.length<=u?i.push({[a]:l}):i[u][a]=l});else if(t===void 0)throw new Error([`MUI X: bar series with id='${a}' has no data.`,"Either provide a data property to the series or use the dataset prop."].join(`
2
2
  `))});const o={};return s.forEach(a=>{const{ids:c,stackingOffset:l,stackingOrder:u}=a,d=Hs().keys(c.map(f=>{const h=r[f].dataKey;return r[f].data===void 0&&h!==void 0?h:f})).value((f,h)=>f[h]??0).order(u).offset(l)(i);c.forEach((f,h)=>{const m=r[f].dataKey;o[f]=b({layout:"vertical"},r[f],{data:m?t.map(p=>{const g=p[m];return typeof g!="number"?0:g}):r[f].data,stackedData:d[h].map(([p,g])=>[p,g])})})}),{seriesOrder:n,stackingGroups:s,series:ui(o,a=>a==null?"":a.toLocaleString())}},di=(e,t,n)=>{const r=e.layout==="vertical",s=r?t?.colorScale:n?.colorScale,i=r?n?.colorScale:t?.colorScale,o=r?t?.data:n?.data;return i?a=>{const c=e.data[a],l=c===null?e.color:i(c);return l===null?e.color:l}:s&&o?a=>{const c=o[a],l=c===null?e.color:s(c);return l===null?e.color:l}:()=>e.color},$l={seriesType:"bar",seriesFormatter:_l,colorProcessor:di,xExtremumGetter:Rl,yExtremumGetter:Tl},on=(e,t)=>[t[0]===null?e[0]:Math.min(e[0],t[0]),t[1]===null?e[1]:Math.max(e[1],t[1])],Ll=e=>{const{series:t,axis:n,isDefaultAxis:r,getFilters:s}=e;return Object.keys(t).filter(i=>{const o=t[i].xAxisId??t[i].xAxisKey;return o===n.id||o===void 0&&r}).reduce((i,o)=>{const a=s?.({currentAxisId:n.id,isDefaultAxis:r,seriesXAxisId:t[o].xAxisId??t[o].xAxisKey,seriesYAxisId:t[o].yAxisId??t[o].yAxisKey}),c=t[o].data?.reduce((l,u,d)=>a&&!a(u,d)?l:on(l,[u.x,u.x]),[1/0,-1/0]);return on(i,c??[1/0,-1/0])},[1/0,-1/0])},Dl=e=>{const{series:t,axis:n,isDefaultAxis:r,getFilters:s}=e;return Object.keys(t).filter(i=>{const o=t[i].yAxisId??t[i].yAxisKey;return o===n.id||o===void 0&&r}).reduce((i,o)=>{const a=s?.({currentAxisId:n.id,isDefaultAxis:r,seriesXAxisId:t[o].xAxisId??t[o].xAxisKey,seriesYAxisId:t[o].yAxisId??t[o].yAxisKey}),c=t[o].data?.reduce((l,u,d)=>a&&!a(u,d)?l:on(l,[u.y,u.y]),[1/0,-1/0]);return on(i,c??[1/0,-1/0])},[1/0,-1/0])},Fl=({series:e,seriesOrder:t},n)=>({series:Object.fromEntries(Object.entries(e).map(([s,i])=>{const o=i?.datasetKeys,a=["x","y","id"].filter(l=>typeof o?.[l]!="string");if(i?.datasetKeys&&a.length>0)throw new Error([`MUI X: scatter series with id='${s}' has incomplete datasetKeys.`,`Properties ${a.map(l=>`"${l}"`).join(", ")} are missing.`].join(`
3
3
  `));const c=o?n?.map(l=>({x:l[o.x]??null,y:l[o.y]??null,z:o.z&&l[o.z],id:l[o.id]}))??[]:i.data??[];return[s,b({},i,{data:c,valueFormatter:i.valueFormatter??(l=>`(${l.x}, ${l.y})`)})]})),seriesOrder:t}),zl=(e,t,n,r)=>{const s=r?.colorScale,i=n?.colorScale,o=t?.colorScale;return s?a=>{if(r?.data?.[a]!==void 0){const u=s(r?.data?.[a]);if(u!==null)return u}const c=e.data[a],l=c===null?e.color:s(c.z);return l===null?e.color:l}:i?a=>{const c=e.data[a],l=c===null?e.color:i(c.y);return l===null?e.color:l}:o?a=>{const c=e.data[a],l=c===null?e.color:o(c.x);return l===null?e.color:l}:()=>e.color},Nl={seriesType:"scatter",seriesFormatter:Fl,colorProcessor:zl,xExtremumGetter:Ll,yExtremumGetter:Dl},Bl=e=>{const{axis:t}=e,n=Math.min(...t.data??[]),r=Math.max(...t.data??[]);return[n,r]};function Vl(e,t,n){return t.reduce((r,s,i)=>{const[o,a]=e(s);return n&&(!n({y:o,x:null},i)||!n({y:a,x:null},i))?r:[Math.min(o,a,r[0]),Math.max(o,a,r[1])]},[1/0,-1/0])}const Hl=e=>{const{series:t,axis:n,isDefaultAxis:r,getFilters:s}=e;return Object.keys(t).filter(i=>{const o=t[i].yAxisId??t[i].yAxisKey;return o===n.id||r&&o===void 0}).reduce((i,o)=>{const{area:a,stackedData:c}=t[o],l=a!==void 0,u=s?.({currentAxisId:n.id,isDefaultAxis:r,seriesXAxisId:t[o].xAxisId??t[o].xAxisKey,seriesYAxisId:t[o].yAxisId??t[o].yAxisKey}),d=l&&n.scaleType!=="log"&&typeof t[o].baseline!="string"?p=>p:p=>[p[1],p[1]],f=Vl(d,c,u),[h,m]=f;return[Math.min(h,i[0]),Math.max(m,i[1])]},[1/0,-1/0])},Ul=(e,t)=>{const{seriesOrder:n,series:r}=e,s=ci(b({},e,{defaultStrategy:{stackOffset:"none"}})),i=t??[];n.forEach(a=>{const c=r[a].data;c!==void 0&&c.forEach((l,u)=>{i.length<=u?i.push({[a]:l}):i[u][a]=l})});const o={};return s.forEach(a=>{const{ids:c,stackingOrder:l,stackingOffset:u}=a,d=Hs().keys(c.map(f=>{const h=r[f].dataKey;return r[f].data===void 0&&h!==void 0?h:f})).value((f,h)=>f[h]??0).order(l).offset(u)(i);c.forEach((f,h)=>{const m=r[f].dataKey;o[f]=b({},r[f],{data:m?t.map(p=>{const g=p[m];return typeof g!="number"?null:g}):r[f].data,stackedData:d[h].map(([p,g])=>[p,g])})})}),{seriesOrder:n,stackingGroups:s,series:ui(o,a=>a==null?"":a.toLocaleString())}},Gl=(e,t,n)=>{const r=n?.colorScale,s=t?.colorScale;return r?i=>{const o=e.data[i],a=o===null?e.color:r(o);return a===null?e.color:a}:s?i=>{const o=t.data?.[i],a=o===null?e.color:s(o);return a===null?e.color:a}:()=>e.color},Xl={seriesType:"line",colorProcessor:Gl,seriesFormatter:Ul,xExtremumGetter:Bl,yExtremumGetter:Hl};function Ee(e,t){return typeof e=="function"?e(t):e}const Wl=(e="none")=>{if(typeof e=="function")return e;switch(e){case"none":return null;case"desc":return(t,n)=>n-t;case"asc":return(t,n)=>t-n;default:return null}},Yl=e=>{const{seriesOrder:t,series:n}=e,r={};return t.forEach(s=>{const i=ml().startAngle(2*Math.PI*(n[s].startAngle??0)/360).endAngle(2*Math.PI*(n[s].endAngle??360)/360).padAngle(2*Math.PI*(n[s].paddingAngle??0)/360).sortValues(Wl(n[s].sortingValues??"none"))(n[s].data.map(o=>o.value));r[s]=b({valueFormatter:o=>o.value.toLocaleString()},n[s],{data:n[s].data.map((o,a)=>b({},o,{id:o.id??`auto-generated-pie-id-${s}-${a}`},i[a])).map((o,a)=>b({},o,{formattedValue:n[s].valueFormatter?.(b({},o,{label:Ee(o.label,"arc")}),{dataIndex:a})??o.value.toLocaleString()}))})}),{seriesOrder:t,series:r}},Kl=e=>t=>e.data[t].color,ql={seriesType:"pie",colorProcessor:Kl,seriesFormatter:Yl},Ql=[$l,Nl,Xl,ql];function Zl(e){const t=e??Ql,n={},r={},s={},i={},o={},a={};for(let c=0;c<t.length;c+=1){const l=t[c],u=l.seriesType;n[u]=l.seriesFormatter,r[u]=l.colorProcessor,l.xExtremumGetter&&(s[u]=l.xExtremumGetter),l.yExtremumGetter&&(i[u]=l.yExtremumGetter),l.rotationExtremumGetter&&(o[u]=l.rotationExtremumGetter),l.radiusExtremumGetter&&(a[u]=l.radiusExtremumGetter)}return{seriesFormatters:n,colorProcessors:r,xExtremumGetters:s,yExtremumGetters:i,rotationExtremumGetters:o,radiusExtremumGetters:a}}function Jl(e){const{children:t,plugins:n}=e,r=v.useMemo(()=>({isInitialized:!0,data:Zl(n)}),[n]);return x.jsx(zt.Provider,{value:r,children:t})}function fi(e){const{isInitialized:t,data:n}=v.useContext(zt);if(!t)throw new Error(["MUI X: Could not find the plugin context.","It looks like you rendered your component outside of a ChartsContainer parent component."].join(`
4
4
  `));return n.colorProcessors}function ec(e){const{isInitialized:t,data:n}=v.useContext(zt);if(!t)throw new Error(["MUI X: Could not find the plugin context.","It looks like you rendered your component outside of a ChartsContainer parent component."].join(`
@@ -1,5 +1,5 @@
1
- import{D as U,r as b,cd as W,j as e,K as z,an as G,B as g,c$ as R,N as Q,ap as X,aq as Z,bf as T,aM as K,b5 as A,au as k,av as O,aw as M,ax as E,ay as D,cS as J,X as j,bn as w,eR as I,eS as ee,eT as S,eU as se,eV as L,eW as B,eX as P,eY as N,eZ as p,e_ as Y,e$ as $,dN as re,f0 as te,bi as ae,bj as le,bk as v,f1 as V,F as de,a as ne,Y as oe,Z as ce,a1 as ie,f2 as ue}from"./index-DfI9E1Fb.js";import{B as me}from"./building-2-B92gXbOj.js";import{S as xe}from"./save-D84vX5ea.js";/**
2
- * @license lucide-react v0.546.0 - ISC
1
+ import{D as U,r as b,cd as W,j as e,K as z,an as G,B as g,c$ as R,N as Q,ap as X,aq as Z,bf as T,aM as K,b5 as A,au as k,av as O,aw as M,ax as E,ay as D,cS as J,X as j,bn as w,eR as I,eS as ee,eT as S,eU as se,eV as L,eW as B,eX as P,eY as N,eZ as p,e_ as Y,e$ as $,dN as re,f0 as te,bi as ae,bj as le,bk as v,f1 as V,F as de,a as ne,Y as oe,Z as ce,a1 as ie,f2 as ue}from"./index-B9S5s-Ek.js";import{B as me}from"./building-2-ClFm6mRd.js";import{S as xe}from"./save-ZDLsO-Uf.js";/**
2
+ * @license lucide-react v0.548.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
5
5
  * See the LICENSE file in the root directory of this source tree.
@@ -1 +1 @@
1
- import{i as f,fQ as I,r as u,t as l,l as p,V as b,X as y,j as e,a0 as C,fz as $,a2 as D,a3 as F,a4 as w,a5 as k,v as j,a7 as v,fR as E,fS as S,ab as z,o as A,T as M,B as T,c7 as O,q as L,fT as P,fU as q,F as B,a as U,fV as R,c as V,L as _,bR as Q,bS as G,fW as W}from"./index-DfI9E1Fb.js";const X="updateTag",H=()=>{const[{fetching:i},r]=f(I),c=u.useCallback(async a=>{const t=`Error updating tag ID [${a.tagId}]`,s=`${X}-${a.tagId}`;l.loading("Updating Tag...",{id:s});try{const n=await r(a),d=p(n,t,s,"updateTag");if(d)return l.success("Success",{id:s,description:"Tag updated"}),d.updateTag}catch(n){console.error(`${t}: ${n}`),l.error("Error",{id:s,description:t,duration:1e5,closeButton:!0})}return!1},[r]);return{fetching:i,updateTag:c}},J=({onDone:i,data:r,close:c})=>{const{updateTag:a,fetching:t}=H(),s=y(S,r),n=b({defaultValues:{name:s.name,parentId:s.parent?.id}}),{control:d,handleSubmit:m,formState:{dirtyFields:h}}=n,x=o=>{const g=z(o,h);c(),g&&Object.keys(g).length>0&&a({tagId:s.id,fields:g}).then(()=>i?.())};return e.jsx(C,{...n,children:e.jsxs("form",{onSubmit:m(x),children:[e.jsx("div",{className:"flex-row px-10 h-max justify-start block",children:e.jsxs($,{cols:3,children:[e.jsx(D,{name:"name",control:d,defaultValue:s.name,rules:{required:"Required",minLength:{value:2,message:"Must be at least 2 characters"}},render:({field:o})=>e.jsxs(F,{children:[e.jsx(w,{children:"Name"}),e.jsx(k,{children:e.jsx(j,{...o,value:o.value??void 0})}),e.jsx(v,{})]})}),e.jsx(E,{formManager:n,tagsPath:"parentId",label:"Parent Tag"})]})}),e.jsxs("div",{className:"mt-10 mb-5 flex justify-center gap-5",children:[e.jsx("button",{type:"submit",onClick:()=>m(x),className:"mt-8 text-white bg-indigo-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-indigo-600 rounded-sm text-lg",disabled:t||Object.keys(h).length===0,children:"Accept"}),e.jsx("button",{type:"button",className:"mt-8 text-white bg-rose-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-rose-600 rounded-sm text-lg",onClick:c,children:"Cancel"})]})]})})},K=({onDone:i,data:r})=>{const[c,{open:a,close:t}]=A(!1);function s(){t(),i?.()}return e.jsxs(e.Fragment,{children:[e.jsx(M,{label:"Edit Tag",children:e.jsx(T,{variant:"ghost",size:"icon",className:"size-7.5",onClick:a,children:e.jsx(O,{className:"size-5"})})}),e.jsx(L,{centered:!0,opened:c,onClose:t,title:"Insert Business Trip",children:e.jsx(J,{close:t,onDone:s,data:r})})]})},Y="addTag",Z=()=>{const[{fetching:i},r]=f(P),c=u.useCallback(async a=>{const t=`Error adding new tag [${a.tagName}]`,s=`${Y}-${a.tagName}`;l.loading("Adding tag",{id:s});try{const n=await r(a);p(n,t,s)&&l.success("Success",{id:s,description:`"${a.tagName}" tag was successfully added`})}catch(n){console.error(`${t}: ${n}`),l.error("Error",{id:s,description:t,duration:1e5,closeButton:!0})}},[r]);return{fetching:i,addTag:c}},ee="deleteTag",se=()=>{const[{fetching:i},r]=f(q),c=u.useCallback(async a=>{const t=`Error deleting new tag [${a.name}]`,s=`${ee}-${a.tagId}`;l.loading(`Deleting tag [${a.name}]`,{id:s});try{const n=await r(a);p(n,t,s)&&l.success("Tag Deleted",{id:s,description:`[${a.name}] tag was successfully removed`})}catch(n){console.error(`${t}: ${n}`),l.error("Error",{id:s,description:t,duration:1e5,closeButton:!0})}},[r]);return{fetching:i,deleteTag:c}},te=()=>{const{setFiltersContext:i}=u.useContext(B),[r,c]=u.useState(""),[{data:a,fetching:t},s]=U({query:W}),{addTag:n}=Z(),{deleteTag:d}=se();i(null);const m=R(a?.allTags??[]),h=u.useCallback(o=>{o.length>2&&n({tagName:o}).then(()=>{s()})},[n,s]),x=u.useCallback((o,g)=>{d({tagId:o,name:g}).then(()=>{s()})},[d,s]);return e.jsx(V,{title:"Tags",description:"Manage tags for your bookmarks.",children:t?e.jsx(_,{className:"h-10 w-10 animate-spin mr-2 self-center"}):e.jsxs("div",{className:"h-full flex flex-col overflow-hidden",children:[m?.map(o=>e.jsxs("div",{className:"flex items-center gap-2 text-gray-600 mb-2",children:[e.jsxs("div",{className:"w-full mt-1 relative rounded-md shadow-xs",children:[o.namePath?.map((g,N)=>e.jsx("span",{className:"ms-2"},N)),o.name]}),e.jsx(K,{data:o}),e.jsx(T,{variant:"ghost",size:"icon",className:"size-7.5",onClick:()=>x(o.id,o.name),children:e.jsx(Q,{className:"size-5"})})]},o.id)),e.jsxs("div",{className:"flex justify-start items-center gap-2 text-gray-600 mb-2",children:[e.jsx(j,{className:"w-80",value:r,onChange:o=>c(o.currentTarget.value),placeholder:"Add new tag",required:!0}),e.jsx(T,{variant:"ghost",size:"icon",className:"size-7.5",disabled:r.length<2,onClick:()=>h(r),children:e.jsx(G,{className:"size-5"})})]})]})})};export{te as TagsManager};
1
+ import{i as f,fQ as I,r as u,t as l,l as p,V as b,X as y,j as e,a0 as C,fz as $,a2 as D,a3 as F,a4 as w,a5 as k,v as j,a7 as v,fR as E,fS as S,ab as z,o as A,T as M,B as T,c7 as O,q as L,fT as P,fU as q,F as B,a as U,fV as R,c as V,L as _,bR as Q,bS as G,fW as W}from"./index-B9S5s-Ek.js";const X="updateTag",H=()=>{const[{fetching:i},r]=f(I),c=u.useCallback(async a=>{const t=`Error updating tag ID [${a.tagId}]`,s=`${X}-${a.tagId}`;l.loading("Updating Tag...",{id:s});try{const n=await r(a),d=p(n,t,s,"updateTag");if(d)return l.success("Success",{id:s,description:"Tag updated"}),d.updateTag}catch(n){console.error(`${t}: ${n}`),l.error("Error",{id:s,description:t,duration:1e5,closeButton:!0})}return!1},[r]);return{fetching:i,updateTag:c}},J=({onDone:i,data:r,close:c})=>{const{updateTag:a,fetching:t}=H(),s=y(S,r),n=b({defaultValues:{name:s.name,parentId:s.parent?.id}}),{control:d,handleSubmit:m,formState:{dirtyFields:h}}=n,x=o=>{const g=z(o,h);c(),g&&Object.keys(g).length>0&&a({tagId:s.id,fields:g}).then(()=>i?.())};return e.jsx(C,{...n,children:e.jsxs("form",{onSubmit:m(x),children:[e.jsx("div",{className:"flex-row px-10 h-max justify-start block",children:e.jsxs($,{cols:3,children:[e.jsx(D,{name:"name",control:d,defaultValue:s.name,rules:{required:"Required",minLength:{value:2,message:"Must be at least 2 characters"}},render:({field:o})=>e.jsxs(F,{children:[e.jsx(w,{children:"Name"}),e.jsx(k,{children:e.jsx(j,{...o,value:o.value??void 0})}),e.jsx(v,{})]})}),e.jsx(E,{formManager:n,tagsPath:"parentId",label:"Parent Tag"})]})}),e.jsxs("div",{className:"mt-10 mb-5 flex justify-center gap-5",children:[e.jsx("button",{type:"submit",onClick:()=>m(x),className:"mt-8 text-white bg-indigo-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-indigo-600 rounded-sm text-lg",disabled:t||Object.keys(h).length===0,children:"Accept"}),e.jsx("button",{type:"button",className:"mt-8 text-white bg-rose-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-rose-600 rounded-sm text-lg",onClick:c,children:"Cancel"})]})]})})},K=({onDone:i,data:r})=>{const[c,{open:a,close:t}]=A(!1);function s(){t(),i?.()}return e.jsxs(e.Fragment,{children:[e.jsx(M,{label:"Edit Tag",children:e.jsx(T,{variant:"ghost",size:"icon",className:"size-7.5",onClick:a,children:e.jsx(O,{className:"size-5"})})}),e.jsx(L,{centered:!0,opened:c,onClose:t,title:"Insert Business Trip",children:e.jsx(J,{close:t,onDone:s,data:r})})]})},Y="addTag",Z=()=>{const[{fetching:i},r]=f(P),c=u.useCallback(async a=>{const t=`Error adding new tag [${a.tagName}]`,s=`${Y}-${a.tagName}`;l.loading("Adding tag",{id:s});try{const n=await r(a);p(n,t,s)&&l.success("Success",{id:s,description:`"${a.tagName}" tag was successfully added`})}catch(n){console.error(`${t}: ${n}`),l.error("Error",{id:s,description:t,duration:1e5,closeButton:!0})}},[r]);return{fetching:i,addTag:c}},ee="deleteTag",se=()=>{const[{fetching:i},r]=f(q),c=u.useCallback(async a=>{const t=`Error deleting new tag [${a.name}]`,s=`${ee}-${a.tagId}`;l.loading(`Deleting tag [${a.name}]`,{id:s});try{const n=await r(a);p(n,t,s)&&l.success("Tag Deleted",{id:s,description:`[${a.name}] tag was successfully removed`})}catch(n){console.error(`${t}: ${n}`),l.error("Error",{id:s,description:t,duration:1e5,closeButton:!0})}},[r]);return{fetching:i,deleteTag:c}},te=()=>{const{setFiltersContext:i}=u.useContext(B),[r,c]=u.useState(""),[{data:a,fetching:t},s]=U({query:W}),{addTag:n}=Z(),{deleteTag:d}=se();i(null);const m=R(a?.allTags??[]),h=u.useCallback(o=>{o.length>2&&n({tagName:o}).then(()=>{s()})},[n,s]),x=u.useCallback((o,g)=>{d({tagId:o,name:g}).then(()=>{s()})},[d,s]);return e.jsx(V,{title:"Tags",description:"Manage tags for your bookmarks.",children:t?e.jsx(_,{className:"h-10 w-10 animate-spin mr-2 self-center"}):e.jsxs("div",{className:"h-full flex flex-col overflow-hidden",children:[m?.map(o=>e.jsxs("div",{className:"flex items-center gap-2 text-gray-600 mb-2",children:[e.jsxs("div",{className:"w-full mt-1 relative rounded-md shadow-xs",children:[o.namePath?.map((g,N)=>e.jsx("span",{className:"ms-2"},N)),o.name]}),e.jsx(K,{data:o}),e.jsx(T,{variant:"ghost",size:"icon",className:"size-7.5",onClick:()=>x(o.id,o.name),children:e.jsx(Q,{className:"size-5"})})]},o.id)),e.jsxs("div",{className:"flex justify-start items-center gap-2 text-gray-600 mb-2",children:[e.jsx(j,{className:"w-80",value:r,onChange:o=>c(o.currentTarget.value),placeholder:"Add new tag",required:!0}),e.jsx(T,{variant:"ghost",size:"icon",className:"size-7.5",disabled:r.length<2,onClick:()=>h(r),children:e.jsx(G,{className:"size-5"})})]})]})})};export{te as TagsManager};
@@ -1 +1 @@
1
- import{r as h,j as e,c_ as u,eK as p,B as y,c$ as g,bp as D,F as P,a as w,c as R,L as E,ca as v,eL as F}from"./index-DfI9E1Fb.js";import{d as C}from"./graphql-document-dedupe-fragments-ByT8-wlV.js";import{R as d}from"./report-commentary-row-CF-l1YIC.js";function A({year:l,setYear:m,referenceYears:o,setReferenceYears:j}){const[c,x]=h.useState(!1);return e.jsxs(e.Fragment,{children:[e.jsx(u,{opened:c,onClose:()=>x(!1),withCloseButton:!0,content:e.jsxs(e.Fragment,{children:[e.jsx(p,{label:"Change report year",value:new Date(l,0,1),onChange:n=>n&&m(n?.getFullYear()),popoverProps:{withinPortal:!0},minDate:new Date(2010,0,1),maxDate:new Date}),e.jsx(p,{type:"multiple",label:"Pick reference years",value:o?.map(n=>new Date(n,0,1)),onChange:n=>j(n.map(i=>i.getFullYear()).filter(i=>l!==i)),popoverProps:{withinPortal:!0},minDate:new Date(2010,0,1),maxDate:new Date})]})}),e.jsx(y,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>x(!0),children:e.jsx(g,{className:"size-5"})})]})}const b=()=>{const{year:l}=D(),{setFiltersContext:m}=h.useContext(P),[o,j]=h.useState(l?Number(l):new Date().getFullYear()),[c,x]=h.useState([]),[{data:n,fetching:i}]=w({query:C(F),variables:{reportYear:o,referenceYears:c}});h.useEffect(()=>{m(e.jsx("div",{className:"flex flex-row gap-2",children:e.jsx(A,{year:o,setYear:j,referenceYears:c,setReferenceYears:x})}))},[o,i,m,c,x]);const f=n?.profitAndLossReport,a=f?.report,s=f?.reference??[];return e.jsx(R,{title:"Profit and Loss Report",children:i?e.jsx(E,{className:"h-10 w-10 animate-spin mr-2 self-center"}):e.jsx("div",{className:"flex flex-col gap-4",children:a&&e.jsxs(v,{highlightOnHover:!0,fontSize:"md",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{}),e.jsx("th",{children:o},o),e.jsx("th",{}),s.map(t=>e.jsx("th",{children:t.year},t.year))]})}),e.jsxs("tbody",{children:[e.jsx(d,{dataRow:t=>e.jsxs("tr",{children:[e.jsx("th",{children:"Revenue"}),e.jsx("th",{children:a.revenue.amount.formatted}),e.jsx("th",{children:t}),s.map(r=>e.jsx("th",{children:r.revenue.amount.formatted},r.year))]}),commentaryData:a.revenue}),e.jsx(d,{dataRow:t=>e.jsxs("tr",{children:[e.jsx("td",{children:"Cost of Sales"}),e.jsx("td",{children:a.costOfSales.amount.formatted}),e.jsx("th",{children:t}),s.map(r=>e.jsx("td",{children:r.costOfSales.amount.formatted},r.year))]}),commentaryData:a.costOfSales}),e.jsxs("tr",{children:[e.jsx("th",{children:"Gross Profit"}),e.jsx("th",{children:a.grossProfit.formatted}),e.jsx("th",{}),s.map(t=>e.jsx("th",{children:t.grossProfit.formatted},t.year))]}),e.jsx(d,{dataRow:t=>e.jsxs("tr",{children:[e.jsx("td",{children:"R&D Expenses"}),e.jsx("td",{children:a.researchAndDevelopmentExpenses.amount.formatted}),e.jsx("th",{children:t}),s.map(r=>e.jsx("td",{children:r.researchAndDevelopmentExpenses.amount.formatted},r.year))]}),commentaryData:a.researchAndDevelopmentExpenses}),e.jsx(d,{dataRow:t=>e.jsxs("tr",{children:[e.jsx("td",{children:"Marketing Expenses"}),e.jsx("td",{children:a.marketingExpenses.amount.formatted}),e.jsx("th",{children:t}),s.map(r=>e.jsx("td",{children:r.marketingExpenses.amount.formatted},r.year))]}),commentaryData:a.marketingExpenses}),e.jsx(d,{dataRow:t=>e.jsxs("tr",{children:[e.jsx("td",{children:"Management and General Expenses"}),e.jsx("td",{children:a.managementAndGeneralExpenses.amount.formatted}),e.jsx("th",{children:t}),s.map(r=>e.jsx("td",{children:r.managementAndGeneralExpenses.amount.formatted},r.year))]}),commentaryData:a.managementAndGeneralExpenses}),e.jsxs("tr",{children:[e.jsx("th",{children:"Operating Profit"}),e.jsx("th",{children:a.operatingProfit.formatted}),e.jsx("th",{}),s.map(t=>e.jsx("th",{children:t.operatingProfit.formatted},t.year))]}),e.jsx(d,{dataRow:t=>e.jsxs("tr",{children:[e.jsx("td",{children:"Financial Expenses"}),e.jsx("td",{children:a.financialExpenses.amount.formatted}),e.jsx("th",{children:t}),s.map(r=>e.jsx("td",{children:r.financialExpenses.amount.formatted},r.year))]}),commentaryData:a.financialExpenses}),e.jsx(d,{dataRow:t=>e.jsxs("tr",{children:[e.jsx("td",{children:"Other Income"}),e.jsx("td",{children:a.otherIncome.amount.formatted}),e.jsx("th",{children:t}),s.map(r=>e.jsx("td",{children:r.otherIncome.amount.formatted},r.year))]}),commentaryData:a.otherIncome}),e.jsxs("tr",{children:[e.jsx("th",{children:"Profit Before Tax"}),e.jsx("th",{children:a.profitBeforeTax.formatted}),e.jsx("th",{}),s.map(t=>e.jsx("th",{children:t.profitBeforeTax.formatted},t.year))]}),e.jsxs("tr",{children:[e.jsx("td",{children:"Tax"}),e.jsx("td",{children:a.tax.formatted}),e.jsx("td",{}),s.map(t=>e.jsx("td",{children:t.tax.formatted},t.year))]})]}),e.jsx("tfoot",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Net Profit"}),e.jsx("th",{children:a.netProfit.formatted}),e.jsx("th",{}),s.map(t=>e.jsx("th",{children:t.netProfit.formatted},t.year))]})})]})})})};export{b as ProfitAndLossReport};
1
+ import{r as h,j as e,c_ as u,eK as p,B as y,c$ as g,bp as D,F as P,a as w,c as R,L as E,ca as v,eL as F}from"./index-B9S5s-Ek.js";import{d as C}from"./graphql-document-dedupe-fragments-ByT8-wlV.js";import{R as d}from"./report-commentary-row-5CDlBkOP.js";function A({year:l,setYear:m,referenceYears:o,setReferenceYears:j}){const[c,x]=h.useState(!1);return e.jsxs(e.Fragment,{children:[e.jsx(u,{opened:c,onClose:()=>x(!1),withCloseButton:!0,content:e.jsxs(e.Fragment,{children:[e.jsx(p,{label:"Change report year",value:new Date(l,0,1),onChange:n=>n&&m(n?.getFullYear()),popoverProps:{withinPortal:!0},minDate:new Date(2010,0,1),maxDate:new Date}),e.jsx(p,{type:"multiple",label:"Pick reference years",value:o?.map(n=>new Date(n,0,1)),onChange:n=>j(n.map(i=>i.getFullYear()).filter(i=>l!==i)),popoverProps:{withinPortal:!0},minDate:new Date(2010,0,1),maxDate:new Date})]})}),e.jsx(y,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>x(!0),children:e.jsx(g,{className:"size-5"})})]})}const b=()=>{const{year:l}=D(),{setFiltersContext:m}=h.useContext(P),[o,j]=h.useState(l?Number(l):new Date().getFullYear()),[c,x]=h.useState([]),[{data:n,fetching:i}]=w({query:C(F),variables:{reportYear:o,referenceYears:c}});h.useEffect(()=>{m(e.jsx("div",{className:"flex flex-row gap-2",children:e.jsx(A,{year:o,setYear:j,referenceYears:c,setReferenceYears:x})}))},[o,i,m,c,x]);const f=n?.profitAndLossReport,a=f?.report,s=f?.reference??[];return e.jsx(R,{title:"Profit and Loss Report",children:i?e.jsx(E,{className:"h-10 w-10 animate-spin mr-2 self-center"}):e.jsx("div",{className:"flex flex-col gap-4",children:a&&e.jsxs(v,{highlightOnHover:!0,fontSize:"md",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{}),e.jsx("th",{children:o},o),e.jsx("th",{}),s.map(t=>e.jsx("th",{children:t.year},t.year))]})}),e.jsxs("tbody",{children:[e.jsx(d,{dataRow:t=>e.jsxs("tr",{children:[e.jsx("th",{children:"Revenue"}),e.jsx("th",{children:a.revenue.amount.formatted}),e.jsx("th",{children:t}),s.map(r=>e.jsx("th",{children:r.revenue.amount.formatted},r.year))]}),commentaryData:a.revenue}),e.jsx(d,{dataRow:t=>e.jsxs("tr",{children:[e.jsx("td",{children:"Cost of Sales"}),e.jsx("td",{children:a.costOfSales.amount.formatted}),e.jsx("th",{children:t}),s.map(r=>e.jsx("td",{children:r.costOfSales.amount.formatted},r.year))]}),commentaryData:a.costOfSales}),e.jsxs("tr",{children:[e.jsx("th",{children:"Gross Profit"}),e.jsx("th",{children:a.grossProfit.formatted}),e.jsx("th",{}),s.map(t=>e.jsx("th",{children:t.grossProfit.formatted},t.year))]}),e.jsx(d,{dataRow:t=>e.jsxs("tr",{children:[e.jsx("td",{children:"R&D Expenses"}),e.jsx("td",{children:a.researchAndDevelopmentExpenses.amount.formatted}),e.jsx("th",{children:t}),s.map(r=>e.jsx("td",{children:r.researchAndDevelopmentExpenses.amount.formatted},r.year))]}),commentaryData:a.researchAndDevelopmentExpenses}),e.jsx(d,{dataRow:t=>e.jsxs("tr",{children:[e.jsx("td",{children:"Marketing Expenses"}),e.jsx("td",{children:a.marketingExpenses.amount.formatted}),e.jsx("th",{children:t}),s.map(r=>e.jsx("td",{children:r.marketingExpenses.amount.formatted},r.year))]}),commentaryData:a.marketingExpenses}),e.jsx(d,{dataRow:t=>e.jsxs("tr",{children:[e.jsx("td",{children:"Management and General Expenses"}),e.jsx("td",{children:a.managementAndGeneralExpenses.amount.formatted}),e.jsx("th",{children:t}),s.map(r=>e.jsx("td",{children:r.managementAndGeneralExpenses.amount.formatted},r.year))]}),commentaryData:a.managementAndGeneralExpenses}),e.jsxs("tr",{children:[e.jsx("th",{children:"Operating Profit"}),e.jsx("th",{children:a.operatingProfit.formatted}),e.jsx("th",{}),s.map(t=>e.jsx("th",{children:t.operatingProfit.formatted},t.year))]}),e.jsx(d,{dataRow:t=>e.jsxs("tr",{children:[e.jsx("td",{children:"Financial Expenses"}),e.jsx("td",{children:a.financialExpenses.amount.formatted}),e.jsx("th",{children:t}),s.map(r=>e.jsx("td",{children:r.financialExpenses.amount.formatted},r.year))]}),commentaryData:a.financialExpenses}),e.jsx(d,{dataRow:t=>e.jsxs("tr",{children:[e.jsx("td",{children:"Other Income"}),e.jsx("td",{children:a.otherIncome.amount.formatted}),e.jsx("th",{children:t}),s.map(r=>e.jsx("td",{children:r.otherIncome.amount.formatted},r.year))]}),commentaryData:a.otherIncome}),e.jsxs("tr",{children:[e.jsx("th",{children:"Profit Before Tax"}),e.jsx("th",{children:a.profitBeforeTax.formatted}),e.jsx("th",{}),s.map(t=>e.jsx("th",{children:t.profitBeforeTax.formatted},t.year))]}),e.jsxs("tr",{children:[e.jsx("td",{children:"Tax"}),e.jsx("td",{children:a.tax.formatted}),e.jsx("td",{}),s.map(t=>e.jsx("td",{children:t.tax.formatted},t.year))]})]}),e.jsx("tfoot",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Net Profit"}),e.jsx("th",{children:a.netProfit.formatted}),e.jsx("th",{}),s.map(t=>e.jsx("th",{children:t.netProfit.formatted},t.year))]})})]})})})};export{b as ProfitAndLossReport};
@@ -1 +1 @@
1
- import{i as k,k as M,r,t as j,l as A,a as N,m as F,j as e,n as T,o as z,B as v,p as C,q as D,u as y,s as P,v as L,F as $,w as O,T as R,P as q,b as U,c as _,L as Q,x as V,R as B,y as H,z as K}from"./index-DfI9E1Fb.js";import{B as G}from"./business-header-Cr5S_Mz7.js";import{C as J,M as W}from"./Checkbox-DjollWGm.js";import"./building-2-B92gXbOj.js";const X="mergeBusinesses",Y=()=>{const[{fetching:o},d]=k(M),u=r.useCallback(async l=>{const c=`Error merging into business ID [${l.targetBusinessId}]`,t=`${X}-${l.targetBusinessId}`;j.loading("Merging Businesses",{id:t});try{const a=await d(l),s=A(a,c,t);if(s)return j.success("Success",{id:t,description:"Businesses merged"}),s.mergeBusinesses.id}catch(a){console.error(`${c}: ${a}`),j.error("Error",{id:t,description:c,duration:1e5,closeButton:!0})}},[d]);return{fetching:o,mergeBusinesses:u}};function Z({businessIds:o,onDone:d,resetMerge:u}){const{mergeBusinesses:l,fetching:c}=Y(),t=Array.from(new Set(o)),[{data:a,fetching:s}]=N({query:F,variables:{businessIds:t}}),[m,f]=r.useState(a?.businesses[0]),n=a?.businesses.length!==t.length&&"Some businesses were not Found"||void 0,g=a?.businesses||[],h=r.useCallback(async()=>{if(!m){j.error("Error",{description:"No main business selected"});return}if(t.length<2){j.error("Error",{description:"At least 2 businesses are required to execute a merge"});return}return await l({targetBusinessId:m.id,businessIdsToMerge:t.filter(x=>x!==m.id)}),u(),d()},[m,t,l,d,u]);return e.jsxs(e.Fragment,{children:[s&&e.jsx("div",{className:"flex flex-col text-center w-full mb-1",children:e.jsx(T,{})}),!s&&n&&e.jsx("div",{className:"flex flex-col text-center w-full mb-1",children:e.jsx("h3",{className:"sm:text-2xl text-xl font-medium title-font mb-6 text-gray-900",children:n})}),!s&&!n&&e.jsxs(e.Fragment,{children:[e.jsxs("table",{children:[e.jsxs("tr",{children:[e.jsx("th",{children:"Main"}),g.map(x=>e.jsx("td",{children:e.jsx("div",{className:"flex items-center justify-center mx-2 px-2 py-2 border-2 border-b-0 rounded-t-xl",children:e.jsx(J,{checked:x.id===m?.id,size:"xl",onClick:()=>{f(x)}})})},x.id))]}),e.jsxs("tr",{children:[e.jsx("th",{children:"Name"}),g.map(x=>e.jsx("td",{children:x.name},x.id))]})]}),e.jsxs("div",{className:"flex justify-center gap-5 mt-5",children:[e.jsx("button",{type:"button",className:" text-white bg-blue-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-blue-600 rounded-sm text-lg",disabled:s||c,onClick:h,children:"Accept"}),e.jsx("button",{type:"button",className:" text-white bg-red-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-red-600 rounded-sm text-lg",onClick:d,children:"Cancel"}),e.jsx("button",{type:"button",className:" text-white bg-red-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-red-600 rounded-sm text-lg",onClick:()=>{u(),d()},children:"Reset Merge"})]})]})]})}function ee(o){const[d,{close:u,open:l}]=z(!1),{selected:c,resetMerge:t}=o,a=new Set(c.map(({id:g})=>g)),s=a.size>=1,[m,f]=r.useState(s?"default":"outline");r.useEffect(()=>{f(s?"default":"outline")},[s]);const n=r.useCallback(()=>{u(),c.map(({onChange:g})=>g())},[c,u]);return e.jsxs(e.Fragment,{children:[e.jsx(v,{onClick:()=>{s&&l()},disabled:!s,variant:m,className:C("size-7.5",s?" bg-blue-500 hover:bg-blue-500/90":""),size:"icon",children:e.jsx(W,{className:"size-5"})}),e.jsx(D,{opened:d,onClose:u,size:"auto",centered:!0,children:e.jsx(Z,{businessIds:Array.from(a),onDone:n,resetMerge:t})})]})}function se({activePage:o,setPage:d,totalPages:u=1,businessName:l,setBusinessName:c}){const{get:t,set:a}=y(),[s,m]=r.useState(l);r.useEffect(()=>{const n=o>1?o.toFixed(0):void 0,g=t("page");n!==g&&n!=="1"&&a("page",n)},[o,t,a]),r.useEffect(()=>{const n=setTimeout(()=>{c(s)},600);return()=>{clearTimeout(n)}},[s,c]);const f=n=>{m(n)};return e.jsxs("div",{className:"flex flex-row gap-5 items-center",children:[e.jsx(P,{className:"flex-auto",value:o,onChange:d,total:u}),e.jsx(L,{className:"w-72",placeholder:"Business Name",defaultValue:l??void 0,onChange:n=>f(n.target.value===""?void 0:n.target.value)})]})}const re=()=>{const{get:o}=y(),[d,u]=r.useState(!1),[l,c]=r.useState(o("page")?Number(o("page")):1),[t,a]=r.useState(o("name")?o("page"):void 0),{setFiltersContext:s}=r.useContext($),[{data:m,fetching:f},n]=N({query:K,variables:{page:l,limit:100,name:t}}),g=O(),[h,x]=r.useState([]),I=r.useCallback((i,p)=>{h.map(b=>b.id).includes(i)?x(h.filter(b=>b.id!==i)):x([...h,{id:i,onChange:p}])},[h]);function S(){x([])}r.useEffect(()=>{s(e.jsxs("div",{className:"flex flex-row gap-x-5",children:[e.jsx(se,{activePage:l,setPage:c,businessName:t,setBusinessName:a,totalPages:m?.allBusinesses?.pageInfo.totalPages}),e.jsx(R,{label:"Expand all businesses",children:e.jsx(v,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>u(i=>!i),children:d?e.jsx(q,{className:"size-5"}):e.jsx(U,{className:"size-5"})})}),e.jsx(ee,{selected:h,resetMerge:S})]}))},[m,l,t,d,s,c,a,u,h]);const w=m?.allBusinesses?.nodes.filter(i=>i.__typename==="LtdFinancialEntity").sort((i,p)=>i.name.toLowerCase()>p.name.toLowerCase()?1:-1)??[],E=new Set(h.map(i=>i.id));return e.jsx(_,{title:`Businesses (${m?.allBusinesses?.pageInfo.totalRecords??""})`,description:"All businesses",headerActions:e.jsx("div",{className:"flex items-center py-4 gap-4",children:e.jsx(H,{description:"",onAdd:()=>n()})}),children:f?e.jsx("div",{className:"flex flex-row justify-center",children:e.jsx(Q,{className:C("h-10 w-10 animate-spin mr-2")})}):e.jsx("div",{className:"space-y-2",children:w.map(i=>e.jsx("div",{className:"group relative border rounded-lg hover:shadow-md transition-shadow",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"pl-4 flex items-center",children:e.jsx(V,{checked:E.has(i.id),onCheckedChange:()=>{I(i.id,()=>{})},className:"h-4 w-4 rounded border-gray-300 cursor-pointer",onClick:p=>p.stopPropagation()})}),e.jsx("div",{role:"button",tabIndex:0,className:"flex-1 cursor-pointer",onClick:()=>{g(B.BUSINESSES.DETAIL(i.id))},onKeyDown:p=>{(p.key==="Enter"||p.key===" ")&&(p.preventDefault(),g(B.BUSINESSES.DETAIL(i.id)))},children:e.jsx(G,{data:i})})]})},i.id))})})};export{re as Businesses};
1
+ import{i as k,k as M,r,t as j,l as A,a as N,m as F,j as e,n as T,o as z,B as v,p as C,q as D,u as y,s as P,v as L,F as $,w as O,T as R,P as q,b as U,c as _,L as Q,x as V,R as B,y as H,z as K}from"./index-B9S5s-Ek.js";import{B as G}from"./business-header-BdKqniFy.js";import{C as J,M as W}from"./Checkbox-StVWX8SV.js";import"./building-2-ClFm6mRd.js";const X="mergeBusinesses",Y=()=>{const[{fetching:o},d]=k(M),u=r.useCallback(async l=>{const c=`Error merging into business ID [${l.targetBusinessId}]`,t=`${X}-${l.targetBusinessId}`;j.loading("Merging Businesses",{id:t});try{const a=await d(l),s=A(a,c,t);if(s)return j.success("Success",{id:t,description:"Businesses merged"}),s.mergeBusinesses.id}catch(a){console.error(`${c}: ${a}`),j.error("Error",{id:t,description:c,duration:1e5,closeButton:!0})}},[d]);return{fetching:o,mergeBusinesses:u}};function Z({businessIds:o,onDone:d,resetMerge:u}){const{mergeBusinesses:l,fetching:c}=Y(),t=Array.from(new Set(o)),[{data:a,fetching:s}]=N({query:F,variables:{businessIds:t}}),[m,f]=r.useState(a?.businesses[0]),n=a?.businesses.length!==t.length&&"Some businesses were not Found"||void 0,g=a?.businesses||[],h=r.useCallback(async()=>{if(!m){j.error("Error",{description:"No main business selected"});return}if(t.length<2){j.error("Error",{description:"At least 2 businesses are required to execute a merge"});return}return await l({targetBusinessId:m.id,businessIdsToMerge:t.filter(x=>x!==m.id)}),u(),d()},[m,t,l,d,u]);return e.jsxs(e.Fragment,{children:[s&&e.jsx("div",{className:"flex flex-col text-center w-full mb-1",children:e.jsx(T,{})}),!s&&n&&e.jsx("div",{className:"flex flex-col text-center w-full mb-1",children:e.jsx("h3",{className:"sm:text-2xl text-xl font-medium title-font mb-6 text-gray-900",children:n})}),!s&&!n&&e.jsxs(e.Fragment,{children:[e.jsxs("table",{children:[e.jsxs("tr",{children:[e.jsx("th",{children:"Main"}),g.map(x=>e.jsx("td",{children:e.jsx("div",{className:"flex items-center justify-center mx-2 px-2 py-2 border-2 border-b-0 rounded-t-xl",children:e.jsx(J,{checked:x.id===m?.id,size:"xl",onClick:()=>{f(x)}})})},x.id))]}),e.jsxs("tr",{children:[e.jsx("th",{children:"Name"}),g.map(x=>e.jsx("td",{children:x.name},x.id))]})]}),e.jsxs("div",{className:"flex justify-center gap-5 mt-5",children:[e.jsx("button",{type:"button",className:" text-white bg-blue-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-blue-600 rounded-sm text-lg",disabled:s||c,onClick:h,children:"Accept"}),e.jsx("button",{type:"button",className:" text-white bg-red-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-red-600 rounded-sm text-lg",onClick:d,children:"Cancel"}),e.jsx("button",{type:"button",className:" text-white bg-red-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-red-600 rounded-sm text-lg",onClick:()=>{u(),d()},children:"Reset Merge"})]})]})]})}function ee(o){const[d,{close:u,open:l}]=z(!1),{selected:c,resetMerge:t}=o,a=new Set(c.map(({id:g})=>g)),s=a.size>=1,[m,f]=r.useState(s?"default":"outline");r.useEffect(()=>{f(s?"default":"outline")},[s]);const n=r.useCallback(()=>{u(),c.map(({onChange:g})=>g())},[c,u]);return e.jsxs(e.Fragment,{children:[e.jsx(v,{onClick:()=>{s&&l()},disabled:!s,variant:m,className:C("size-7.5",s?" bg-blue-500 hover:bg-blue-500/90":""),size:"icon",children:e.jsx(W,{className:"size-5"})}),e.jsx(D,{opened:d,onClose:u,size:"auto",centered:!0,children:e.jsx(Z,{businessIds:Array.from(a),onDone:n,resetMerge:t})})]})}function se({activePage:o,setPage:d,totalPages:u=1,businessName:l,setBusinessName:c}){const{get:t,set:a}=y(),[s,m]=r.useState(l);r.useEffect(()=>{const n=o>1?o.toFixed(0):void 0,g=t("page");n!==g&&n!=="1"&&a("page",n)},[o,t,a]),r.useEffect(()=>{const n=setTimeout(()=>{c(s)},600);return()=>{clearTimeout(n)}},[s,c]);const f=n=>{m(n)};return e.jsxs("div",{className:"flex flex-row gap-5 items-center",children:[e.jsx(P,{className:"flex-auto",value:o,onChange:d,total:u}),e.jsx(L,{className:"w-72",placeholder:"Business Name",defaultValue:l??void 0,onChange:n=>f(n.target.value===""?void 0:n.target.value)})]})}const re=()=>{const{get:o}=y(),[d,u]=r.useState(!1),[l,c]=r.useState(o("page")?Number(o("page")):1),[t,a]=r.useState(o("name")?o("page"):void 0),{setFiltersContext:s}=r.useContext($),[{data:m,fetching:f},n]=N({query:K,variables:{page:l,limit:100,name:t}}),g=O(),[h,x]=r.useState([]),I=r.useCallback((i,p)=>{h.map(b=>b.id).includes(i)?x(h.filter(b=>b.id!==i)):x([...h,{id:i,onChange:p}])},[h]);function S(){x([])}r.useEffect(()=>{s(e.jsxs("div",{className:"flex flex-row gap-x-5",children:[e.jsx(se,{activePage:l,setPage:c,businessName:t,setBusinessName:a,totalPages:m?.allBusinesses?.pageInfo.totalPages}),e.jsx(R,{label:"Expand all businesses",children:e.jsx(v,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>u(i=>!i),children:d?e.jsx(q,{className:"size-5"}):e.jsx(U,{className:"size-5"})})}),e.jsx(ee,{selected:h,resetMerge:S})]}))},[m,l,t,d,s,c,a,u,h]);const w=m?.allBusinesses?.nodes.filter(i=>i.__typename==="LtdFinancialEntity").sort((i,p)=>i.name.toLowerCase()>p.name.toLowerCase()?1:-1)??[],E=new Set(h.map(i=>i.id));return e.jsx(_,{title:`Businesses (${m?.allBusinesses?.pageInfo.totalRecords??""})`,description:"All businesses",headerActions:e.jsx("div",{className:"flex items-center py-4 gap-4",children:e.jsx(H,{description:"",onAdd:()=>n()})}),children:f?e.jsx("div",{className:"flex flex-row justify-center",children:e.jsx(Q,{className:C("h-10 w-10 animate-spin mr-2")})}):e.jsx("div",{className:"space-y-2",children:w.map(i=>e.jsx("div",{className:"group relative border rounded-lg hover:shadow-md transition-shadow",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"pl-4 flex items-center",children:e.jsx(V,{checked:E.has(i.id),onCheckedChange:()=>{I(i.id,()=>{})},className:"h-4 w-4 rounded border-gray-300 cursor-pointer",onClick:p=>p.stopPropagation()})}),e.jsx("div",{role:"button",tabIndex:0,className:"flex-1 cursor-pointer",onClick:()=>{g(B.BUSINESSES.DETAIL(i.id))},onKeyDown:p=>{(p.key==="Enter"||p.key===" ")&&(p.preventDefault(),g(B.BUSINESSES.DETAIL(i.id)))},children:e.jsx(G,{data:i})})]})},i.id))})})};export{re as Businesses};
@@ -1,4 +1,4 @@
1
- import{cY as fr,ai as gr,ah as ge,j as F,r as kt,u as io,cZ as pr,c_ as mr,B as br,c$ as xr,V as _r,H as le,bO as Pn,bT as Dn,bU as An,d0 as yr,F as wr,a as vr,d1 as Mr,b1 as it,c as Sr,L as kr,d2 as Cr}from"./index-DfI9E1Fb.js";/*!
1
+ import{cY as fr,ai as gr,ah as ge,j as F,r as kt,u as io,cZ as pr,c_ as mr,B as br,c$ as xr,V as _r,H as le,bO as Pn,bT as Dn,bU as An,d0 as yr,F as wr,a as vr,d1 as Mr,b1 as it,c as Sr,L as kr,d2 as Cr}from"./index-B9S5s-Ek.js";/*!
2
2
  * decimal.js v10.6.0
3
3
  * An arbitrary-precision Decimal type for JavaScript.
4
4
  * https://github.com/MikeMcl/decimal.js
@@ -1 +1 @@
1
- import{i as v,fX as U,r as u,t as m,l as F,aK as H,j as e,a2 as C,a3 as j,a4 as f,a5 as p,v as L,a6 as y,a7 as S,bO as K,bP as V,aO as z,aI as _,K as D,an as E,B as h,N as M,ap as A,aq as R,V as O,a0 as k,fY as G,c7 as Q,a as P,fZ as X,L as $,F as Y,dj as Z,c as J,dm as W,dn as ee,dp as T,dq as se,dr as b,ds as te,dt as w,f_ as ae,dz as re,dA as oe,dB as ne}from"./index-DfI9E1Fb.js";import{D as ie}from"./data-table-pagination-CN5CnGZV.js";import{A as N}from"./arrow-up-down-J-i_WnHP.js";const de="insertTaxCategory",ce=()=>{const[{fetching:s},n]=v(U),t=u.useCallback(async a=>{const d="Error creating tax category",r=de;m.loading("Adding Tax Category",{id:r});try{const i=await n(a),l=F(i,d,r);if(l)return m.success("Success",{id:r,description:`${l.insertTaxCategory.name} was created`}),l.insertTaxCategory}catch(i){console.error(`${d}: ${i}`),m.error("Error",{id:r,description:d,duration:1e5,closeButton:!0})}},[n]);return{fetching:s,insertTaxCategory:t}};function q({formManager:s,setFetching:n,isInsert:t}){const{control:a,watch:d,setValue:r}=s,{selectableSortCodes:i,fetching:l,sortCodes:x}=H();u.useEffect(()=>{n(l)},[n,l]);const c=d("sortCode");return u.useEffect(()=>{if(c){const o=x.find(g=>g.key===c);o?.defaultIrsCode&&r("irsCode",o.defaultIrsCode,{shouldDirty:!0})}},[c,x,r]),e.jsxs(e.Fragment,{children:[e.jsx(C,{name:"name",control:a,rules:{required:"Required",minLength:{value:2,message:"Must be at least 2 characters"}},render:({field:o,fieldState:g})=>e.jsxs(j,{children:[e.jsx(f,{children:"Name"}),e.jsx(p,{children:e.jsx(L,{...o,value:o.value??void 0,required:!0,className:t?"":y(g)})}),e.jsx(S,{})]})}),e.jsx(K,{name:"sortCode",control:a,render:({field:o,fieldState:g})=>e.jsx(V,{...o,onChange:B=>{o.onChange(Number(B))},data:i,value:o.value?.toString(),disabled:l,label:"Sort Code",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,className:t?"":y(g)})}),e.jsx(C,{name:"irsCode",control:a,render:({field:o,fieldState:g})=>e.jsxs(j,{children:[e.jsx(f,{children:"IRS Code"}),e.jsx(p,{children:e.jsx(z,{...o,className:t?"":y(g),value:o.value??void 0,hideControls:!0,decimalScale:0})}),e.jsx(S,{})]})}),e.jsx(C,{control:a,name:"taxExcluded",render:({field:o})=>e.jsxs(j,{className:"flex flex-row items-center justify-between",children:[e.jsx("div",{className:"space-y-0.5",children:e.jsx(f,{children:"Tax excluded category"})}),e.jsx(p,{children:e.jsx(_,{onCheckedChange:o.onChange,checked:o.value??void 0})})]})})]})}function le({onAdd:s}){const[n,t]=u.useState(!1);return e.jsxs(D,{open:n,onOpenChange:t,children:[e.jsx(E,{asChild:!0,children:e.jsx(h,{children:"Add Tax Category"})}),e.jsxs(M,{className:"w-[90vw] max-w-screen-md",children:[e.jsx(A,{children:e.jsx(R,{children:"Add New Tax Category"})}),e.jsx(xe,{close:()=>t(!1),onAdd:s})]})]})}function xe({close:s,onAdd:n}){const t=O({}),{handleSubmit:a}=t,[d,r]=u.useState(!1),{insertTaxCategory:i,fetching:l}=ce(),x=c=>{c.sortCode&&=parseInt(c.sortCode.toString()),i({fields:c}).then(o=>{o?.id&&(n?.(o.id),s())})};return e.jsx(k,{...t,children:e.jsxs("form",{onSubmit:a(x),children:[e.jsx("div",{className:"flex flex-col gap-4 my-4",children:e.jsx(q,{isInsert:!0,formManager:t,setFetching:r})}),e.jsx("div",{className:"flex justify-end mt-4",children:e.jsx(h,{type:"submit",disabled:l||d,children:"Add Tax Category"})})]})})}const ue="updateTaxCategory",ge=()=>{const[{fetching:s},n]=v(G),t=u.useCallback(async a=>{const d="Error updating tax category",r=`${ue}-${a.taxCategoryId}`;m.loading("Uploading Tax Category",{id:r});try{const i=await n(a),l=F(i,d,r,"updateTaxCategory");if(l)return m.success("Success",{id:r,description:`${l.updateTaxCategory.name} was updated`}),l.updateTaxCategory}catch(i){console.error(`${d}: ${i}`),m.error("Error",{id:r,description:d,duration:1e5,closeButton:!0})}},[n]);return{fetching:s,updateTaxCategory:t}};function me({taxCategoryId:s,onAdd:n}){const[t,a]=u.useState(!1);return e.jsxs(D,{open:t,onOpenChange:a,children:[e.jsx(E,{asChild:!0,children:e.jsx(h,{variant:"outline",size:"icon",children:e.jsx(Q,{})})}),e.jsxs(M,{className:"w-[400px] max-w-screen-md",children:[e.jsx(A,{children:e.jsx(R,{children:"Edit Tax Category"})}),e.jsx(he,{taxCategoryId:s,close:()=>a(!1),onAdd:n})]})]})}function he({taxCategoryId:s,close:n,onAdd:t}){const[{data:a,fetching:d}]=P({query:X,variables:{id:s}}),r=a?.taxCategory;return!r&&!d&&m.error("Error",{description:"Couldn'nt find tax category"}),d?e.jsx($,{className:"h-10 w-10 animate-spin"}):e.jsx(Ce,{taxCategory:r,close:n,onAdd:t})}function Ce({taxCategory:s,close:n,onAdd:t}){const a=O({defaultValues:{sortCode:s.sortCode?.key,name:s.name,irsCode:s.irsCode}}),{handleSubmit:d}=a,[r,i]=u.useState(!1),{updateTaxCategory:l,fetching:x}=ge(),c=o=>{o.sortCode&&=parseInt(o.sortCode.toString()),l({fields:o,taxCategoryId:s.id}).then(g=>{g?.id&&(t?.(g.id),n())})};return e.jsx(k,{...a,children:e.jsxs("form",{onSubmit:d(c),children:[e.jsx("div",{className:"flex flex-col gap-4 my-4",children:e.jsx(q,{isInsert:!1,formManager:a,setFetching:i})}),e.jsx("div",{className:"flex justify-end mt-4",children:e.jsx(h,{type:"submit",disabled:x||r,children:"Update"})})]})})}const je=({data:s})=>e.jsx("td",{children:s.name}),fe=({data:s})=>e.jsx("td",{children:s.sortCode?e.jsxs("span",{children:[s.sortCode?.name," (",s.sortCode?.id,")"]}):"N/A"}),I=[{id:"name",accessorKey:"name",cell:({row:s})=>e.jsx(je,{data:s.original}),header:({column:s})=>e.jsxs(h,{variant:"ghost",onClick:()=>s.toggleSorting(s.getIsSorted()==="asc"),children:["Name",e.jsx(N,{})]})},{id:"sortCode",accessorKey:"sortCode.key",cell:({row:s})=>e.jsx(fe,{data:s.original}),header:({column:s})=>e.jsxs(h,{variant:"ghost",onClick:()=>s.toggleSorting(s.getIsSorted()==="asc"),children:["Sort Code",e.jsx(N,{})]})},{id:"edit",cell:({row:s})=>e.jsx(me,{taxCategoryId:s.original.id})}],Se=()=>{const[{data:s,fetching:n,error:t},a]=P({query:ae}),{setFiltersContext:d}=u.useContext(Y),r=s?.taxCategories??[],i=Z({data:r,columns:I,getCoreRowModel:ne(),getPaginationRowModel:oe(),getSortedRowModel:re(),initialState:{pagination:{pageSize:30}}}),l=i.getPageOptions();return u.useEffect(()=>{d(e.jsx("div",{className:"flex items-center justify-end gap-10 space-x-2 py-4",children:e.jsx("div",{className:"flex items-center justify-between px-2",children:e.jsx(ie,{table:i})})}))},[d,i,l]),u.useEffect(()=>{t&&m.error("Error",{description:"Error fetching tax categories"})},[t]),e.jsx(J,{title:`Tax Categories (${r.length})`,description:"All tax categories",headerActions:e.jsx(le,{onAdd:()=>a()}),children:n?e.jsx("div",{className:"flex flex-row justify-center",children:e.jsx($,{className:"h-10 w-10 animate-spin mr-2"})}):e.jsx("div",{className:"flex flex-col gap-4 rounded-md border",children:e.jsxs(W,{children:[e.jsx(ee,{children:i.getHeaderGroups().map(x=>e.jsx(T,{children:x.headers.map(c=>e.jsx(se,{children:c.isPlaceholder?null:b(c.column.columnDef.header,c.getContext())},c.id))},x.id))}),e.jsx(te,{children:i.getRowModel().rows.length===0?e.jsx(T,{children:e.jsx(w,{colSpan:I.length,className:"text-center py-8",children:"No tax categories found"})}):i.getRowModel().rows.map(x=>e.jsx(T,{children:x.getVisibleCells().map(c=>e.jsx(w,{children:b(c.column.columnDef.cell,c.getContext())},c.id))},x.id))})]})})})};export{Se as TaxCategories};
1
+ import{i as v,fX as U,r as u,t as m,l as F,aK as H,j as e,a2 as C,a3 as j,a4 as f,a5 as p,v as L,a6 as y,a7 as S,bO as K,bP as V,aO as z,aI as _,K as D,an as E,B as h,N as M,ap as A,aq as R,V as O,a0 as k,fY as G,c7 as Q,a as P,fZ as X,L as $,F as Y,dj as Z,c as J,dm as W,dn as ee,dp as T,dq as se,dr as b,ds as te,dt as w,f_ as ae,dz as re,dA as oe,dB as ne}from"./index-B9S5s-Ek.js";import{D as ie}from"./data-table-pagination-BxG_nDcy.js";import{A as N}from"./arrow-up-down-Dc_JXNej.js";const de="insertTaxCategory",ce=()=>{const[{fetching:s},n]=v(U),t=u.useCallback(async a=>{const d="Error creating tax category",r=de;m.loading("Adding Tax Category",{id:r});try{const i=await n(a),l=F(i,d,r);if(l)return m.success("Success",{id:r,description:`${l.insertTaxCategory.name} was created`}),l.insertTaxCategory}catch(i){console.error(`${d}: ${i}`),m.error("Error",{id:r,description:d,duration:1e5,closeButton:!0})}},[n]);return{fetching:s,insertTaxCategory:t}};function q({formManager:s,setFetching:n,isInsert:t}){const{control:a,watch:d,setValue:r}=s,{selectableSortCodes:i,fetching:l,sortCodes:x}=H();u.useEffect(()=>{n(l)},[n,l]);const c=d("sortCode");return u.useEffect(()=>{if(c){const o=x.find(g=>g.key===c);o?.defaultIrsCode&&r("irsCode",o.defaultIrsCode,{shouldDirty:!0})}},[c,x,r]),e.jsxs(e.Fragment,{children:[e.jsx(C,{name:"name",control:a,rules:{required:"Required",minLength:{value:2,message:"Must be at least 2 characters"}},render:({field:o,fieldState:g})=>e.jsxs(j,{children:[e.jsx(f,{children:"Name"}),e.jsx(p,{children:e.jsx(L,{...o,value:o.value??void 0,required:!0,className:t?"":y(g)})}),e.jsx(S,{})]})}),e.jsx(K,{name:"sortCode",control:a,render:({field:o,fieldState:g})=>e.jsx(V,{...o,onChange:B=>{o.onChange(Number(B))},data:i,value:o.value?.toString(),disabled:l,label:"Sort Code",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,className:t?"":y(g)})}),e.jsx(C,{name:"irsCode",control:a,render:({field:o,fieldState:g})=>e.jsxs(j,{children:[e.jsx(f,{children:"IRS Code"}),e.jsx(p,{children:e.jsx(z,{...o,className:t?"":y(g),value:o.value??void 0,hideControls:!0,decimalScale:0})}),e.jsx(S,{})]})}),e.jsx(C,{control:a,name:"taxExcluded",render:({field:o})=>e.jsxs(j,{className:"flex flex-row items-center justify-between",children:[e.jsx("div",{className:"space-y-0.5",children:e.jsx(f,{children:"Tax excluded category"})}),e.jsx(p,{children:e.jsx(_,{onCheckedChange:o.onChange,checked:o.value??void 0})})]})})]})}function le({onAdd:s}){const[n,t]=u.useState(!1);return e.jsxs(D,{open:n,onOpenChange:t,children:[e.jsx(E,{asChild:!0,children:e.jsx(h,{children:"Add Tax Category"})}),e.jsxs(M,{className:"w-[90vw] max-w-screen-md",children:[e.jsx(A,{children:e.jsx(R,{children:"Add New Tax Category"})}),e.jsx(xe,{close:()=>t(!1),onAdd:s})]})]})}function xe({close:s,onAdd:n}){const t=O({}),{handleSubmit:a}=t,[d,r]=u.useState(!1),{insertTaxCategory:i,fetching:l}=ce(),x=c=>{c.sortCode&&=parseInt(c.sortCode.toString()),i({fields:c}).then(o=>{o?.id&&(n?.(o.id),s())})};return e.jsx(k,{...t,children:e.jsxs("form",{onSubmit:a(x),children:[e.jsx("div",{className:"flex flex-col gap-4 my-4",children:e.jsx(q,{isInsert:!0,formManager:t,setFetching:r})}),e.jsx("div",{className:"flex justify-end mt-4",children:e.jsx(h,{type:"submit",disabled:l||d,children:"Add Tax Category"})})]})})}const ue="updateTaxCategory",ge=()=>{const[{fetching:s},n]=v(G),t=u.useCallback(async a=>{const d="Error updating tax category",r=`${ue}-${a.taxCategoryId}`;m.loading("Uploading Tax Category",{id:r});try{const i=await n(a),l=F(i,d,r,"updateTaxCategory");if(l)return m.success("Success",{id:r,description:`${l.updateTaxCategory.name} was updated`}),l.updateTaxCategory}catch(i){console.error(`${d}: ${i}`),m.error("Error",{id:r,description:d,duration:1e5,closeButton:!0})}},[n]);return{fetching:s,updateTaxCategory:t}};function me({taxCategoryId:s,onAdd:n}){const[t,a]=u.useState(!1);return e.jsxs(D,{open:t,onOpenChange:a,children:[e.jsx(E,{asChild:!0,children:e.jsx(h,{variant:"outline",size:"icon",children:e.jsx(Q,{})})}),e.jsxs(M,{className:"w-[400px] max-w-screen-md",children:[e.jsx(A,{children:e.jsx(R,{children:"Edit Tax Category"})}),e.jsx(he,{taxCategoryId:s,close:()=>a(!1),onAdd:n})]})]})}function he({taxCategoryId:s,close:n,onAdd:t}){const[{data:a,fetching:d}]=P({query:X,variables:{id:s}}),r=a?.taxCategory;return!r&&!d&&m.error("Error",{description:"Couldn'nt find tax category"}),d?e.jsx($,{className:"h-10 w-10 animate-spin"}):e.jsx(Ce,{taxCategory:r,close:n,onAdd:t})}function Ce({taxCategory:s,close:n,onAdd:t}){const a=O({defaultValues:{sortCode:s.sortCode?.key,name:s.name,irsCode:s.irsCode}}),{handleSubmit:d}=a,[r,i]=u.useState(!1),{updateTaxCategory:l,fetching:x}=ge(),c=o=>{o.sortCode&&=parseInt(o.sortCode.toString()),l({fields:o,taxCategoryId:s.id}).then(g=>{g?.id&&(t?.(g.id),n())})};return e.jsx(k,{...a,children:e.jsxs("form",{onSubmit:d(c),children:[e.jsx("div",{className:"flex flex-col gap-4 my-4",children:e.jsx(q,{isInsert:!1,formManager:a,setFetching:i})}),e.jsx("div",{className:"flex justify-end mt-4",children:e.jsx(h,{type:"submit",disabled:x||r,children:"Update"})})]})})}const je=({data:s})=>e.jsx("td",{children:s.name}),fe=({data:s})=>e.jsx("td",{children:s.sortCode?e.jsxs("span",{children:[s.sortCode?.name," (",s.sortCode?.id,")"]}):"N/A"}),I=[{id:"name",accessorKey:"name",cell:({row:s})=>e.jsx(je,{data:s.original}),header:({column:s})=>e.jsxs(h,{variant:"ghost",onClick:()=>s.toggleSorting(s.getIsSorted()==="asc"),children:["Name",e.jsx(N,{})]})},{id:"sortCode",accessorKey:"sortCode.key",cell:({row:s})=>e.jsx(fe,{data:s.original}),header:({column:s})=>e.jsxs(h,{variant:"ghost",onClick:()=>s.toggleSorting(s.getIsSorted()==="asc"),children:["Sort Code",e.jsx(N,{})]})},{id:"edit",cell:({row:s})=>e.jsx(me,{taxCategoryId:s.original.id})}],Se=()=>{const[{data:s,fetching:n,error:t},a]=P({query:ae}),{setFiltersContext:d}=u.useContext(Y),r=s?.taxCategories??[],i=Z({data:r,columns:I,getCoreRowModel:ne(),getPaginationRowModel:oe(),getSortedRowModel:re(),initialState:{pagination:{pageSize:30}}}),l=i.getPageOptions();return u.useEffect(()=>{d(e.jsx("div",{className:"flex items-center justify-end gap-10 space-x-2 py-4",children:e.jsx("div",{className:"flex items-center justify-between px-2",children:e.jsx(ie,{table:i})})}))},[d,i,l]),u.useEffect(()=>{t&&m.error("Error",{description:"Error fetching tax categories"})},[t]),e.jsx(J,{title:`Tax Categories (${r.length})`,description:"All tax categories",headerActions:e.jsx(le,{onAdd:()=>a()}),children:n?e.jsx("div",{className:"flex flex-row justify-center",children:e.jsx($,{className:"h-10 w-10 animate-spin mr-2"})}):e.jsx("div",{className:"flex flex-col gap-4 rounded-md border",children:e.jsxs(W,{children:[e.jsx(ee,{children:i.getHeaderGroups().map(x=>e.jsx(T,{children:x.headers.map(c=>e.jsx(se,{children:c.isPlaceholder?null:b(c.column.columnDef.header,c.getContext())},c.id))},x.id))}),e.jsx(te,{children:i.getRowModel().rows.length===0?e.jsx(T,{children:e.jsx(w,{colSpan:I.length,className:"text-center py-8",children:"No tax categories found"})}):i.getRowModel().rows.map(x=>e.jsx(T,{children:x.getVisibleCells().map(c=>e.jsx(w,{children:b(c.column.columnDef.cell,c.getContext())},c.id))},x.id))})]})})})};export{Se as TaxCategories};
@@ -1,10 +1,10 @@
1
- import{D as V,i as q,eB as E,r,t as k,l as F,a as $,eC as _,j as s,n as L,eD as R,o as H,B as Q,p as X,q as G}from"./index-DfI9E1Fb.js";import{C as J,M as K}from"./Checkbox-DjollWGm.js";/**
2
- * @license lucide-react v0.546.0 - ISC
1
+ import{D as V,i as q,eB as E,r,t as k,l as F,a as $,eC as _,j as s,n as L,eD as R,o as H,B as Q,p as X,q as G}from"./index-B9S5s-Ek.js";import{C as J,M as K}from"./Checkbox-StVWX8SV.js";/**
2
+ * @license lucide-react v0.548.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
5
5
  * See the LICENSE file in the root directory of this source tree.
6
6
  */const U=[["path",{d:"M21 10.656V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h12.344",key:"2acyp4"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],g=V("square-check-big",U);/**
7
- * @license lucide-react v0.546.0 - ISC
7
+ * @license lucide-react v0.548.0 - ISC
8
8
  *
9
9
  * This source code is licensed under the ISC license.
10
10
  * See the LICENSE file in the root directory of this source tree.
@@ -1 +1 @@
1
- import{r as l,cZ as w,u as P,d0 as O,j as e,c_ as V,bz as U,B as c,c$ as z,ae as K,V as _,H as b,dh as B,a0 as H,di as L,bO as D,ch as M,bT as I,bU as T,a2 as q,a3 as G,a4 as J,a5 as Q,aI as X,bu as Z,F as $,a as W,dj as Y,c as ee,L as te,dk as se,dl as ae,dm as ne,dn as le,dp as S,dq as re,dr as k,ds as ie,dt as R,du as oe,dv as ce,dw as de,dx as me,dy as ue,dz as ge,dA as he,dB as xe}from"./index-DfI9E1Fb.js";import{D as je}from"./data-table-pagination-CN5CnGZV.js";import{s as pe}from"./sub-BbpGm1pj.js";import{A as v}from"./arrow-up-down-J-i_WnHP.js";import"./subMonths-0tIJizDp.js";function fe({filter:t,setFilter:s,closeModal:x}){const{userContext:j}=l.useContext(K),h=_({defaultValues:{ownerIDs:j?.context.adminBusinessId?[j.context.adminBusinessId]:void 0,toDate:b(new Date,"yyyy-MM-dd"),fromDate:b(pe(new Date,{years:1}),"yyyy-MM-dd"),...t}}),{control:o,handleSubmit:y}=h,{selectableFinancialEntities:r,fetching:d}=B(),C=a=>{s(a),x()};function m(){s({}),x()}return e.jsxs(e.Fragment,{children:[d?e.jsx("div",{children:"Loading..."}):e.jsx("div",{}),e.jsx(H,{...h,children:e.jsxs("form",{onSubmit:y(C),children:[e.jsxs(L,{cols:2,children:[e.jsx(D,{name:"ownerIDs",control:o,defaultValue:t.ownerIDs,render:({field:a,fieldState:g})=>e.jsx(M,{...a,data:r,value:a.value??[],disabled:d,label:"Owners",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:g.error?.message,withinPortal:!0})}),e.jsx(D,{name:"businessIDs",control:o,defaultValue:t.businessIDs,render:({field:a,fieldState:g})=>e.jsx(M,{...a,data:r,value:a.value??[],disabled:d,label:"Financial Entities",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:g.error?.message,withinPortal:!0})}),e.jsx(D,{name:"fromDate",control:o,defaultValue:t.fromDate,rules:{pattern:{value:I,message:"Date must be im format yyyy-mm-dd"}},render:({field:a,fieldState:g})=>e.jsx(T,{...a,onChange:i=>{const p=i?typeof i=="string"?i:b(i,"yyyy-MM-dd"):void 0;p!==a.value&&a.onChange(p)},value:a.value?new Date(a.value):void 0,error:g.error?.message,label:"From Date",popoverProps:{withinPortal:!0}})}),e.jsx(D,{name:"toDate",control:o,defaultValue:t.toDate,rules:{pattern:{value:I,message:"Date must be im format yyyy-mm-dd"}},render:({field:a,fieldState:g})=>e.jsx(T,{...a,onChange:i=>{const p=i?typeof i=="string"?i:b(i,"yyyy-MM-dd"):void 0;p!==a.value&&a.onChange(p)},value:a.value?new Date(a.value):void 0,error:g.error?.message,label:"To Date",popoverProps:{withinPortal:!0}})}),e.jsx(q,{name:"unmatched",control:o,render:({field:a})=>e.jsxs(G,{className:"flex flex-row items-center justify-between rounded-lg border p-3 shadow-sm",children:[e.jsx("div",{className:"space-y-0.5",children:e.jsx(J,{children:"Unmatched only"})}),e.jsx(Q,{children:e.jsx(X,{defaultChecked:t.unmatched??!1,onCheckedChange:a.onChange})})]})})]}),e.jsxs("div",{className:"flex justify-center mt-5 gap-3",children:[e.jsx("button",{type:"submit",disabled:d,className:"text-white bg-indigo-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-indigo-600 rounded-sm text-lg",children:"Filter"}),e.jsx("button",{type:"button",className:"text-white bg-orange-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-orange-600 rounded-sm text-lg",onClick:m,children:"Clear"}),e.jsx("button",{type:"button",className:"text-white bg-rose-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-rose-600 rounded-sm text-lg",onClick:x,children:"Cancel"})]})]})})]})}function ve({filter:t={},setFilter:s,initiallyOpened:x=!1}){const[j,h]=l.useState(x),[o,y]=l.useState(!w(t)),{get:r,set:d}=P();l.useEffect(()=>{const m=w(t)?null:encodeURIComponent(JSON.stringify(t)),a=r("documentsFilters");m!==a&&d("documentsFilters",m)},[t,r,d]);const C=l.useCallback(m=>{O(m,t)||(s(m),y(!w(m)))},[t,s]);return e.jsxs("div",{className:"flex flex-row gap-5 items-center",children:[e.jsx(V,{opened:j,onClose:()=>h(!1),content:e.jsx(fe,{filter:t,setFilter:C,closeModal:()=>h(!1)}),modalSize:"xl"}),e.jsx(U,{inline:!0,size:16,disabled:!o,children:e.jsx(c,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>h(!0),children:e.jsx(z,{className:"size-5"})})})]})}const E=[{accessorKey:"__typename",header:({column:t})=>e.jsxs(c,{variant:"ghost",onClick:()=>t.toggleSorting(t.getIsSorted()==="asc"),children:[e.jsx("div",{className:"text-left",children:"Type"}),e.jsx(v,{className:"ml-2 h-4 w-4"})]}),cell:({row:t})=>{const{__typename:s}=t.original;return e.jsx("div",{className:"text-left font-medium",children:s})}},{accessorKey:"image",header:()=>e.jsx("div",{className:"text-left",children:"Image"}),cell:({row:t})=>{const{image:s}=t.original;return e.jsx("div",{className:"text-left font-medium",children:s?e.jsx("img",{alt:"missing img",src:s?.toString(),height:80,width:80}):"No image"})}},{accessorKey:"file",header:()=>e.jsx("div",{className:"text-left",children:"File"}),cell:({row:t})=>{const{file:s}=t.original;return e.jsx("div",{className:"text-left font-medium",children:s&&e.jsx(c,{variant:"outline",size:"sm",asChild:!0,children:e.jsx("a",{target:"_blank",rel:"noreferrer",href:s?.toString(),children:"Open"})})})}},{accessorKey:"date",header:({column:t})=>e.jsxs(c,{variant:"ghost",onClick:()=>t.toggleSorting(t.getIsSorted()==="asc"),children:[e.jsx("div",{className:"text-left",children:"Date"}),e.jsx(v,{className:"ml-2 h-4 w-4"})]}),cell:({row:t})=>"date"in t.original&&t.original.date?e.jsx("div",{className:"text-left font-medium",children:b(new Date(t.original.date),"dd/MM/yy")}):null},{accessorKey:"serialNumber",header:({column:t})=>e.jsxs(c,{variant:"ghost",onClick:()=>t.toggleSorting(t.getIsSorted()==="asc"),children:[e.jsx("div",{className:"text-left",children:"Serial Number"}),e.jsx(v,{className:"ml-2 h-4 w-4"})]}),cell:({row:t})=>"serialNumber"in t.original&&t.original.serialNumber?e.jsx("div",{className:"text-left font-medium",children:t.original.serialNumber}):null},{accessorKey:"vat.raw",header:({column:t})=>e.jsxs(c,{variant:"ghost",onClick:()=>t.toggleSorting(t.getIsSorted()==="asc"),children:[e.jsx("div",{className:"text-left",children:"VAT"}),e.jsx(v,{className:"ml-2 h-4 w-4"})]}),cell:({row:t})=>"vat"in t.original&&t.original.vat?.formatted?e.jsx("div",{className:"text-left font-medium whitespace-nowrap",children:t.original.vat.formatted}):null},{accessorKey:"amount.raw",header:({column:t})=>e.jsxs(c,{variant:"ghost",onClick:()=>t.toggleSorting(t.getIsSorted()==="asc"),children:[e.jsx("div",{className:"text-left",children:"Amount"}),e.jsx(v,{className:"ml-2 h-4 w-4"})]}),cell:({row:t})=>"amount"in t.original&&t.original.amount?.formatted?e.jsx("div",{className:"text-left font-medium whitespace-nowrap",children:t.original.amount.formatted}):null},{accessorKey:"creditor.name",header:({column:t})=>e.jsxs(c,{variant:"ghost",onClick:()=>t.toggleSorting(t.getIsSorted()==="asc"),children:[e.jsx("div",{className:"text-left",children:"Creditor"}),e.jsx(v,{className:"ml-2 h-4 w-4"})]}),cell:({row:t})=>"creditor"in t.original&&t.original.creditor?.name?e.jsx("div",{className:"text-left font-medium whitespace-nowrap",children:t.original.creditor.name}):null},{accessorKey:"debtor.name",header:({column:t})=>e.jsxs(c,{variant:"ghost",onClick:()=>t.toggleSorting(t.getIsSorted()==="asc"),children:[e.jsx("div",{className:"text-left",children:"Debtor"}),e.jsx(v,{className:"ml-2 h-4 w-4"})]}),cell:({row:t})=>"debtor"in t.original&&t.original.debtor?.name?e.jsx("div",{className:"text-left font-medium whitespace-nowrap",children:t.original.debtor.name}):null},{accessorKey:"charge.transactions[0].id",header:()=>e.jsx("div",{className:"text-left",children:"Related Transaction"}),cell:({row:t})=>t.original.charge?.transactions?.[0]?.id?e.jsx(Z,{items:t.original.charge?.transactions??[],columns:[{title:"Transaction Amount",value:s=>s?.amount.formatted},{title:"Transaction Created At",value:s=>s?.eventDate?b(new Date(s.eventDate),"dd/MM/yy"):null},{title:"Transaction Effective Date",value:s=>s?.effectiveDate?b(new Date(s.effectiveDate),"dd/MM/yy"):null},{title:"Transaction Description",value:s=>s?.sourceDescription}]}):"No Related Transaction"}],we=()=>{const[t,s]=l.useState(null),[x,j]=l.useState(!1),{get:h}=P(),o=h("documentsFilters"),y=l.useMemo(()=>{if(o)try{return JSON.parse(decodeURIComponent(o))}catch{return}},[o]),[r,d]=l.useState(y),[C,m]=l.useState([]),[a,g]=l.useState({}),{setFiltersContext:i}=l.useContext($),[{data:p,fetching:F},N]=W({query:ue,variables:{filters:r??{}},pause:!0});l.useEffect(()=>{r&&N()},[r,N]);const f=Y({data:p?.documentsByFilters??[],columns:E,getCoreRowModel:xe(),getPaginationRowModel:he(),onSortingChange:m,getSortedRowModel:ge(),onColumnVisibilityChange:g,state:{sorting:C,columnVisibility:a}}),A=f.getState().pagination.pageIndex;return l.useEffect(()=>{i(e.jsxs("div",{className:"flex flex-row gap-x-5",children:[e.jsx(je,{table:f}),e.jsx(ve,{filter:r,setFilter:d,initiallyOpened:!r})]}))},[f,F,r,i,d,y,A]),e.jsx(ee,{title:"Documents",description:"All documents",headerActions:e.jsxs("div",{className:"flex items-center py-4 gap-4",children:[e.jsxs(oe,{children:[e.jsx(ce,{asChild:!0,children:e.jsx(c,{className:"ml-auto",children:"Columns"})}),e.jsx(de,{align:"end",children:f.getAllColumns().filter(n=>n.getCanHide()).map(n=>e.jsx(me,{className:"capitalize",checked:n.getIsVisible(),onCheckedChange:u=>n.toggleVisibility(!!u),children:n.id},n.id))})]}),e.jsx(c,{onClick:()=>j(!0),children:"Upload Documents"})]}),children:F?e.jsx(te,{className:"h-10 w-10 animate-spin mr-2 self-center"}):e.jsxs(e.Fragment,{children:[e.jsx(se,{open:x,onOpenChange:j,onChange:N}),t&&e.jsx(V,{modalSize:"45%",content:e.jsx(ae,{src:t}),opened:!!t,onClose:()=>s(null)}),e.jsxs(ne,{children:[e.jsx(le,{children:f.getHeaderGroups().map(n=>e.jsx(S,{children:n.headers.map(u=>e.jsx(re,{children:u.isPlaceholder?null:k(u.column.columnDef.header,u.getContext())},u.id))},n.id))}),e.jsx(ie,{children:f.getRowModel().rows?.length?f.getRowModel().rows.map(n=>e.jsx(S,{"data-state":n.getIsSelected()&&"selected",children:n.getVisibleCells().map(u=>e.jsx(R,{children:k(u.column.columnDef.cell,u.getContext())},u.id))},n.id)):e.jsx(S,{children:e.jsx(R,{colSpan:E.length,className:"h-24 text-center",children:"No results."})})})]})]})})};export{we as DocumentsReport,E as columns};
1
+ import{r as l,cZ as w,u as P,d0 as O,j as e,c_ as V,bz as U,B as c,c$ as z,ae as K,V as _,H as b,dh as B,a0 as H,di as L,bO as D,ch as M,bT as I,bU as T,a2 as q,a3 as G,a4 as J,a5 as Q,aI as X,bu as Z,F as $,a as W,dj as Y,c as ee,L as te,dk as se,dl as ae,dm as ne,dn as le,dp as S,dq as re,dr as k,ds as ie,dt as R,du as oe,dv as ce,dw as de,dx as me,dy as ue,dz as ge,dA as he,dB as xe}from"./index-B9S5s-Ek.js";import{D as je}from"./data-table-pagination-BxG_nDcy.js";import{s as pe}from"./sub-DWCpbavW.js";import{A as v}from"./arrow-up-down-Dc_JXNej.js";import"./subMonths-DpFGzG8Q.js";function fe({filter:t,setFilter:s,closeModal:x}){const{userContext:j}=l.useContext(K),h=_({defaultValues:{ownerIDs:j?.context.adminBusinessId?[j.context.adminBusinessId]:void 0,toDate:b(new Date,"yyyy-MM-dd"),fromDate:b(pe(new Date,{years:1}),"yyyy-MM-dd"),...t}}),{control:o,handleSubmit:y}=h,{selectableFinancialEntities:r,fetching:d}=B(),C=a=>{s(a),x()};function m(){s({}),x()}return e.jsxs(e.Fragment,{children:[d?e.jsx("div",{children:"Loading..."}):e.jsx("div",{}),e.jsx(H,{...h,children:e.jsxs("form",{onSubmit:y(C),children:[e.jsxs(L,{cols:2,children:[e.jsx(D,{name:"ownerIDs",control:o,defaultValue:t.ownerIDs,render:({field:a,fieldState:g})=>e.jsx(M,{...a,data:r,value:a.value??[],disabled:d,label:"Owners",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:g.error?.message,withinPortal:!0})}),e.jsx(D,{name:"businessIDs",control:o,defaultValue:t.businessIDs,render:({field:a,fieldState:g})=>e.jsx(M,{...a,data:r,value:a.value??[],disabled:d,label:"Financial Entities",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:g.error?.message,withinPortal:!0})}),e.jsx(D,{name:"fromDate",control:o,defaultValue:t.fromDate,rules:{pattern:{value:I,message:"Date must be im format yyyy-mm-dd"}},render:({field:a,fieldState:g})=>e.jsx(T,{...a,onChange:i=>{const p=i?typeof i=="string"?i:b(i,"yyyy-MM-dd"):void 0;p!==a.value&&a.onChange(p)},value:a.value?new Date(a.value):void 0,error:g.error?.message,label:"From Date",popoverProps:{withinPortal:!0}})}),e.jsx(D,{name:"toDate",control:o,defaultValue:t.toDate,rules:{pattern:{value:I,message:"Date must be im format yyyy-mm-dd"}},render:({field:a,fieldState:g})=>e.jsx(T,{...a,onChange:i=>{const p=i?typeof i=="string"?i:b(i,"yyyy-MM-dd"):void 0;p!==a.value&&a.onChange(p)},value:a.value?new Date(a.value):void 0,error:g.error?.message,label:"To Date",popoverProps:{withinPortal:!0}})}),e.jsx(q,{name:"unmatched",control:o,render:({field:a})=>e.jsxs(G,{className:"flex flex-row items-center justify-between rounded-lg border p-3 shadow-sm",children:[e.jsx("div",{className:"space-y-0.5",children:e.jsx(J,{children:"Unmatched only"})}),e.jsx(Q,{children:e.jsx(X,{defaultChecked:t.unmatched??!1,onCheckedChange:a.onChange})})]})})]}),e.jsxs("div",{className:"flex justify-center mt-5 gap-3",children:[e.jsx("button",{type:"submit",disabled:d,className:"text-white bg-indigo-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-indigo-600 rounded-sm text-lg",children:"Filter"}),e.jsx("button",{type:"button",className:"text-white bg-orange-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-orange-600 rounded-sm text-lg",onClick:m,children:"Clear"}),e.jsx("button",{type:"button",className:"text-white bg-rose-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-rose-600 rounded-sm text-lg",onClick:x,children:"Cancel"})]})]})})]})}function ve({filter:t={},setFilter:s,initiallyOpened:x=!1}){const[j,h]=l.useState(x),[o,y]=l.useState(!w(t)),{get:r,set:d}=P();l.useEffect(()=>{const m=w(t)?null:encodeURIComponent(JSON.stringify(t)),a=r("documentsFilters");m!==a&&d("documentsFilters",m)},[t,r,d]);const C=l.useCallback(m=>{O(m,t)||(s(m),y(!w(m)))},[t,s]);return e.jsxs("div",{className:"flex flex-row gap-5 items-center",children:[e.jsx(V,{opened:j,onClose:()=>h(!1),content:e.jsx(fe,{filter:t,setFilter:C,closeModal:()=>h(!1)}),modalSize:"xl"}),e.jsx(U,{inline:!0,size:16,disabled:!o,children:e.jsx(c,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>h(!0),children:e.jsx(z,{className:"size-5"})})})]})}const E=[{accessorKey:"__typename",header:({column:t})=>e.jsxs(c,{variant:"ghost",onClick:()=>t.toggleSorting(t.getIsSorted()==="asc"),children:[e.jsx("div",{className:"text-left",children:"Type"}),e.jsx(v,{className:"ml-2 h-4 w-4"})]}),cell:({row:t})=>{const{__typename:s}=t.original;return e.jsx("div",{className:"text-left font-medium",children:s})}},{accessorKey:"image",header:()=>e.jsx("div",{className:"text-left",children:"Image"}),cell:({row:t})=>{const{image:s}=t.original;return e.jsx("div",{className:"text-left font-medium",children:s?e.jsx("img",{alt:"missing img",src:s?.toString(),height:80,width:80}):"No image"})}},{accessorKey:"file",header:()=>e.jsx("div",{className:"text-left",children:"File"}),cell:({row:t})=>{const{file:s}=t.original;return e.jsx("div",{className:"text-left font-medium",children:s&&e.jsx(c,{variant:"outline",size:"sm",asChild:!0,children:e.jsx("a",{target:"_blank",rel:"noreferrer",href:s?.toString(),children:"Open"})})})}},{accessorKey:"date",header:({column:t})=>e.jsxs(c,{variant:"ghost",onClick:()=>t.toggleSorting(t.getIsSorted()==="asc"),children:[e.jsx("div",{className:"text-left",children:"Date"}),e.jsx(v,{className:"ml-2 h-4 w-4"})]}),cell:({row:t})=>"date"in t.original&&t.original.date?e.jsx("div",{className:"text-left font-medium",children:b(new Date(t.original.date),"dd/MM/yy")}):null},{accessorKey:"serialNumber",header:({column:t})=>e.jsxs(c,{variant:"ghost",onClick:()=>t.toggleSorting(t.getIsSorted()==="asc"),children:[e.jsx("div",{className:"text-left",children:"Serial Number"}),e.jsx(v,{className:"ml-2 h-4 w-4"})]}),cell:({row:t})=>"serialNumber"in t.original&&t.original.serialNumber?e.jsx("div",{className:"text-left font-medium",children:t.original.serialNumber}):null},{accessorKey:"vat.raw",header:({column:t})=>e.jsxs(c,{variant:"ghost",onClick:()=>t.toggleSorting(t.getIsSorted()==="asc"),children:[e.jsx("div",{className:"text-left",children:"VAT"}),e.jsx(v,{className:"ml-2 h-4 w-4"})]}),cell:({row:t})=>"vat"in t.original&&t.original.vat?.formatted?e.jsx("div",{className:"text-left font-medium whitespace-nowrap",children:t.original.vat.formatted}):null},{accessorKey:"amount.raw",header:({column:t})=>e.jsxs(c,{variant:"ghost",onClick:()=>t.toggleSorting(t.getIsSorted()==="asc"),children:[e.jsx("div",{className:"text-left",children:"Amount"}),e.jsx(v,{className:"ml-2 h-4 w-4"})]}),cell:({row:t})=>"amount"in t.original&&t.original.amount?.formatted?e.jsx("div",{className:"text-left font-medium whitespace-nowrap",children:t.original.amount.formatted}):null},{accessorKey:"creditor.name",header:({column:t})=>e.jsxs(c,{variant:"ghost",onClick:()=>t.toggleSorting(t.getIsSorted()==="asc"),children:[e.jsx("div",{className:"text-left",children:"Creditor"}),e.jsx(v,{className:"ml-2 h-4 w-4"})]}),cell:({row:t})=>"creditor"in t.original&&t.original.creditor?.name?e.jsx("div",{className:"text-left font-medium whitespace-nowrap",children:t.original.creditor.name}):null},{accessorKey:"debtor.name",header:({column:t})=>e.jsxs(c,{variant:"ghost",onClick:()=>t.toggleSorting(t.getIsSorted()==="asc"),children:[e.jsx("div",{className:"text-left",children:"Debtor"}),e.jsx(v,{className:"ml-2 h-4 w-4"})]}),cell:({row:t})=>"debtor"in t.original&&t.original.debtor?.name?e.jsx("div",{className:"text-left font-medium whitespace-nowrap",children:t.original.debtor.name}):null},{accessorKey:"charge.transactions[0].id",header:()=>e.jsx("div",{className:"text-left",children:"Related Transaction"}),cell:({row:t})=>t.original.charge?.transactions?.[0]?.id?e.jsx(Z,{items:t.original.charge?.transactions??[],columns:[{title:"Transaction Amount",value:s=>s?.amount.formatted},{title:"Transaction Created At",value:s=>s?.eventDate?b(new Date(s.eventDate),"dd/MM/yy"):null},{title:"Transaction Effective Date",value:s=>s?.effectiveDate?b(new Date(s.effectiveDate),"dd/MM/yy"):null},{title:"Transaction Description",value:s=>s?.sourceDescription}]}):"No Related Transaction"}],we=()=>{const[t,s]=l.useState(null),[x,j]=l.useState(!1),{get:h}=P(),o=h("documentsFilters"),y=l.useMemo(()=>{if(o)try{return JSON.parse(decodeURIComponent(o))}catch{return}},[o]),[r,d]=l.useState(y),[C,m]=l.useState([]),[a,g]=l.useState({}),{setFiltersContext:i}=l.useContext($),[{data:p,fetching:F},N]=W({query:ue,variables:{filters:r??{}},pause:!0});l.useEffect(()=>{r&&N()},[r,N]);const f=Y({data:p?.documentsByFilters??[],columns:E,getCoreRowModel:xe(),getPaginationRowModel:he(),onSortingChange:m,getSortedRowModel:ge(),onColumnVisibilityChange:g,state:{sorting:C,columnVisibility:a}}),A=f.getState().pagination.pageIndex;return l.useEffect(()=>{i(e.jsxs("div",{className:"flex flex-row gap-x-5",children:[e.jsx(je,{table:f}),e.jsx(ve,{filter:r,setFilter:d,initiallyOpened:!r})]}))},[f,F,r,i,d,y,A]),e.jsx(ee,{title:"Documents",description:"All documents",headerActions:e.jsxs("div",{className:"flex items-center py-4 gap-4",children:[e.jsxs(oe,{children:[e.jsx(ce,{asChild:!0,children:e.jsx(c,{className:"ml-auto",children:"Columns"})}),e.jsx(de,{align:"end",children:f.getAllColumns().filter(n=>n.getCanHide()).map(n=>e.jsx(me,{className:"capitalize",checked:n.getIsVisible(),onCheckedChange:u=>n.toggleVisibility(!!u),children:n.id},n.id))})]}),e.jsx(c,{onClick:()=>j(!0),children:"Upload Documents"})]}),children:F?e.jsx(te,{className:"h-10 w-10 animate-spin mr-2 self-center"}):e.jsxs(e.Fragment,{children:[e.jsx(se,{open:x,onOpenChange:j,onChange:N}),t&&e.jsx(V,{modalSize:"45%",content:e.jsx(ae,{src:t}),opened:!!t,onClose:()=>s(null)}),e.jsxs(ne,{children:[e.jsx(le,{children:f.getHeaderGroups().map(n=>e.jsx(S,{children:n.headers.map(u=>e.jsx(re,{children:u.isPlaceholder?null:k(u.column.columnDef.header,u.getContext())},u.id))},n.id))}),e.jsx(ie,{children:f.getRowModel().rows?.length?f.getRowModel().rows.map(n=>e.jsx(S,{"data-state":n.getIsSelected()&&"selected",children:n.getVisibleCells().map(u=>e.jsx(R,{children:k(u.column.columnDef.cell,u.getContext())},u.id))},n.id)):e.jsx(S,{children:e.jsx(R,{colSpan:E.length,className:"h-24 text-center",children:"No results."})})})]})]})})};export{we as DocumentsReport,E as columns};
@@ -1 +1 @@
1
- import{cZ as k,r as m,u as R,d0 as V,j as e,c_ as q,bz as Q,B as I,c$ as z,V as G,cd as K,dh as X,aL as J,di as Z,bO as y,bP as A,bT as F,bU as B,H as S,ch as E,a as P,f7 as W,Y as U,n as $,Z as Y,_ as ee,at as ae,a1 as O,f8 as se,F as te,ae as re,aP as ne,c as oe,$ as le,e8 as ie,f9 as ce,b1 as de}from"./index-DfI9E1Fb.js";import{k as ue,B as N,X as H,Y as me,l as pe,m as xe,n as ge,o as he,p as fe,q as be,r as je}from"./chart-CQ9Opsuw.js";import{s as ye}from"./sub-BbpGm1pj.js";import"./sequential-CAnleQny.js";import"./subMonths-0tIJizDp.js";var ve=ue({chartName:"BarChart",GraphicalChild:N,defaultTooltipEventType:"axis",validateTooltipEventTypes:["axis","item"],axisComponents:[{axisType:"xAxis",AxisComp:H},{axisType:"yAxis",AxisComp:me}],formatAxisMap:pe});function _(s){return!s||k(s)?null:encodeURIComponent(JSON.stringify(s))}const L="balanceReportFilters",x={MONTHLY:"Monthly",BI_MONTHLY:"Bi-monthly",QUARTERLY:"Quarterly",SEMI_ANNUALLY:"Semi-Annually",ANNUALLY:"Annually"};function Ce({filter:s,setFilter:n,closeModal:c}){const{control:t,handleSubmit:r,watch:g}=G({defaultValues:{...s}}),{selectableBusinesses:b,fetching:h}=K(),{selectableFinancialEntities:f,fetching:v}=X(),{selectableTags:p,fetching:j}=J(),M=a=>{n(a),c()},C=g("excludedTags"),l=m.useMemo(()=>p.filter(a=>!C.includes(a.value)),[C,p]),d=g("includedTags"),o=m.useMemo(()=>p.filter(a=>!d.includes(a.value)),[d,p]);return e.jsxs("form",{onSubmit:r(M),children:[e.jsxs(Z,{cols:2,children:[e.jsx(y,{name:"ownerId",control:t,defaultValue:s?.ownerId,render:({field:a,fieldState:i})=>e.jsx(A,{...a,data:b,value:a.value,disabled:h,label:"Owners",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:i.error?.message,withinPortal:!0})}),e.jsx(y,{name:"fromDate",control:t,defaultValue:s?.fromDate,rules:{pattern:{value:F,message:"Date must be im format yyyy-mm-dd"}},render:({field:a,fieldState:i})=>e.jsx(B,{...a,onChange:u=>{const T=u?typeof u=="string"?u:S(u,"yyyy-MM-dd"):void 0;T!==a.value&&a.onChange(T)},value:a.value?new Date(a.value):void 0,error:i.error?.message,label:"From Date",popoverProps:{withinPortal:!0}})}),e.jsx(y,{name:"toDate",control:t,defaultValue:s?.toDate,rules:{pattern:{value:F,message:"Date must be im format yyyy-mm-dd"}},render:({field:a,fieldState:i})=>e.jsx(B,{...a,onChange:u=>{const T=u?typeof u=="string"?u:S(u,"yyyy-MM-dd"):void 0;T!==a.value&&a.onChange(T)},value:a.value?new Date(a.value):void 0,error:i.error?.message,label:"To Date",popoverProps:{withinPortal:!0}})}),e.jsx(y,{name:"period",control:t,defaultValue:x.MONTHLY,render:({field:a,fieldState:i})=>e.jsx(A,{...a,data:Object.values(x).map(u=>({value:u,label:u})),value:a.value,label:"Period",maxDropdownHeight:160,error:i.error?.message,withinPortal:!0})}),e.jsx(y,{name:"excludedCounterparties",control:t,defaultValue:s.excludedCounterparties,render:({field:a,fieldState:i})=>e.jsx(E,{...a,data:f,value:a.value??[],disabled:v,label:"Excluded Counterparties",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:i.error?.message,withinPortal:!0})}),e.jsx(y,{name:"includedTags",control:t,defaultValue:s.includedTags,render:({field:a,fieldState:i})=>e.jsx(E,{...a,data:l,value:a.value??[],disabled:j,label:"Included Tags",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:i.error?.message,withinPortal:!0})}),e.jsx(y,{name:"excludedTags",control:t,defaultValue:s.excludedTags,render:({field:a,fieldState:i})=>e.jsx(E,{...a,data:o,value:a.value??[],disabled:j,label:"Excluded Tags",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:i.error?.message,withinPortal:!0})})]}),e.jsxs("div",{className:"flex justify-center mt-5 gap-3",children:[e.jsx("button",{type:"submit",disabled:h,className:"text-white bg-indigo-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-indigo-600 rounded-sm text-lg",children:"Filter"}),e.jsx("button",{type:"button",className:"text-white bg-rose-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-rose-600 rounded-sm text-lg",onClick:c,children:"Cancel"})]})]})}function Te({filter:s,setFilter:n,initiallyOpened:c=!1}){const[t,r]=m.useState(c),[g,b]=m.useState(!!s),{get:h,set:f}=R();m.useEffect(()=>{const p=_(s),j=h(L);p!==j&&f(L,p)},[s,h,f]);const v=m.useCallback(p=>{V(p,s)||(n(p),b(!!p))},[s,n]);return e.jsxs("div",{className:"flex flex-row gap-5 items-center",children:[e.jsx(q,{opened:t,onClose:()=>r(!1),content:e.jsx(Ce,{filter:s,setFilter:v,closeModal:()=>r(!1)}),modalSize:"xl"}),e.jsx(Q,{inline:!0,size:16,disabled:!g,children:e.jsx(I,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>r(!0),children:e.jsx(z,{className:"size-5"})})})]})}const we=({period:s,transactionIDs:n,onCloseExtendedTransactions:c})=>{const[{data:t,fetching:r}]=P({query:W,variables:{transactionIDs:n}}),g=m.useMemo(()=>t?.transactionsByIDs?n.map(b=>t?.transactionsByIDs.find(h=>h.id===b)).filter(Boolean):[],[t,n]);return e.jsx(U,{className:"mt-5 w-full",children:r?e.jsx($,{}):e.jsxs(e.Fragment,{children:[e.jsx(Y,{children:e.jsxs(ee,{className:"flex justify-between",children:[e.jsxs("span",{children:[s," Transactions"]}),e.jsx(I,{variant:"link",onClick:c,children:e.jsx(ae,{className:"h-4 w-4"})})]})}),e.jsx(O,{children:e.jsx(se,{transactionsProps:g})})]})})};function Be(s){const n=new URLSearchParams,c=_(s);return c&&n.append(L,c),`/reports/balance${n.size>0?`?${n}`:""}`}const w={income:{label:"Income",color:"rgba(0, 255, 50, 0.5)"},expense:{label:"Expense",color:"rgba(255, 0, 0, 0.5)"},delta:{label:"Delta",color:"rgba(0, 30, 255, 0.5)"},cumulative:{label:"Cumulative Balance",color:"rgba(100, 0, 255, 0.5)"}};function Ne(s,n,c){switch(c){case x.MONTHLY:{const t=String(n).padStart(2,"0");return`${s}-${t}`}case x.BI_MONTHLY:{const t=n%2===0?n-1:n,r=String(t).padStart(2,"0");return`${s}-${r}`}case x.QUARTERLY:{const t=Math.ceil(n/3);return`${s}-Q${t}`}case x.SEMI_ANNUALLY:{const t=n>6?2:1;return`${s}-H${t}`}case x.ANNUALLY:return String(s)}}function Me(s,n){switch(n){case x.MONTHLY:{const[c,t]=s.split("-");return`${t}/${c}`}case x.BI_MONTHLY:{const[c,t]=s.split("-"),r=Number(t)+1,g=String(r).padStart(2,"0");return`${t}-${g}/${c}`}case x.QUARTERLY:{const[c,t]=s.split("-");return`${t}, ${c}`}case x.SEMI_ANNUALLY:{const[c,t]=s.split("-");return`${t}, ${c}`}case x.ANNUALLY:return s}}const D=ie(de.Usd),De=()=>{const{setFiltersContext:s}=m.useContext(te),{userContext:n}=m.useContext(re),{get:c}=R(),t=m.useMemo(()=>{const l={ownerId:n?.context.adminBusinessId,toDate:S(new Date,"yyyy-MM-dd"),period:x.MONTHLY,fromDate:S(ye(new Date,{years:1}),"yyyy-MM-dd"),excludedCounterparties:[],includedTags:[],excludedTags:[]},d=c(L);if(d)try{return JSON.parse(decodeURIComponent(d))}catch(o){console.log("Error parsing balance report filters from URL:",o)}return l},[n?.context.adminBusinessId,c]),[r,g]=m.useState(t),[b,h]=m.useState(void 0),[f,v]=m.useState(Object.keys(w)),p=m.useMemo(()=>{const{ownerId:l,fromDate:d,toDate:o}=r;return{ownerId:l,fromDate:d,toDate:o}},[r]),[{data:j,fetching:M}]=P({query:ce,variables:p,pause:!r});m.useEffect(()=>{s(e.jsxs("div",{className:"flex flex-row gap-x-5",children:[e.jsx(Te,{filter:r,setFilter:g,initiallyOpened:!r}),e.jsx(ne,{options:Object.entries(w).map(([l,d])=>({label:d.label,value:l})),onValueChange:v,defaultValue:f,placeholder:"Select Data Sets",variant:"default",maxCount:1})]})),h(void 0)},[j,M,r,s,g,f]),m.useEffect(()=>{g(l=>({...l,ownerId:n?.context.adminBusinessId}))},[n]);const C=m.useMemo(()=>{if(!j?.transactionsForBalanceReport)return[];const l=new Map;j.transactionsForBalanceReport.map(o=>{if(o.counterparty?.id&&(!o.isFee&&n?.context.financialAccountsBusinessesIds?.includes(o.counterparty.id)||r.excludedCounterparties?.includes(o.counterparty.id))||r.includedTags.length>0&&(!o.charge?.tags||o.charge.tags.length===0||!o.charge.tags.some(u=>r.includedTags.includes(u.id)))||r.excludedTags.length>0&&o.charge?.tags.length&&o.charge.tags.some(u=>r.excludedTags.includes(u.id)))return;const a=Ne(o.year,o.month,r.period);l.has(a)||l.set(a,{income:0,expense:0,delta:0,transactions:[]});const i=l.get(a);o.amountUsd.raw>0?i.income+=o.amountUsd.raw:i.expense+=o.amountUsd.raw,i.delta+=o.amountUsd.raw,i.transactions.push(o)});let d=0;return Array.from(l.entries()).sort((o,a)=>o[0].localeCompare(a[0])).map(([o,a])=>(d+=a.delta,{period:o,income:a.income,expense:a.expense,delta:a.delta,cumulative:d,transactions:a.transactions.sort((i,u)=>Math.abs(u.amountUsd.raw)-Math.abs(i.amountUsd.raw))}))},[j,r.period,r.excludedCounterparties,n?.context.financialAccountsBusinessesIds,r.includedTags,r.excludedTags]);return e.jsx(oe,{title:"Balance Report",description:"Accounts periodical balance",children:M?e.jsx($,{}):e.jsxs(e.Fragment,{children:[e.jsxs(U,{className:"w-full",children:[e.jsx(Y,{children:e.jsx(le,{children:"Click specific period to expand it's transactions data"})}),e.jsx(O,{children:e.jsx(xe,{config:w,className:"h-150 w-full",children:e.jsxs(ve,{accessibilityLayer:!0,data:C,onClick:l=>h(l.activeLabel),children:[e.jsx(ge,{vertical:!1}),e.jsx(H,{dataKey:"period",tickLine:!1,tickMargin:10,axisLine:!1,tickFormatter:l=>Me(l,r.period)}),e.jsx(he,{content:e.jsx(fe,{formatter:(l,d,o,a)=>{const i=`bg-[var(--color-${d})]`;return a<2?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:`${i} h-2.5 w-2.5 shrink-0 rounded-[2px]`}),w[d]?.label||d,e.jsx("div",{className:"ml-auto flex items-baseline gap-0.5 font-mono font-medium tabular-nums text-foreground",children:D.format(Number(l))})]}):e.jsxs("div",{className:"mt-1.5 flex basis-full items-center border-t pt-1.5 text-xs font-medium text-foreground",children:[e.jsx("div",{className:`h-2.5 w-2.5 shrink-0 rounded-[2px] mr-2 ${i}`}),w[d]?.label||d,e.jsx("div",{className:"ml-auto flex items-baseline gap-0.5 font-mono font-medium tabular-nums text-foreground",children:D.format(Number(l))})]})}})}),e.jsx(be,{content:e.jsx(je,{})}),f.includes("income")&&e.jsx(N,{dataKey:"income",fill:"var(--color-income)",radius:4}),f.includes("expense")&&e.jsx(N,{dataKey:"expense",fill:"var(--color-expense)",radius:4}),f.includes("delta")&&e.jsx(N,{dataKey:"delta",fill:"var(--color-delta)",radius:4}),f.includes("cumulative")&&e.jsx(N,{dataKey:"cumulative",fill:"var(--color-cumulative)",radius:4})]})})})]}),b&&e.jsx(we,{period:b,onCloseExtendedTransactions:()=>h(void 0),transactionIDs:C.find(l=>l.period===b)?.transactions.map(l=>l.id)??[]})]})})};export{De as BalanceReport,Be as getBalanceReportHref};
1
+ import{cZ as k,r as m,u as R,d0 as V,j as e,c_ as q,bz as Q,B as I,c$ as z,V as G,cd as K,dh as X,aL as J,di as Z,bO as y,bP as A,bT as F,bU as B,H as S,ch as E,a as P,f7 as W,Y as U,n as $,Z as Y,_ as ee,at as ae,a1 as O,f8 as se,F as te,ae as re,aP as ne,c as oe,$ as le,e8 as ie,f9 as ce,b1 as de}from"./index-B9S5s-Ek.js";import{k as ue,B as N,X as H,Y as me,l as pe,m as xe,n as ge,o as he,p as fe,q as be,r as je}from"./chart-DJ8eRZgf.js";import{s as ye}from"./sub-DWCpbavW.js";import"./sequential-CAnleQny.js";import"./subMonths-DpFGzG8Q.js";var ve=ue({chartName:"BarChart",GraphicalChild:N,defaultTooltipEventType:"axis",validateTooltipEventTypes:["axis","item"],axisComponents:[{axisType:"xAxis",AxisComp:H},{axisType:"yAxis",AxisComp:me}],formatAxisMap:pe});function _(s){return!s||k(s)?null:encodeURIComponent(JSON.stringify(s))}const L="balanceReportFilters",x={MONTHLY:"Monthly",BI_MONTHLY:"Bi-monthly",QUARTERLY:"Quarterly",SEMI_ANNUALLY:"Semi-Annually",ANNUALLY:"Annually"};function Ce({filter:s,setFilter:n,closeModal:c}){const{control:t,handleSubmit:r,watch:g}=G({defaultValues:{...s}}),{selectableBusinesses:b,fetching:h}=K(),{selectableFinancialEntities:f,fetching:v}=X(),{selectableTags:p,fetching:j}=J(),M=a=>{n(a),c()},C=g("excludedTags"),l=m.useMemo(()=>p.filter(a=>!C.includes(a.value)),[C,p]),d=g("includedTags"),o=m.useMemo(()=>p.filter(a=>!d.includes(a.value)),[d,p]);return e.jsxs("form",{onSubmit:r(M),children:[e.jsxs(Z,{cols:2,children:[e.jsx(y,{name:"ownerId",control:t,defaultValue:s?.ownerId,render:({field:a,fieldState:i})=>e.jsx(A,{...a,data:b,value:a.value,disabled:h,label:"Owners",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:i.error?.message,withinPortal:!0})}),e.jsx(y,{name:"fromDate",control:t,defaultValue:s?.fromDate,rules:{pattern:{value:F,message:"Date must be im format yyyy-mm-dd"}},render:({field:a,fieldState:i})=>e.jsx(B,{...a,onChange:u=>{const T=u?typeof u=="string"?u:S(u,"yyyy-MM-dd"):void 0;T!==a.value&&a.onChange(T)},value:a.value?new Date(a.value):void 0,error:i.error?.message,label:"From Date",popoverProps:{withinPortal:!0}})}),e.jsx(y,{name:"toDate",control:t,defaultValue:s?.toDate,rules:{pattern:{value:F,message:"Date must be im format yyyy-mm-dd"}},render:({field:a,fieldState:i})=>e.jsx(B,{...a,onChange:u=>{const T=u?typeof u=="string"?u:S(u,"yyyy-MM-dd"):void 0;T!==a.value&&a.onChange(T)},value:a.value?new Date(a.value):void 0,error:i.error?.message,label:"To Date",popoverProps:{withinPortal:!0}})}),e.jsx(y,{name:"period",control:t,defaultValue:x.MONTHLY,render:({field:a,fieldState:i})=>e.jsx(A,{...a,data:Object.values(x).map(u=>({value:u,label:u})),value:a.value,label:"Period",maxDropdownHeight:160,error:i.error?.message,withinPortal:!0})}),e.jsx(y,{name:"excludedCounterparties",control:t,defaultValue:s.excludedCounterparties,render:({field:a,fieldState:i})=>e.jsx(E,{...a,data:f,value:a.value??[],disabled:v,label:"Excluded Counterparties",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:i.error?.message,withinPortal:!0})}),e.jsx(y,{name:"includedTags",control:t,defaultValue:s.includedTags,render:({field:a,fieldState:i})=>e.jsx(E,{...a,data:l,value:a.value??[],disabled:j,label:"Included Tags",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:i.error?.message,withinPortal:!0})}),e.jsx(y,{name:"excludedTags",control:t,defaultValue:s.excludedTags,render:({field:a,fieldState:i})=>e.jsx(E,{...a,data:o,value:a.value??[],disabled:j,label:"Excluded Tags",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:i.error?.message,withinPortal:!0})})]}),e.jsxs("div",{className:"flex justify-center mt-5 gap-3",children:[e.jsx("button",{type:"submit",disabled:h,className:"text-white bg-indigo-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-indigo-600 rounded-sm text-lg",children:"Filter"}),e.jsx("button",{type:"button",className:"text-white bg-rose-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-rose-600 rounded-sm text-lg",onClick:c,children:"Cancel"})]})]})}function Te({filter:s,setFilter:n,initiallyOpened:c=!1}){const[t,r]=m.useState(c),[g,b]=m.useState(!!s),{get:h,set:f}=R();m.useEffect(()=>{const p=_(s),j=h(L);p!==j&&f(L,p)},[s,h,f]);const v=m.useCallback(p=>{V(p,s)||(n(p),b(!!p))},[s,n]);return e.jsxs("div",{className:"flex flex-row gap-5 items-center",children:[e.jsx(q,{opened:t,onClose:()=>r(!1),content:e.jsx(Ce,{filter:s,setFilter:v,closeModal:()=>r(!1)}),modalSize:"xl"}),e.jsx(Q,{inline:!0,size:16,disabled:!g,children:e.jsx(I,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>r(!0),children:e.jsx(z,{className:"size-5"})})})]})}const we=({period:s,transactionIDs:n,onCloseExtendedTransactions:c})=>{const[{data:t,fetching:r}]=P({query:W,variables:{transactionIDs:n}}),g=m.useMemo(()=>t?.transactionsByIDs?n.map(b=>t?.transactionsByIDs.find(h=>h.id===b)).filter(Boolean):[],[t,n]);return e.jsx(U,{className:"mt-5 w-full",children:r?e.jsx($,{}):e.jsxs(e.Fragment,{children:[e.jsx(Y,{children:e.jsxs(ee,{className:"flex justify-between",children:[e.jsxs("span",{children:[s," Transactions"]}),e.jsx(I,{variant:"link",onClick:c,children:e.jsx(ae,{className:"h-4 w-4"})})]})}),e.jsx(O,{children:e.jsx(se,{transactionsProps:g})})]})})};function Be(s){const n=new URLSearchParams,c=_(s);return c&&n.append(L,c),`/reports/balance${n.size>0?`?${n}`:""}`}const w={income:{label:"Income",color:"rgba(0, 255, 50, 0.5)"},expense:{label:"Expense",color:"rgba(255, 0, 0, 0.5)"},delta:{label:"Delta",color:"rgba(0, 30, 255, 0.5)"},cumulative:{label:"Cumulative Balance",color:"rgba(100, 0, 255, 0.5)"}};function Ne(s,n,c){switch(c){case x.MONTHLY:{const t=String(n).padStart(2,"0");return`${s}-${t}`}case x.BI_MONTHLY:{const t=n%2===0?n-1:n,r=String(t).padStart(2,"0");return`${s}-${r}`}case x.QUARTERLY:{const t=Math.ceil(n/3);return`${s}-Q${t}`}case x.SEMI_ANNUALLY:{const t=n>6?2:1;return`${s}-H${t}`}case x.ANNUALLY:return String(s)}}function Me(s,n){switch(n){case x.MONTHLY:{const[c,t]=s.split("-");return`${t}/${c}`}case x.BI_MONTHLY:{const[c,t]=s.split("-"),r=Number(t)+1,g=String(r).padStart(2,"0");return`${t}-${g}/${c}`}case x.QUARTERLY:{const[c,t]=s.split("-");return`${t}, ${c}`}case x.SEMI_ANNUALLY:{const[c,t]=s.split("-");return`${t}, ${c}`}case x.ANNUALLY:return s}}const D=ie(de.Usd),De=()=>{const{setFiltersContext:s}=m.useContext(te),{userContext:n}=m.useContext(re),{get:c}=R(),t=m.useMemo(()=>{const l={ownerId:n?.context.adminBusinessId,toDate:S(new Date,"yyyy-MM-dd"),period:x.MONTHLY,fromDate:S(ye(new Date,{years:1}),"yyyy-MM-dd"),excludedCounterparties:[],includedTags:[],excludedTags:[]},d=c(L);if(d)try{return JSON.parse(decodeURIComponent(d))}catch(o){console.log("Error parsing balance report filters from URL:",o)}return l},[n?.context.adminBusinessId,c]),[r,g]=m.useState(t),[b,h]=m.useState(void 0),[f,v]=m.useState(Object.keys(w)),p=m.useMemo(()=>{const{ownerId:l,fromDate:d,toDate:o}=r;return{ownerId:l,fromDate:d,toDate:o}},[r]),[{data:j,fetching:M}]=P({query:ce,variables:p,pause:!r});m.useEffect(()=>{s(e.jsxs("div",{className:"flex flex-row gap-x-5",children:[e.jsx(Te,{filter:r,setFilter:g,initiallyOpened:!r}),e.jsx(ne,{options:Object.entries(w).map(([l,d])=>({label:d.label,value:l})),onValueChange:v,defaultValue:f,placeholder:"Select Data Sets",variant:"default",maxCount:1})]})),h(void 0)},[j,M,r,s,g,f]),m.useEffect(()=>{g(l=>({...l,ownerId:n?.context.adminBusinessId}))},[n]);const C=m.useMemo(()=>{if(!j?.transactionsForBalanceReport)return[];const l=new Map;j.transactionsForBalanceReport.map(o=>{if(o.counterparty?.id&&(!o.isFee&&n?.context.financialAccountsBusinessesIds?.includes(o.counterparty.id)||r.excludedCounterparties?.includes(o.counterparty.id))||r.includedTags.length>0&&(!o.charge?.tags||o.charge.tags.length===0||!o.charge.tags.some(u=>r.includedTags.includes(u.id)))||r.excludedTags.length>0&&o.charge?.tags.length&&o.charge.tags.some(u=>r.excludedTags.includes(u.id)))return;const a=Ne(o.year,o.month,r.period);l.has(a)||l.set(a,{income:0,expense:0,delta:0,transactions:[]});const i=l.get(a);o.amountUsd.raw>0?i.income+=o.amountUsd.raw:i.expense+=o.amountUsd.raw,i.delta+=o.amountUsd.raw,i.transactions.push(o)});let d=0;return Array.from(l.entries()).sort((o,a)=>o[0].localeCompare(a[0])).map(([o,a])=>(d+=a.delta,{period:o,income:a.income,expense:a.expense,delta:a.delta,cumulative:d,transactions:a.transactions.sort((i,u)=>Math.abs(u.amountUsd.raw)-Math.abs(i.amountUsd.raw))}))},[j,r.period,r.excludedCounterparties,n?.context.financialAccountsBusinessesIds,r.includedTags,r.excludedTags]);return e.jsx(oe,{title:"Balance Report",description:"Accounts periodical balance",children:M?e.jsx($,{}):e.jsxs(e.Fragment,{children:[e.jsxs(U,{className:"w-full",children:[e.jsx(Y,{children:e.jsx(le,{children:"Click specific period to expand it's transactions data"})}),e.jsx(O,{children:e.jsx(xe,{config:w,className:"h-150 w-full",children:e.jsxs(ve,{accessibilityLayer:!0,data:C,onClick:l=>h(l.activeLabel),children:[e.jsx(ge,{vertical:!1}),e.jsx(H,{dataKey:"period",tickLine:!1,tickMargin:10,axisLine:!1,tickFormatter:l=>Me(l,r.period)}),e.jsx(he,{content:e.jsx(fe,{formatter:(l,d,o,a)=>{const i=`bg-[var(--color-${d})]`;return a<2?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:`${i} h-2.5 w-2.5 shrink-0 rounded-[2px]`}),w[d]?.label||d,e.jsx("div",{className:"ml-auto flex items-baseline gap-0.5 font-mono font-medium tabular-nums text-foreground",children:D.format(Number(l))})]}):e.jsxs("div",{className:"mt-1.5 flex basis-full items-center border-t pt-1.5 text-xs font-medium text-foreground",children:[e.jsx("div",{className:`h-2.5 w-2.5 shrink-0 rounded-[2px] mr-2 ${i}`}),w[d]?.label||d,e.jsx("div",{className:"ml-auto flex items-baseline gap-0.5 font-mono font-medium tabular-nums text-foreground",children:D.format(Number(l))})]})}})}),e.jsx(be,{content:e.jsx(je,{})}),f.includes("income")&&e.jsx(N,{dataKey:"income",fill:"var(--color-income)",radius:4}),f.includes("expense")&&e.jsx(N,{dataKey:"expense",fill:"var(--color-expense)",radius:4}),f.includes("delta")&&e.jsx(N,{dataKey:"delta",fill:"var(--color-delta)",radius:4}),f.includes("cumulative")&&e.jsx(N,{dataKey:"cumulative",fill:"var(--color-cumulative)",radius:4})]})})})]}),b&&e.jsx(we,{period:b,onCloseExtendedTransactions:()=>h(void 0),transactionIDs:C.find(l=>l.period===b)?.transactions.map(l=>l.id)??[]})]})})};export{De as BalanceReport,Be as getBalanceReportHref};
@@ -1,4 +1,4 @@
1
- import{cZ as f,r as h,u as B,j as e,c_ as $,bz as N,B as S,c$ as R,V as k,cd as O,ae as z,a0 as A,bO as v,ch as D,bT as C,bU as F,H as T,a2 as E,a3 as P,a4 as L,a5 as V,aI as M,d0 as U,dR as _,b$ as w,T as I,P as q,b as G,bg as Z,b6 as j,b1 as p,X as H,dS as J,ca as Q,cS as y,F as X,a as K,dT as W,dU as Y,c as ee,L as te,dV as se}from"./index-DfI9E1Fb.js";function ae(t){return!t||f(t)?null:encodeURIComponent(JSON.stringify(t))}function re({filter:t,setFilter:s,closeModal:o}){const n=k({defaultValues:{...t}}),{control:r,handleSubmit:l}=n,{selectableBusinesses:a,fetching:u}=O(),{userContext:m}=h.useContext(z),c=i=>{i.fromDate?.trim()===""&&(i.fromDate=void 0),i.toDate?.trim()===""&&(i.toDate=void 0),s(i),o()};function d(){s({}),o()}return e.jsxs(e.Fragment,{children:[u?e.jsx("div",{children:"Loading..."}):e.jsx("div",{}),e.jsx(A,{...n,children:e.jsxs("form",{onSubmit:l(c),className:"space-y-2",children:[e.jsx(v,{name:"ownerIds",control:r,defaultValue:void 0,render:({field:i,fieldState:b})=>e.jsx(D,{...i,data:a,value:i.value??(m?.context.adminBusinessId?[m?.context.adminBusinessId]:void 0),disabled:u,label:"Owners",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:b.error?.message})}),e.jsx(v,{name:"businessIDs",control:r,defaultValue:void 0,render:({field:i,fieldState:b})=>e.jsx(D,{...i,data:a,value:i.value??void 0,disabled:u,label:"Businesses",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:b.error?.message})}),e.jsx(v,{name:"fromDate",control:r,defaultValue:t.fromDate,rules:{required:"Required",pattern:{value:C,message:"Date must be im format yyyy-mm-dd"}},render:({field:i,fieldState:b})=>e.jsx(F,{...i,onChange:x=>{const g=x?typeof x=="string"?x:T(x,"yyyy-MM-dd"):void 0;g!==i.value&&i.onChange(g)},value:i.value?new Date(i.value):void 0,label:"From Date",error:b.error?.message,required:!0,popoverProps:{withinPortal:!0}})}),e.jsx(v,{name:"toDate",control:r,defaultValue:t.toDate,rules:{pattern:{value:C,message:"Date must be im format yyyy-mm-dd"}},render:({field:i,fieldState:b})=>e.jsx(F,{...i,onChange:x=>{const g=x?typeof x=="string"?x:T(x,"yyyy-MM-dd"):void 0;g!==i.value&&i.onChange(g)},value:i.value?new Date(i.value):void 0,label:"To Date",error:b.error?.message,required:!0,popoverProps:{withinPortal:!0}})}),e.jsx(E,{name:"isShowZeroedAccounts",control:r,render:({field:i})=>e.jsxs(P,{className:"flex flex-row items-center justify-between rounded-lg border p-3 shadow-sm",children:[e.jsx("div",{className:"space-y-0.5",children:e.jsx(L,{children:"Show zeroed accounts"})}),e.jsxs("div",{className:"flex flex-row items-center gap-1",children:[e.jsx(V,{children:e.jsx(M,{defaultChecked:t.isShowZeroedAccounts??!1,onCheckedChange:i.onChange,checked:i.value===!0})}),e.jsx("span",{children:i.value?"show":"remove"})]})]})}),e.jsxs("div",{className:"flex justify-center mt-5 gap-3",children:[e.jsx("button",{type:"submit",className:"text-white bg-indigo-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-indigo-600 rounded-sm text-lg",children:"Filter"}),e.jsx("button",{type:"button",className:"text-white bg-orange-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-orange-600 rounded-sm text-lg",onClick:d,children:"Clear"}),e.jsx("button",{type:"button",className:"text-white bg-rose-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-rose-600 rounded-sm text-lg",onClick:o,children:"Cancel"})]})]})})]})}function ne({filter:t,setFilter:s}){const[o,n]=h.useState(!1),[r,l]=h.useState(!f(t)),{get:a,set:u}=B();function m(d){return Object.entries(d??{}).filter(([b,x])=>x!==void 0&&Array.isArray(x)&&x.length>0).length>0}function c(d){U(d,t)||(s(d),l(m(d)))}return h.useEffect(()=>{const d=f(t)?null:encodeURIComponent(JSON.stringify(t)),i=a("trialBalanceReportFilters");d!==i&&u("trialBalanceReportFilters",d)},[t,a,u]),e.jsxs(e.Fragment,{children:[e.jsx($,{opened:o,onClose:()=>n(!1),content:e.jsx(re,{filter:t,setFilter:c,closeModal:()=>n(!1)})}),e.jsx(N,{inline:!0,size:16,disabled:!r,children:e.jsx(S,{variant:"outline",onClick:()=>n(!0),className:"p-2",children:e.jsx(R,{size:20})})})]})}const oe=({data:t,fromDate:s,toDate:o})=>{const n=h.useCallback(async()=>{const r=le(t),l=`trial_balance_report${s?`_${s}`:""}${o?`_${o}`:""}`;return{fileContent:r,fileName:l}},[t,s,o]);return e.jsx(_,{createFileVariables:n})},le=t=>{let s="";s+=`Sort Code,Account Name,Debit,Credit,Balance\r
1
+ import{cZ as f,r as h,u as B,j as e,c_ as $,bz as N,B as S,c$ as R,V as k,cd as O,ae as z,a0 as A,bO as v,ch as D,bT as C,bU as F,H as T,a2 as E,a3 as P,a4 as L,a5 as V,aI as M,d0 as U,dR as _,b$ as w,T as I,P as q,b as G,bg as Z,b6 as j,b1 as p,X as H,dS as J,ca as Q,cS as y,F as X,a as K,dT as W,dU as Y,c as ee,L as te,dV as se}from"./index-B9S5s-Ek.js";function ae(t){return!t||f(t)?null:encodeURIComponent(JSON.stringify(t))}function re({filter:t,setFilter:s,closeModal:o}){const n=k({defaultValues:{...t}}),{control:r,handleSubmit:l}=n,{selectableBusinesses:a,fetching:u}=O(),{userContext:m}=h.useContext(z),c=i=>{i.fromDate?.trim()===""&&(i.fromDate=void 0),i.toDate?.trim()===""&&(i.toDate=void 0),s(i),o()};function d(){s({}),o()}return e.jsxs(e.Fragment,{children:[u?e.jsx("div",{children:"Loading..."}):e.jsx("div",{}),e.jsx(A,{...n,children:e.jsxs("form",{onSubmit:l(c),className:"space-y-2",children:[e.jsx(v,{name:"ownerIds",control:r,defaultValue:void 0,render:({field:i,fieldState:b})=>e.jsx(D,{...i,data:a,value:i.value??(m?.context.adminBusinessId?[m?.context.adminBusinessId]:void 0),disabled:u,label:"Owners",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:b.error?.message})}),e.jsx(v,{name:"businessIDs",control:r,defaultValue:void 0,render:({field:i,fieldState:b})=>e.jsx(D,{...i,data:a,value:i.value??void 0,disabled:u,label:"Businesses",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:b.error?.message})}),e.jsx(v,{name:"fromDate",control:r,defaultValue:t.fromDate,rules:{required:"Required",pattern:{value:C,message:"Date must be im format yyyy-mm-dd"}},render:({field:i,fieldState:b})=>e.jsx(F,{...i,onChange:x=>{const g=x?typeof x=="string"?x:T(x,"yyyy-MM-dd"):void 0;g!==i.value&&i.onChange(g)},value:i.value?new Date(i.value):void 0,label:"From Date",error:b.error?.message,required:!0,popoverProps:{withinPortal:!0}})}),e.jsx(v,{name:"toDate",control:r,defaultValue:t.toDate,rules:{pattern:{value:C,message:"Date must be im format yyyy-mm-dd"}},render:({field:i,fieldState:b})=>e.jsx(F,{...i,onChange:x=>{const g=x?typeof x=="string"?x:T(x,"yyyy-MM-dd"):void 0;g!==i.value&&i.onChange(g)},value:i.value?new Date(i.value):void 0,label:"To Date",error:b.error?.message,required:!0,popoverProps:{withinPortal:!0}})}),e.jsx(E,{name:"isShowZeroedAccounts",control:r,render:({field:i})=>e.jsxs(P,{className:"flex flex-row items-center justify-between rounded-lg border p-3 shadow-sm",children:[e.jsx("div",{className:"space-y-0.5",children:e.jsx(L,{children:"Show zeroed accounts"})}),e.jsxs("div",{className:"flex flex-row items-center gap-1",children:[e.jsx(V,{children:e.jsx(M,{defaultChecked:t.isShowZeroedAccounts??!1,onCheckedChange:i.onChange,checked:i.value===!0})}),e.jsx("span",{children:i.value?"show":"remove"})]})]})}),e.jsxs("div",{className:"flex justify-center mt-5 gap-3",children:[e.jsx("button",{type:"submit",className:"text-white bg-indigo-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-indigo-600 rounded-sm text-lg",children:"Filter"}),e.jsx("button",{type:"button",className:"text-white bg-orange-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-orange-600 rounded-sm text-lg",onClick:d,children:"Clear"}),e.jsx("button",{type:"button",className:"text-white bg-rose-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-rose-600 rounded-sm text-lg",onClick:o,children:"Cancel"})]})]})})]})}function ne({filter:t,setFilter:s}){const[o,n]=h.useState(!1),[r,l]=h.useState(!f(t)),{get:a,set:u}=B();function m(d){return Object.entries(d??{}).filter(([b,x])=>x!==void 0&&Array.isArray(x)&&x.length>0).length>0}function c(d){U(d,t)||(s(d),l(m(d)))}return h.useEffect(()=>{const d=f(t)?null:encodeURIComponent(JSON.stringify(t)),i=a("trialBalanceReportFilters");d!==i&&u("trialBalanceReportFilters",d)},[t,a,u]),e.jsxs(e.Fragment,{children:[e.jsx($,{opened:o,onClose:()=>n(!1),content:e.jsx(re,{filter:t,setFilter:c,closeModal:()=>n(!1)})}),e.jsx(N,{inline:!0,size:16,disabled:!r,children:e.jsx(S,{variant:"outline",onClick:()=>n(!0),className:"p-2",children:e.jsx(R,{size:20})})})]})}const oe=({data:t,fromDate:s,toDate:o})=>{const n=h.useCallback(async()=>{const r=le(t),l=`trial_balance_report${s?`_${s}`:""}${o?`_${o}`:""}`;return{fileContent:r,fileName:l}},[t,s,o]);return e.jsx(_,{createFileVariables:n})},le=t=>{let s="";s+=`Sort Code,Account Name,Debit,Credit,Balance\r
2
2
  `;for(const[o,n]of Object.entries(t)){const r=ie(o,n);s+=r}return s+=`Report total:,,${Object.values(t).reduce((o,n)=>o+n.totalDebit,0)},${Object.values(t).reduce((o,n)=>o+n.totalCredit,0)},${Object.values(t).reduce((o,n)=>o+n.sum,0)}\r
3
3
  `,s};function ie(t,s){let o="";return Object.values(s.sortCodes).sort((n,r)=>n.key-r.key).map(n=>{const r=ce(n);o+=r}),o+=`${t.replaceAll("0","*")},Group Total:,${s.totalDebit??""},${s.totalCredit??""},${s.sum}\r
4
4
  `,o}function ce(t){let s="";s+=`${t.name}\r