@accounter/client 0.0.9-alpha-20251209135403-8ff0c644655c764ce404779933f0dbf26a6a54e9 → 0.0.9-alpha-20251209170231-980cc730914111644c9194dac5ac995a09e28c74

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 (94) hide show
  1. package/CHANGELOG.md +1 -1
  2. package/dist/assets/{Checkbox-BHVKlxRj.js → Checkbox-CoEj3QSE.js} +1 -1
  3. package/dist/assets/{MultiSelect-DY08OexD.js → MultiSelect-DRJD_QDr.js} +1 -1
  4. package/dist/assets/{Progress-CkBW27DM.js → Progress-CU1fWOjF.js} +1 -1
  5. package/dist/assets/{Table-bhKB4PFK.js → Table-C5b9rbOB.js} +1 -1
  6. package/dist/assets/{Typography-DclIL89E.js → Typography-CJ6IUHKs.js} +1 -1
  7. package/dist/assets/{YearPickerInput-DgK0Ih6X.js → YearPickerInput-DD-O605S.js} +1 -1
  8. package/dist/assets/{accordion-CAxRDsFz.js → accordion-Csw2mWiO.js} +1 -1
  9. package/dist/assets/{accountant-approvals-Dgsw0WDb.js → accountant-approvals-BeUBLtnd.js} +1 -1
  10. package/dist/assets/{accounter-table-DIm6Wedu.js → accounter-table-CLNNqdXm.js} +1 -1
  11. package/dist/assets/{addDays-CpwSVE6j.js → addDays-oqtNz11p.js} +1 -1
  12. package/dist/assets/{all-charges-CS_0zCEZ.js → all-charges-BK_c2XcZ.js} +1 -1
  13. package/dist/assets/{arrow-up-down-BCKzoFzo.js → arrow-up-down-BepSQkkk.js} +1 -1
  14. package/dist/assets/{building-2-Cp2Es1mt.js → building-2-DoYjr9zp.js} +1 -1
  15. package/dist/assets/{business-B1WVYc0i.js → business-C49SW3ik.js} +2 -2
  16. package/dist/assets/{business-extended-info-NwMS1Rj6.js → business-extended-info-CaoOYPT8.js} +1 -1
  17. package/dist/assets/{business-header-D7w2Xzis.js → business-header-gf-FUFaN.js} +1 -1
  18. package/dist/assets/{business-ledger-filters-BBCKjVgu.js → business-ledger-filters-Clr_J6Pb.js} +1 -1
  19. package/dist/assets/{business-ledger-single-CjmguyFq.js → business-ledger-single-CeMmKYhH.js} +1 -1
  20. package/dist/assets/{business-trip-BljjobKa.js → business-trip-DNDWlM8w.js} +1 -1
  21. package/dist/assets/charge-NQDW3QqJ.js +1 -0
  22. package/dist/assets/{charges-filters-D_ruML4x.js → charges-filters-nFUpOOgf.js} +1 -1
  23. package/dist/assets/{charges-ledger-validation-RNuvPfFo.js → charges-ledger-validation-zMQsg1pC.js} +1 -1
  24. package/dist/assets/{charges-table-Dmz1Fxim.js → charges-table-CTMLwet4.js} +1 -1
  25. package/dist/assets/{chart-MqLuc9m0.js → chart-CcwcQbqJ.js} +1 -1
  26. package/dist/assets/{contracts-DCmvv-5I.js → contracts-CAZC6d8B.js} +1 -1
  27. package/dist/assets/{data-table-column-header-CT7O7uRT.js → data-table-column-header-BxsKrjBX.js} +1 -1
  28. package/dist/assets/{data-table-pagination-Bn6-S7wX.js → data-table-pagination-wIOuSOqc.js} +1 -1
  29. package/dist/assets/{deposits-transactions-table-BAObjoYX.js → deposits-transactions-table-jhVmfuNs.js} +1 -1
  30. package/dist/assets/{download-csv-button-BsXK9P76.js → download-csv-button-CxFM5ZN1.js} +1 -1
  31. package/dist/assets/{edit-issue-document-modal-CG9FH4t_.js → edit-issue-document-modal-CI2VPVkB.js} +1 -1
  32. package/dist/assets/{editable-business-trip-CH61WHL7.js → editable-business-trip-B388mlUw.js} +1 -1
  33. package/dist/assets/{eye-off-Cc-ssiRk.js → eye-off-CfHy9jRk.js} +1 -1
  34. package/dist/assets/{funnel-4UXATjU3.js → funnel-Cn1E8rCW.js} +1 -1
  35. package/dist/assets/{index-JJZ0k_k8.js → index-2Ym7mPTf.js} +1 -1
  36. package/dist/assets/{index-CPuaqVQw.js → index-BM4xRMf6.js} +1 -1
  37. package/dist/assets/{index-D8HuUMKu.js → index-BWtxBLCR.js} +1 -1
  38. package/dist/assets/{index-CFrclniY.js → index-BYgtjSMY.js} +1 -1
  39. package/dist/assets/{index-BHTel4x6.js → index-BbVwSP6k.js} +1 -1
  40. package/dist/assets/{index-DYUcGCvp.js → index-Bcc1EVhw.js} +1 -1
  41. package/dist/assets/{index-Cz49agDK.js → index-BcxhLoO7.js} +1 -1
  42. package/dist/assets/{index-lpyXbMDd.js → index-Bq4ew9mE.js} +1 -1
  43. package/dist/assets/{index-De4VpPkV.js → index-BvTcJJXh.js} +1 -1
  44. package/dist/assets/{index-DQsGXPYg.js → index-CM5jGkPB.js} +1 -1
  45. package/dist/assets/{index-DVU7w2C4.js → index-D0scMlrm.js} +1 -1
  46. package/dist/assets/{index-Cw81Wg3b.js → index-DAjmDqPJ.js} +1 -1
  47. package/dist/assets/{index-CFOw7tWS.js → index-DBLC9vCJ.js} +1 -1
  48. package/dist/assets/{index-D42PKeAo.js → index-DHYVY3Bq.js} +1 -1
  49. package/dist/assets/{index-YQXRLoVL.js → index-DrY2LoBX.js} +1 -1
  50. package/dist/assets/{index-CjcufnQY.js → index-DuJJkBba.js} +1 -1
  51. package/dist/assets/{index-BNMU0DUr.js → index-ITLfbYgx.js} +1 -1
  52. package/dist/assets/{index-qyF0HH0t.js → index-MvqJWvoO.js} +1 -1
  53. package/dist/assets/{index-BNGi9a78.js → index-U9BN8IFT.js} +1 -1
  54. package/dist/assets/{index-C3pJ0CeY.js → index-W0j_QNs_.js} +1 -1
  55. package/dist/assets/{index-DPzHTlTo.js → index-bfQMiA8o.js} +1 -1
  56. package/dist/assets/{index-BWtniMl1.js → index-lzDrXIqE.js} +1 -1
  57. package/dist/assets/{index-xOkwbA9z.js → index-oJIMvEL1.js} +1 -1
  58. package/dist/assets/{index-CHtpNrAW.js → index-qAF5sGRO.js} +4 -4
  59. package/dist/assets/{index-C9bDcLJk.js → index-ultzcMfl.js} +1 -1
  60. package/dist/assets/{index-SV9JUpu6.js → index-vQiKHr5F.js} +1 -1
  61. package/dist/assets/{index.es-DnF4r6Dk.js → index.es-Cbmre-3y.js} +1 -1
  62. package/dist/assets/{insert-business-trip-modal-CQv_ZpxL.js → insert-business-trip-modal-_imZNOPq.js} +1 -1
  63. package/dist/assets/issue-document-BbxmF4sT.js +1 -0
  64. package/dist/assets/{list-plus-DsfXaxO5.js → list-plus-DEqGGtBU.js} +1 -1
  65. package/dist/assets/{login-page-DKeixPVN.js → login-page-CUSymIR_.js} +1 -1
  66. package/dist/assets/{match-document-modal-LhAEyv1y.js → match-document-modal-CQ8I-zEU.js} +1 -1
  67. package/dist/assets/{missing-info-charges-DCVKrfEr.js → missing-info-charges-CFt2F-LA.js} +1 -1
  68. package/dist/assets/{modal-YTgF-R03.js → modal-D_KAAYCr.js} +1 -1
  69. package/dist/assets/{modify-contract-dialog-D7Z8bOws.js → modify-contract-dialog-DSwRl9du.js} +1 -1
  70. package/dist/assets/{page-layout-Cs7LzhPs.js → page-layout-7iCtDTzs.js} +1 -1
  71. package/dist/assets/{page-not-found-Cs086tZP.js → page-not-found-CsSbBsPd.js} +1 -1
  72. package/dist/assets/{panel-top-open-DfXV4xoB.js → panel-top-open-CVvVnpDH.js} +1 -1
  73. package/dist/assets/{pencil-3H1z0dQ2.js → pencil-CpYjq1NY.js} +1 -1
  74. package/dist/assets/{report-commentary-row-DNTsFgf_.js → report-commentary-row-CgmMnDJu.js} +1 -1
  75. package/dist/assets/{save-D2KnX2aJ.js → save-C6S-RD-9.js} +1 -1
  76. package/dist/assets/{similar-transactions-modal-DN6pAqBR.js → similar-transactions-modal-Dn4dMAAO.js} +1 -1
  77. package/dist/assets/{sub-UiWBdxTZ.js → sub-DgacWlyb.js} +1 -1
  78. package/dist/assets/subMonths-oKYDpkY2.js +1 -0
  79. package/dist/assets/{summary-DLRjO19t.js → summary-ZTGFg2Jz.js} +1 -1
  80. package/dist/assets/{toggle-expansion-button-ByfnT_sn.js → toggle-expansion-button-DYABrNZG.js} +1 -1
  81. package/dist/assets/tooltip-Br1wJ5zm.js +1 -0
  82. package/dist/assets/{use-url-query-DMunwqS4.js → use-url-query-CYeryni6.js} +1 -1
  83. package/dist/index.html +1 -1
  84. package/package.json +1 -1
  85. package/src/components/business/admin/financial-account-section.tsx +2 -0
  86. package/src/components/financial-accounts/financial-account-card.tsx +4 -0
  87. package/src/components/financial-accounts/modify-financial-account-dialog.tsx +19 -0
  88. package/src/components/financial-accounts/types.ts +1 -0
  89. package/src/gql/gql.ts +3 -3
  90. package/src/gql/graphql.ts +5 -2
  91. package/dist/assets/charge-ChPubJah.js +0 -1
  92. package/dist/assets/issue-document-DJMGPj2s.js +0 -1
  93. package/dist/assets/subMonths-DZvdAXT7.js +0 -1
  94. package/dist/assets/tooltip-0-bix6mQ.js +0 -1
@@ -1 +1 @@
1
- import{v as ve,bt as Ye,ce as Ze,r as p,bu as Ke,cf as ie,aF as Xe,bv as Qe,cg as Je,ch as es,j as e,B as v,L as Se,g as B,ci as ss,t as j,i as S,H as Ie,u as ne,cj as ge,bz as b,bC as q,ck as ae,cl as Ne,aC as ts,bA as U,bB as W,w as M,ay as Fe,cm as Me,l as L,T as w,a3 as G,y as N,n as C,V as I,Y as z,Z as P,_ as X,$,I as Q,a1 as _,b3 as ze,cn as Y,d as Z,co as ns,cp as rs,cq as is,bq as D,cr as as,bT as Pe,cs as $e,G as A,ai as be,R as ye,ct as os,ah as J,e as ee,cu as cs,cv as ds,cw as ls,cx as us,by as Oe,cy as hs,cz as ps,cA as xs,cB as Re,cC as ms,cD as gs,cE as js,cF as fs,cG as vs,cH as bs,at as je,cI as ys,cJ as Ts,cK as Es,cL as Cs,cM as As,cN as ws,cO as Ds,cP as Bs,cQ as Ss,cR as Is,cS as Ns,cT as Fs,cU as Ms,cV as zs,cW as Ps,cX as $s,cY as Os,cZ as Rs,c_ as ks,q as Hs,c$ as _s,d0 as Vs,d1 as Ls,d2 as Us,d3 as Ws,d4 as fe,d5 as qs,d6 as Gs}from"./index-CHtpNrAW.js";import{L as ke}from"./list-plus-DsfXaxO5.js";import{G as te,L as xe,C as He,R as Ys,A as E,S as Zs}from"./summary-DLRjO19t.js";import{T as se}from"./Table-bhKB4PFK.js";import{T as Ks}from"./toggle-expansion-button-ByfnT_sn.js";import{M as _e}from"./MultiSelect-DY08OexD.js";import{u as Xs,S as Qs}from"./similar-transactions-modal-DN6pAqBR.js";import{T as Js}from"./tooltip-0-bix6mQ.js";const et=[["path",{d:"M19 17h2c.6 0 1-.4 1-1v-3c0-.9-.7-1.7-1.5-1.9C18.7 10.6 16 10 16 10s-1.3-1.4-2.2-2.3c-.5-.4-1.1-.7-1.8-.7H5c-.6 0-1.1.4-1.4.9l-1.4 2.9A3.7 3.7 0 0 0 2 12v4c0 .6.4 1 1 1h2",key:"5owen"}],["circle",{cx:"7",cy:"17",r:"2",key:"u2ysq9"}],["path",{d:"M9 17h6",key:"r8uit2"}],["circle",{cx:"17",cy:"17",r:"2",key:"axvx0g"}]],st=ve("car",et);const tt=[["path",{d:"M14 13h2a2 2 0 0 1 2 2v2a2 2 0 0 0 4 0v-6.998a2 2 0 0 0-.59-1.42L18 5",key:"1wtuz0"}],["path",{d:"M14 21V5a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v16",key:"e09ifn"}],["path",{d:"M2 21h13",key:"1x0fut"}],["path",{d:"M3 9h11",key:"1p7c0w"}]],nt=ve("fuel",tt);const rt=[["path",{d:"M6 18H4a2 2 0 0 1-2-2v-5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v5a2 2 0 0 1-2 2h-2",key:"143wyd"}],["path",{d:"M6 9V3a1 1 0 0 1 1-1h10a1 1 0 0 1 1 1v6",key:"1itne7"}],["rect",{x:"6",y:"14",width:"12",height:"8",rx:"1",key:"1ue0tg"}]],it=ve("printer",rt);var at=Ye((i,{fluid:n,sizes:r},{size:t})=>({root:{paddingLeft:i.spacing.md,paddingRight:i.spacing.md,maxWidth:n?"100%":Ze({size:t,sizes:r}),marginLeft:"auto",marginRight:"auto"}})),ot=Object.defineProperty,me=Object.getOwnPropertySymbols,Ve=Object.prototype.hasOwnProperty,Le=Object.prototype.propertyIsEnumerable,Te=(i,n,r)=>n in i?ot(i,n,{enumerable:!0,configurable:!0,writable:!0,value:r}):i[n]=r,ct=(i,n)=>{for(var r in n||(n={}))Ve.call(n,r)&&Te(i,r,n[r]);if(me)for(var r of me(n))Le.call(n,r)&&Te(i,r,n[r]);return i},dt=(i,n)=>{var r={};for(var t in i)Ve.call(i,t)&&n.indexOf(t)<0&&(r[t]=i[t]);if(i!=null&&me)for(var t of me(i))n.indexOf(t)<0&&Le.call(i,t)&&(r[t]=i[t]);return r};const lt={sizes:{xs:ie(540),sm:ie(720),md:ie(960),lg:ie(1140),xl:ie(1320)}},ut=p.forwardRef((i,n)=>{const r=Ke("Container",lt,i),{className:t,fluid:s,size:a,unstyled:o,sizes:d,variant:x}=r,m=dt(r,["className","fluid","size","unstyled","sizes","variant"]),{classes:h,cx:l}=at({fluid:s,sizes:d},{unstyled:o,name:"Container",variant:x,size:a});return Xe.createElement(Qe,ct({className:l(h.root,t),ref:n},m))});ut.displayName="@mantine/core/Container";var H=3.77952755906,he={method:"save",resolution:3,page:{margin:0,format:"A4",orientation:"portrait"},canvas:{mimeType:"image/jpeg",qualityRatio:1,useCORS:!0,logging:!1},overrides:{}},ht=class{pdf;canvas;options;constructor(i,n){this.canvas=i,this.options=n,this.pdf=new es({format:this.options.page.format,orientation:this.options.page.orientation,...this.options.overrides?.pdf,unit:"mm"})}getMarginTopMM(){const i=typeof this.options.page.margin=="object"?this.options.page.margin.top:this.options.page.margin;return Number(i)}getMarginLeftMM(){const i=typeof this.options.page.margin=="object"?this.options.page.margin.left:this.options.page.margin;return Number(i)}getMarginRightMM(){const i=typeof this.options.page.margin=="object"?this.options.page.margin.right:this.options.page.margin;return Number(i)}getMarginBottomMM(){const i=typeof this.options.page.margin=="object"?this.options.page.margin.bottom:this.options.page.margin;return Number(i)}getMarginTop(){return this.getMarginTopMM()*H}getMarginBottom(){return this.getMarginBottomMM()*H}getMarginLeft(){return this.getMarginLeftMM()*H}getMarginRight(){return this.getMarginRightMM()*H}getScale(){return this.options.resolution}getPageHeight(){return this.getPageHeightMM()*H}getPageHeightMM(){return this.pdf.internal.pageSize.height}getPageWidthMM(){return this.pdf.internal.pageSize.width}getPageWidth(){return this.getPageWidthMM()*H}getOriginalCanvasWidth(){return this.canvas.width/this.getScale()}getOriginalCanvasHeight(){return this.canvas.height/this.getScale()}getCanvasPageAvailableHeight(){return this.getPageAvailableHeight()*this.getScale()*this.getHorizontalFitFactor()}getPageAvailableWidth(){return this.getPageWidth()-(this.getMarginLeft()+this.getMarginRight())}getPageAvailableHeight(){return this.getPageHeight()-(this.getMarginTop()+this.getMarginBottom())}getPageAvailableWidthMM(){return this.getPageAvailableWidth()/H}getPageAvailableHeightMM(){return this.getPageAvailableHeight()/H}getNumberPages(){return Math.ceil(this.canvas.height/this.getCanvasPageAvailableHeight())}getHorizontalFitFactor(){return this.getPageAvailableWidth()<this.getOriginalCanvasWidth()?this.getOriginalCanvasWidth()/this.getPageAvailableWidth():1}getCanvasOffsetY(i){return this.getCanvasPageAvailableHeight()*(i-1)}getCanvasHeightLeft(i){return this.canvas.height-this.getCanvasOffsetY(i)}getCanvasPageHeight(i){if(this.canvas.height<this.getCanvasPageAvailableHeight())return this.canvas.height;const n=this.getCanvasHeightLeft(i);return n<this.getCanvasPageAvailableHeight()?n:this.getCanvasPageAvailableHeight()}getCanvasPageWidth(){return this.canvas.width}createCanvasPage(i){const n=this.getCanvasPageWidth(),r=this.getCanvasPageHeight(i),t=document.createElement("canvas");return t.setAttribute("width",String(n)),t.setAttribute("height",String(r)),t.getContext("2d").drawImage(this.canvas,0,this.getCanvasOffsetY(i),this.canvas.width,r,0,0,this.canvas.width,r),t}convert(){let i=1;const n=this.getNumberPages();for(;i<=n;){i>1&&this.pdf.addPage(this.options.page.format,this.options.page.orientation);const r=this.createCanvasPage(i),t=r.toDataURL(this.options.canvas.mimeType,this.options.canvas.qualityRatio);this.pdf.setPage(i),this.pdf.addImage({imageData:t,width:r.width/(this.getScale()*H*this.getHorizontalFitFactor()),height:r.height/(this.getScale()*H*this.getHorizontalFitFactor()),x:this.getMarginLeftMM(),y:this.getMarginTopMM()}),i+=1}return this.pdf}},pt=i=>i?{...he,...i,canvas:{...he.canvas,...i.canvas},page:{...he.page,...i.page}}:he,xt=i=>typeof i=="function"?i():i?.current,mt=async(i,n)=>{const r=pt(n),t=xt(i);if(!t){console.error("Unable to get the target element.");return}const s=await Je(t,{useCORS:r.canvas.useCORS,logging:r.canvas.logging,scale:r.resolution,...r.overrides?.canvas}),o=new ht(s,r).convert();switch(r.method){case"build":return o;case"open":return window.open(o.output("bloburl"),"_blank"),o;case"save":default:{const d=r.filename??`${new Date().getTime()}.pdf`;return await o.save(d,{returnPromise:!0}),o}}},gt=mt;const jt={method:"open",overrides:{pdf:{compress:!0}}},ft=()=>document.getElementById("main-page"),Hn=({filename:i})=>{const[n,r]=p.useState(!1),t=async()=>{r(!0),await gt(ft,{...jt,filename:i}),r(!1)};return e.jsx(v,{variant:"outline",size:"icon",className:"size-7.5",onClick:t,disabled:n,children:n?e.jsx(Se,{className:"h-10 w-10 animate-spin mr-2 self-center"}):e.jsx(it,{className:"size-5"})})},vt="addBusinessTripAccommodationsExpense",bt=()=>{const[{fetching:i},n]=B(ss),r=p.useCallback(async t=>{const s="Error adding business trip accommodations expense",a=vt;j.loading("Adding Business Trip Accommodations Expense",{id:a});try{const o=await n(t),d=S(o,s,a);if(d)return j.success("Success",{id:a,description:"Business trip accommodations expense added"}),d.addBusinessTripAccommodationsExpense}catch(o){console.error(`${s}: ${o}`),j.error("Error",{id:a,description:s,duration:1e5,closeButton:!0})}},[n]);return{fetching:i,addBusinessTripAccommodationsExpense:r}};function Ue({formManager:i,attendeesStayPath:n,attendeesData:r,fetchingAttendees:t=!1,businessTripId:s}){const{control:a,watch:o,trigger:d}=i,{fields:x,append:m,remove:h}=Ie({control:a,name:n}),[l,c]=p.useState(t),[u,g]=p.useState(r??[]),f=o(n),T=x.map((F,R)=>({...F,...f[R]}));p.useEffect(()=>{r&&g(r)},[r]),p.useEffect(()=>{c(t)},[t]);const[{data:y,fetching:O},K]=ne({query:ge,pause:!0,variables:{businessTripId:s??""}});return p.useEffect(()=>{if(y?.businessTrip?.attendees.length){const F=y.businessTrip.attendees.map(R=>({value:R.id,label:R.name}))??[];g(F)}},[y?.businessTrip?.attendees]),p.useEffect(()=>{c(O)},[O]),p.useEffect(()=>{!r&&!y&&!t&&!O&&K({businessTripId:s})},[r,t,O,K,s,y]),!s&&!r?e.jsx("div",{children:"Cannot edit attendees stay, lacking some mandatory information!"}):e.jsxs("div",{children:[e.jsx("span",{className:"mantine-InputWrapper-label mantine-Select-label",children:"Employees Stay"}),e.jsxs("div",{className:"h-full flex flex-col overflow-hidden",children:[T?.map((F,R)=>e.jsxs("div",{className:"flex items-end gap-2 text-gray-600 mb-2",children:[e.jsx("div",{className:"w-full mt-1 relative rounded-md shadow-xs",children:e.jsx(b,{name:`${n}.${R}.attendeeId`,control:a,rules:{required:"Required"},render:({field:k,fieldState:re})=>e.jsx(q,{...k,disabled:l,data:u,value:k.value??void 0,label:"Attendee",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:re.error?.message,withinPortal:!0,required:!0})})}),e.jsx("div",{className:"w-full mt-1 relative rounded-md shadow-xs",children:e.jsx(b,{control:a,name:`${n}.${R}.nightsCount`,render:({field:k,fieldState:re})=>e.jsx(ae,{className:"w-full",...k,min:0,label:"Nights Count",value:k.value??void 0,hideControls:!0,precision:0,error:re.error?.message,required:!0,onChange:V=>k.onChange(V&&typeof V=="number"?V:void 0)})})}),e.jsx(v,{variant:"ghost",size:"icon",className:"mb-2 size-7.5",onClick:()=>{h(R),d(n)},children:e.jsx(Ne,{className:"size-5"})})]},F.id)),e.jsx(v,{variant:"ghost",size:"icon",className:"size-7.5",onClick:()=>{m({}),d(n)},children:e.jsx(ke,{className:"size-5"})})]})]})}function oe({businessTripId:i,control:n,setFetching:r}){const[t,s]=p.useState([]),[{data:a,fetching:o,error:d}]=ne({query:ge,variables:{businessTripId:i}}),{userContext:x}=p.useContext(ts);p.useEffect(()=>{a?.businessTrip?.attendees.length&&s(a.businessTrip.attendees.map(h=>({value:h.id,label:h.name})).sort((h,l)=>h.label>l.label?1:-1))},[a,s]),p.useEffect(()=>{r(o)},[r,o]),p.useEffect(()=>{d&&j.error("Error",{description:"Oops, we have an error fetching attendees"})},[d]);const m=p.useMemo(()=>x?.context.ledgerLock,[x]);return e.jsxs(e.Fragment,{children:[e.jsx(b,{name:"date",control:n,rules:{min:m?{value:m,message:`Date must be after ${m}`}:void 0,pattern:{value:U,message:"Date must be im format yyyy-mm-dd"}},render:({field:h,fieldState:l})=>e.jsx(W,{"data-autofocus":!0,...h,onChange:c=>{const u=c?typeof c=="string"?c:M(c,"yyyy-MM-dd"):void 0;u!==h.value&&h.onChange(u)},value:h.value?new Date(h.value):void 0,error:l.error?.message,label:"Date",popoverProps:{withinPortal:!0}})}),e.jsx(b,{name:"valueDate",control:n,rules:{pattern:{value:U,message:"Date must be im format yyyy-mm-dd"},min:m?{value:m,message:`Date must be after ${m}`}:void 0},render:({field:h,fieldState:l})=>e.jsx(W,{...h,onChange:c=>{const u=c?typeof c=="string"?c:M(c,"yyyy-MM-dd"):void 0;u!==h.value&&h.onChange(u)},value:h.value?new Date(h.value):void 0,error:l.error?.message,label:"Value Date",popoverProps:{withinPortal:!0}})}),e.jsx(b,{name:"amount",control:n,render:({field:h,fieldState:l})=>e.jsx(b,{name:"currency",control:n,defaultValue:Fe.Ils,render:({field:c,fieldState:u})=>e.jsx(Me,{...h,value:h.value??void 0,error:l.error?.message||u.error?.message,label:"Amount",currencyCodeProps:{...c,label:"Currency"}})})}),e.jsx(b,{name:"employeeBusinessId",control:n,render:({field:h,fieldState:l})=>e.jsx(q,{...h,data:t,value:h.value,disabled:o,label:"Attendee",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:l.error?.message,withinPortal:!0})})]})}function Ee(i){const{businessTripId:n,onAdd:r}=i,[t,{close:s,open:a}]=L(!1);return e.jsxs(e.Fragment,{children:[e.jsx(w,{label:"Add Accommodations Expense",children:e.jsx(v,{variant:"outline",size:"icon",className:"size-7.5",onClick:o=>{o.stopPropagation(),a()},children:e.jsx(G,{className:"size-5"})})}),t&&e.jsx(yt,{businessTripId:n,opened:t,close:s,onAdd:r})]})}function yt({businessTripId:i,opened:n,close:r,onAdd:t}){const s=N({defaultValues:{businessTripId:i}}),{control:a,handleSubmit:o}=s,[d,x]=p.useState(!1),{addBusinessTripAccommodationsExpense:m,fetching:h}=bt(),l=c=>{m({fields:c}).then(()=>{t?.(),r()})};return e.jsxs(C,{opened:n,onClose:r,centered:!0,lockScroll:!0,children:[e.jsx(C.Title,{children:"Add Accommodation Expense"}),e.jsx(C.Body,{children:e.jsx(I,{...s,children:e.jsxs("form",{onSubmit:o(l),className:"space-y-3",children:[e.jsx(oe,{businessTripId:i,control:a,setFetching:x}),e.jsx(z,{control:a,name:"country",render:({field:c})=>e.jsxs(P,{children:[e.jsx(X,{children:"Country"}),e.jsx($,{children:e.jsx(Q,{...c,value:c.value??void 0})}),e.jsx(_,{})]})}),e.jsx(z,{name:"nightsCount",control:a,render:({field:c})=>e.jsxs(P,{children:[e.jsx(X,{children:"Nights Count"}),e.jsx($,{children:e.jsx(ze,{...c,value:c.value??void 0,hideControls:!0,decimalScale:0,thousandSeparator:","})}),e.jsx(_,{})]})}),e.jsx(Ue,{formManager:s,attendeesStayPath:"attendeesStay",businessTripId:i}),e.jsx("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:"Add"})})]})})}),(h||d)&&e.jsx(Y,{blur:1,center:!0,children:e.jsx(Z,{})})]})}const Tt="updateBusinessTripAccommodationsExpense",Et=()=>{const[{fetching:i},n]=B(ns),r=p.useCallback(async t=>{const s="Error updating business trip accommodations expense",a=Tt;j.loading("Updating trip accommodations expense",{id:a});try{const o=await n(t),d=S(o,s,a);if(d)return j.success("Success",{id:a,description:"Business trip accommodations expense was updated"}),d.updateBusinessTripAccommodationsExpense}catch(o){console.error(`${s}: ${o}`),j.error("Error",{id:a,description:s,duration:1e5,closeButton:!0})}},[n]);return{fetching:i,updateBusinessTripAccommodationsExpense:r}},Ct="categorizeIntoExistingBusinessTripExpense",At=()=>{const[{fetching:i},n]=B(rs),r=p.useCallback(async t=>{const s="Error updating business trip expense category",a=Ct;j.loading("Updating business trip expense category",{id:a});try{const o=await n(t),d=S(o,s,a);if(d)return j.success("Success",{id:a,description:"Business trip expense category was updated"}),d.categorizeIntoExistingBusinessTripExpense}catch(o){console.error(`${s}: ${o}`),j.error("Error",{id:a,description:s,duration:1e5,closeButton:!0})}},[n]);return{fetching:i,categorizeIntoExistingBusinessTripExpense:r}};function ce(i){const{businessTripExpenseId:n,businessTripId:r,onChange:t}=i,[s,{close:a,open:o}]=L(!1);return e.jsxs(e.Fragment,{children:[e.jsx(w,{label:"Attach Uncategorized Transaction",children:e.jsx(v,{variant:"outline",size:"icon",className:"size-7.5",onClick:d=>{d.stopPropagation(),o()},children:e.jsx(G,{className:"size-5"})})}),s&&e.jsx(wt,{businessTripExpenseId:n,businessTripId:r,opened:s,close:a,onChange:t})]})}function wt({businessTripExpenseId:i,businessTripId:n,opened:r,close:t,onChange:s}){const{control:a,handleSubmit:o,setValue:d}=N({defaultValues:{businessTripExpenseId:i}}),[x,m]=p.useState([]),[{data:h,fetching:l,error:c}]=ne({query:is,variables:{businessTripId:n}}),{categorizeIntoExistingBusinessTripExpense:u,fetching:g}=At(),f=T=>{u({fields:T}).then(()=>{s?.(),t()})};return p.useEffect(()=>{if(h?.businessTrip?.uncategorizedTransactions.length){const T=h.businessTrip.uncategorizedTransactions.filter(y=>y?.transaction);m(T.map(({transaction:y})=>({eventDate:y.eventDate,sourceDescription:y.sourceDescription,referenceKey:y.referenceKey,counterparty:y.counterparty?.name,amount:y.amount.formatted,rawAmount:y.amount.raw,value:y.id,label:`${y.eventDate} | ${y.counterparty?.name} | ${y.amount.formatted}`})).sort((y,O)=>y.eventDate.localeCompare(O.eventDate)))}},[h,m]),p.useEffect(()=>{c&&j.error("Error",{description:"Oops, we have an error fetching transactions to categorize"})},[c]),e.jsxs(C,{opened:r,onClose:t,centered:!0,children:[e.jsx(C.Title,{children:"Set Transaction Category"}),e.jsx(C.Body,{children:e.jsxs("form",{onSubmit:o(f),className:"flex flex-col gap-3 mt-3",children:[e.jsx(b,{name:"transactionId",control:a,render:({field:T,fieldState:y})=>e.jsx(q,{...T,itemComponent:Dt,data:x??[],disabled:l,label:"Transactions",placeholder:"Scroll to see all options",maxDropdownHeight:160,error:y.error?.message,withAsterisk:!0,withinPortal:!0,onChange:O=>{const K=x.find(F=>F.value===O);K?.rawAmount&&d("amount",K.rawAmount),T.onChange(O)}})}),e.jsx(b,{name:"amount",control:a,render:({field:T,fieldState:y})=>e.jsx(ae,{...T,value:T.value??void 0,hideControls:!0,precision:2,removeTrailingZeros:!0,error:y.error?.message,label:"Amount"})}),e.jsx("div",{className:"flex justify-center 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:"Confirm"})})]})}),g&&e.jsx(Y,{blur:1,center:!0,children:e.jsx(Z,{})})]})}const Dt=p.forwardRef(({eventDate:i,sourceDescription:n,referenceKey:r,counterparty:t,amount:s,...a},o)=>e.jsx("div",{ref:o,...a,children:e.jsxs(te,{children:[e.jsx(te.Col,{span:4,children:i}),e.jsx(te.Col,{span:4,children:e.jsx(D,{size:"sm",children:t})}),e.jsx(te.Col,{span:4,children:e.jsx(D,{size:"sm",children:s})}),e.jsx(te.Col,{span:8,children:e.jsx(D,{size:"xs",opacity:.65,children:n})}),e.jsxs(te.Col,{span:4,children:["Reference: ",r]})]})})),Bt="deleteBusinessTripExpense",St=()=>{const[{fetching:i},n]=B(as),r=p.useCallback(async t=>{const s="Error deleting business trip expense",a=`${Bt}-${t.businessTripExpenseId}`;j.loading("Deleting trip expense",{id:a});try{const o=await n(t),d=S(o,s,a);if(d)return j.success("Success",{id:a,description:"Business trip expense was deleted"}),d.deleteBusinessTripExpense}catch(o){console.error(`${s}: ${o}`),j.error("Error",{id:a,description:s,duration:1e5,closeButton:!0})}},[n]);return{fetching:i,deleteBusinessTripExpense:r}};function de(i){const{fetching:n,deleteBusinessTripExpense:r}=St(),t=p.useCallback(()=>{r({businessTripExpenseId:i.businessTripExpenseId}).then(()=>{i.onDelete?.()})},[i,r]);return e.jsx(Pe,{onConfirm:t,title:"Are you sure you want to remove expense?",children:e.jsx(w,{label:"Remove Expense",children:e.jsx(v,{variant:"outline",size:"icon",className:"size-7.5 text-red-500",disabled:n,children:e.jsx($e,{className:"size-5"})})})})}const le=({data:i,isEditMode:n=!1,control:r,businessTripId:t})=>{const s=A(os,i),[a,o]=p.useState([]),[{data:d,fetching:x,error:m}]=ne({query:ge,variables:{businessTripId:t}});p.useEffect(()=>{d?.businessTrip?.attendees.length&&o(d.businessTrip.attendees.map(l=>({value:l.id,label:l.name})).sort((l,c)=>l.label>c.label?1:-1))},[d,o]),p.useEffect(()=>{m&&j.error("Error",{description:"Oops, we have an error fetching attendees"})},[m]);const h=Array.from(new Set(s.charges?.map(l=>l.id)));return e.jsxs(e.Fragment,{children:[e.jsx("td",{children:e.jsx("div",{className:"flex flex-col gap-2 justify-center",children:n&&s.payedByEmployee?e.jsxs(e.Fragment,{children:[e.jsx(b,{name:"date",control:r,defaultValue:s.date,rules:{pattern:{value:U,message:"Date must be im format yyyy-mm-dd"}},render:({field:l,fieldState:c})=>e.jsx(W,{...l,form:`form ${s.id}`,"data-autofocus":!0,onChange:u=>{const g=u?typeof u=="string"?u:M(u,"yyyy-MM-dd"):void 0;g!==l.value&&l.onChange(g)},value:l.value?new Date(l.value):void 0,label:"Date",error:c.error?.message,popoverProps:{withinPortal:!0}})}),e.jsx(b,{name:"valueDate",control:r,defaultValue:s.valueDate,rules:{pattern:{value:U,message:"Date must be im format yyyy-mm-dd"}},render:({field:l,fieldState:c})=>e.jsx(W,{...l,form:`form ${s.id}`,onChange:u=>{const g=u?typeof u=="string"?u:M(u,"yyyy-MM-dd"):void 0;g!==l.value&&l.onChange(g)},value:l.value?new Date(l.value):void 0,label:"Value Date",error:c.error?.message,popoverProps:{withinPortal:!0}})})]}):e.jsxs(e.Fragment,{children:[s.date&&M(new Date(s.date),"dd/MM/yy"),e.jsx(D,{fz:"sm",c:"dimmed",children:s.valueDate&&M(new Date(s.valueDate),"dd/MM/yy")})]})})}),e.jsx("td",{children:n&&s.payedByEmployee?e.jsx(b,{name:"amount",control:r,defaultValue:s.amount?.raw??void 0,render:({field:l,fieldState:c})=>e.jsx(b,{name:"currency",control:r,defaultValue:s.amount?.currency??Fe.Ils,render:({field:u,fieldState:g})=>e.jsx(Me,{form:`form ${s.id}`,...l,value:l.value??void 0,error:c.error?.message||g.error?.message,label:"Amount",currencyCodeProps:{...u,label:"Currency",form:`form ${s.id}`}})})}):e.jsx("div",{children:s.amount?.formatted})}),e.jsx("td",{children:e.jsx("div",{className:"flex flex-col gap-2 justify-center",children:n&&s.payedByEmployee?e.jsx(b,{name:"employeeBusinessId",control:r,defaultValue:s.employee?.id,render:({field:l,fieldState:c})=>e.jsx(q,{form:`form ${s.id}`,...l,data:a,value:l.value,disabled:x,label:"Attendee",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:c.error?.message,withinPortal:!0})}):e.jsx("div",{className:"flex flex-row gap-2 items-center",children:s.payedByEmployee&&e.jsx(D,{c:s.employee?.name?void 0:"red",children:s.employee?.name??"Missing"})})})}),e.jsx("td",{children:e.jsx("div",{className:"flex flex-col gap-2",children:h.map(l=>e.jsx(be,{to:ye.CHARGES.DETAIL(l),target:"_blank",rel:"noreferrer",onClick:c=>c.stopPropagation(),className:"inline-flex items-center font-semibold",children:"To Charge"},l))})})]})},ue=()=>e.jsxs(e.Fragment,{children:[e.jsx("th",{children:"Date"}),e.jsx("th",{children:"Amount"}),e.jsx("th",{children:"Payed By Attendee"}),e.jsx("th",{children:"Charges"})]}),It=({data:i,businessTripId:n,onChange:r})=>{const t=A(cs,i),[s,a]=p.useState(!1),o=N({defaultValues:{id:t.id,businessTripId:n,attendeesStay:t.attendeesStay.map(c=>({attendeeId:c.id,nightsCount:c.nightsCount}))}}),{control:d,handleSubmit:x}=o,{updateBusinessTripAccommodationsExpense:m,fetching:h}=Et(),l=c=>{m({fields:c}).then(()=>{r?.(),a(!1)})};return e.jsxs("tr",{children:[e.jsx(le,{data:t,isEditMode:s,control:d,businessTripId:n}),e.jsx("td",{children:e.jsx(I,{...o,children:e.jsx("form",{id:`form ${t.id}`,onSubmit:x(l),children:s?e.jsx(z,{name:"country",control:d,defaultValue:t.country,render:({field:c})=>e.jsxs(P,{children:[e.jsx($,{children:e.jsx(Q,{form:`form ${t.id}`,...c,value:c.value??void 0})}),e.jsx(_,{})]})}):e.jsx(D,{c:t.country?void 0:"red",children:t.country??"Missing"})})})}),e.jsx("td",{children:e.jsx("div",{className:"flex flex-col gap-2 justify-center",children:s?e.jsx(I,{...o,children:e.jsx(z,{name:"nightsCount",control:d,defaultValue:t.nightsCount,render:({field:c})=>e.jsxs(P,{children:[e.jsx($,{children:e.jsx(ze,{...c,value:c.value??void 0,form:`form ${t.id}`,hideControls:!0,decimalScale:0,thousandSeparator:","})}),e.jsx(_,{})]})})}):e.jsx(D,{c:t.nightsCount?void 0:"red",children:t.nightsCount??"Missing"})})}),e.jsx("td",{children:s?e.jsx(I,{...o,children:e.jsx(Ue,{formManager:o,attendeesStayPath:"attendeesStay",businessTripId:n})}):e.jsx(xe,{listStyleType:"disc",children:t.attendeesStay?.length?t.attendeesStay.map(c=>e.jsxs(xe.Item,{children:[c.attendee.name," (",c.nightsCount,")"]},c.id)):e.jsx(D,{c:"red",fz:"sm",children:"Missing"})})}),e.jsx("td",{children:r&&e.jsxs(e.Fragment,{children:[e.jsx(w,{label:"Edit",children:e.jsx(v,{disabled:h,variant:s?"default":"outline",size:"icon",className:"size-7.5",onClick:c=>{c.stopPropagation(),a(u=>!u)},children:e.jsx(J,{className:"size-5"})})}),s&&e.jsx(w,{label:"Confirm Changes",children:e.jsx(v,{type:"submit",form:`form ${t.id}`,variant:"outline",size:"icon",className:"size-7.5 text-green-500",children:e.jsx(ee,{className:"size-5"})})}),e.jsx(ce,{businessTripExpenseId:t.id,businessTripId:n,onChange:r}),e.jsx(de,{businessTripExpenseId:t.id,onDelete:r})]})})]},t.id)},We=({businessTripId:i,expenses:n,onChange:r})=>{if(!n?.length)return r?e.jsx(Ee,{businessTripId:i,onAdd:r}):e.jsx(e.Fragment,{});const t=n.map(s=>A(ds,s));return e.jsx("div",{className:"flex flex-col gap-2 mt-5",children:e.jsxs(se,{highlightOnHover:!0,withBorder:!0,children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx(ue,{}),e.jsx("th",{children:"Location"}),e.jsx("th",{children:"Nights"}),e.jsx("th",{children:"Attendees Stay"}),e.jsx("th",{})]})}),e.jsxs("tbody",{children:[t.sort((s,a)=>s.date&&a.date?s.date<a.date?1:-1:s.date?-1:a.date?1:0).map(s=>e.jsx(It,{data:s,businessTripId:i,onChange:r},s.id)),r&&e.jsx("tr",{children:e.jsx("td",{colSpan:6,children:e.jsx(Ee,{businessTripId:i,onAdd:r})})})]})]})})},Nt=({data:i,onChange:n})=>{const{accommodationExpenses:r,id:t}=A(ls,i);return e.jsx(We,{businessTripId:t,expenses:r,onChange:n})},Ft="insertBusinessTripAttendee",Mt=()=>{const[{fetching:i},n]=B(us),r=p.useCallback(async t=>{const s="Error adding attendee to business trip",a=Ft;j.loading("Adding attendee",{id:a});try{const o=await n(t),d=S(o,s,a);if(d)return j.success("Success",{id:a,description:"Attendee was added to the business trip"}),d.insertBusinessTripAttendee}catch(o){console.error(`${s}: ${o}`),j.error("Error",{id:a,description:s,duration:1e5,closeButton:!0})}},[n]);return{fetching:i,insertBusinessTripAttendee:r}};function Ce(i){const{businessTripId:n,onAdd:r}=i,[t,{close:s,open:a}]=L(!1);return e.jsxs(e.Fragment,{children:[e.jsx(w,{label:"Add Attendee",children:e.jsx(v,{variant:"outline",size:"icon",onClick:o=>{o.stopPropagation(),a()},className:"size-7.5",children:e.jsx(G,{className:"size-5"})})}),t&&e.jsx(zt,{businessTripId:n,opened:t,close:s,onAdd:r})]})}function zt({businessTripId:i,opened:n,close:r,onAdd:t}){const{selectableBusinesses:s,fetching:a}=Oe(),{control:o,handleSubmit:d}=N({defaultValues:{businessTripId:i}}),{insertBusinessTripAttendee:x,fetching:m}=Mt(),h=l=>{x({fields:l}).then(()=>{t?.(),r()})};return e.jsxs(C,{opened:n,onClose:r,centered:!0,children:[e.jsx(C.Title,{children:"Add Attendee"}),e.jsx(C.Body,{children:e.jsxs("form",{onSubmit:d(h),children:[e.jsx(b,{name:"attendeeId",control:o,render:({field:l,fieldState:c})=>e.jsx(q,{"data-autofocus":!0,...l,data:s,value:l.value,disabled:a,label:"Attendee",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:c.error?.message,withAsterisk:!0,withinPortal:!0})}),e.jsx(b,{name:"arrivalDate",control:o,rules:{pattern:{value:U,message:"Date must be im format yyyy-mm-dd"}},render:({field:l,fieldState:c})=>e.jsx(W,{...l,onChange:u=>{const g=u?typeof u=="string"?u:M(u,"yyyy-MM-dd"):void 0;g!==l.value&&l.onChange(g)},value:l.value?new Date(l.value):void 0,error:c.error?.message,label:"Arrival",popoverProps:{withinPortal:!0}})}),e.jsx(b,{name:"departureDate",control:o,rules:{pattern:{value:U,message:"Date must be im format yyyy-mm-dd"}},render:({field:l,fieldState:c})=>e.jsx(W,{...l,onChange:u=>{const g=u?typeof u=="string"?u:M(u,"yyyy-MM-dd"):void 0;g!==l.value&&l.onChange(g)},value:l.value?new Date(l.value):void 0,error:c.error?.message,label:"Departure",popoverProps:{withinPortal:!0}})}),e.jsx("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:"Add"})})]})}),(m||a)&&e.jsx(Y,{blur:1,center:!0,children:e.jsx(Z,{})})]})}const Pt="updateBusinessTripAttendee",$t=()=>{const[{fetching:i},n]=B(hs),r=p.useCallback(async t=>{const s="Error updating business trip attendee",a=Pt;j.loading("Updating trip attendee",{id:a});try{const o=await n(t),d=S(o,s,a);if(d)return j.success("Success",{id:a,description:"Business trip attendee was updated"}),d.updateBusinessTripAttendee}catch(o){console.error(`${s}: ${o}`),j.error("Error",{id:a,description:s,duration:1e5,closeButton:!0})}},[n]);return{fetching:i,updateBusinessTripAttendee:r}},Ot="deleteBusinessTripAttendee",Rt=()=>{const[{fetching:i},n]=B(ps),r=p.useCallback(async t=>{const s="Error removing business trip attendee",a=Ot;j.loading("Removing business trip attendee",{id:a});try{const o=await n(t),d=S(o,s,a);if(d)return j.success("Success",{id:a,description:"Business trip attendee was removed"}),d.deleteBusinessTripAttendee}catch(o){console.error(`${s}: ${o}`),j.error("Error",{id:a,description:s,duration:1e5,closeButton:!0})}},[n]);return{fetching:i,deleteBusinessTripAttendee:r}};function kt(i){const{fetching:n,deleteBusinessTripAttendee:r}=Rt(),t=p.useCallback(()=>{r({fields:{businessTripId:i.businessTripId,attendeeId:i.attendeeId}}).then(()=>{i.onDelete?.()})},[i,r]);return e.jsx(Pe,{onConfirm:t,title:"Are you sure you want to remove attendee?",children:e.jsx(w,{label:"Remove Attendee",children:e.jsx(v,{variant:"outline",size:"icon",className:"size-7.5 text-red-500",disabled:n,children:e.jsx($e,{className:"size-5"})})})})}const Ht="addBusinessTripFlightsExpense",_t=()=>{const[{fetching:i},n]=B(xs),r=p.useCallback(async t=>{const s="Error adding business trip flight expense",a=Ht;j.loading("Adding business trip flight expense",{id:a});try{const o=await n(t),d=S(o,s,a);if(d)return j.success("Success",{id:a,description:"Business trip flight expense added"}),d.addBusinessTripFlightsExpense}catch(o){console.error(`${s}: ${o}`),j.error("Error",{id:a,description:s,duration:1e5,closeButton:!0})}},[n]);return{fetching:i,addBusinessTripFlightsExpense:r}};function qe({formManager:i,flightPathPath:n,flightPathData:r}){const{control:t,watch:s,trigger:a}=i,{fields:o,append:d,remove:x}=Ie({control:t,name:n}),m=s(n),h=o.map((l,c)=>({...l,...m[c]}));return r?e.jsxs("div",{children:[e.jsx("span",{className:"mantine-InputWrapper-label mantine-Select-label",children:"Flight Path"}),e.jsxs("div",{className:"h-full flex flex-col overflow-hidden",children:[h?.map((l,c)=>e.jsxs("div",{className:"flex items-end gap-2 text-gray-600 mb-2",children:[e.jsx("div",{className:"w-full mt-1 relative rounded-md shadow-xs",children:e.jsx(z,{name:`${n}.${c}`,control:t,rules:{required:"Required"},render:({field:u})=>e.jsxs(P,{children:[e.jsx($,{children:e.jsx(Q,{...u,value:u.value??void 0,placeholder:"Destination"})}),e.jsx(_,{})]})})}),e.jsx(v,{variant:"ghost",size:"icon",className:"mb-2 size-7.5",onClick:()=>{x(c),a(n)},children:e.jsx(Ne,{className:"size-5"})})]},l.id)),e.jsx(v,{variant:"ghost",size:"icon",className:"size-7.5",onClick:()=>{d(""),a(n)},children:e.jsx(ke,{className:"size-5"})})]})]}):e.jsx("div",{children:"Cannot edit flight path stay, lacking some mandatory information!"})}function Ae(i){const{businessTripId:n,onAdd:r}=i,[t,{close:s,open:a}]=L(!1);return e.jsxs(e.Fragment,{children:[e.jsx(w,{label:"Add Flight Expense",children:e.jsx(v,{variant:"outline",size:"icon",className:"size-7.5",onClick:o=>{o.stopPropagation(),a()},children:e.jsx(G,{className:"size-5"})})}),t&&e.jsx(Lt,{businessTripId:n,opened:t,close:s,onAdd:r})]})}const Vt=Object.entries(Re).map(([i,n])=>({value:n,label:i}));function Lt({businessTripId:i,opened:n,close:r,onAdd:t}){const s=N({defaultValues:{businessTripId:i}}),{control:a,handleSubmit:o}=s,[d,x]=p.useState(!1),[{data:m,fetching:h}]=ne({query:ge,variables:{businessTripId:i}}),{addBusinessTripFlightsExpense:l,fetching:c}=_t(),u=f=>{l({fields:f}).then(()=>{t?.(),r()})},g=m?.businessTrip?.attendees.map(f=>({value:f.id,label:f.name}))??[];return e.jsxs(C,{opened:n,onClose:r,centered:!0,lockScroll:!0,children:[e.jsx(C.Title,{children:"Add Flight Expense"}),e.jsx(C.Body,{children:e.jsx(I,{...s,children:e.jsxs("form",{onSubmit:o(u),children:[e.jsx(oe,{businessTripId:i,control:a,setFetching:x}),e.jsx(qe,{formManager:s,flightPathPath:"path"}),e.jsx(b,{name:"flightClass",control:a,render:({field:f,fieldState:T})=>e.jsx(q,{...f,data:Vt,value:f.value,label:"Flight Class",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:T.error?.message,withinPortal:!0})}),e.jsx(b,{name:"attendeeIds",control:a,render:({field:f,fieldState:T})=>e.jsx(_e,{...f,disabled:h,data:g,value:f.value??[],label:"Attendees",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:T.error?.message,withinPortal:!0})}),e.jsx("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:"Add"})})]})})}),(c||d)&&e.jsx(Y,{blur:1,center:!0,children:e.jsx(Z,{})})]})}const Ut="updateBusinessTripFlightsExpense",Wt=()=>{const[{fetching:i},n]=B(ms),r=p.useCallback(async t=>{const s="Error updating business trip flights expense",a=Ut;j.loading("Updating trip flights expense",{id:a});try{const o=await n(t),d=S(o,s,a);if(d)return j.success("Success",{id:a,description:"Business trip flights expense was updated"}),d.updateBusinessTripFlightsExpense}catch(o){console.error(`${s}: ${o}`),j.error("Error",{id:a,description:s,duration:1e5,closeButton:!0})}},[n]);return{fetching:i,updateBusinessTripFlightsExpense:r}},qt=Object.entries(Re).map(([i,n])=>({value:n,label:i})),Gt=({data:i,businessTripId:n,onChange:r,attendees:t})=>{const s=A(gs,i),[a,o]=p.useState(!1),d=N({defaultValues:{id:s.id,businessTripId:n,attendeeIds:s.attendees?.map(g=>g.id)??[],path:s.path??[]}}),{control:x,handleSubmit:m}=d,{updateBusinessTripFlightsExpense:h,fetching:l}=Wt(),c=g=>{h({fields:g}).then(()=>{r?.(),o(!1)})},u=t.map(g=>({value:g.id,label:g.name}));return e.jsxs("tr",{children:[e.jsx(le,{data:s,isEditMode:a,control:x,businessTripId:n}),e.jsx("td",{children:e.jsx(I,{...d,children:e.jsx("form",{id:`form ${s.id}`,onSubmit:m(c),children:e.jsxs("div",{className:"flex flex-col gap-2 justify-center",children:[a?e.jsx(qe,{formManager:d,flightPathPath:"path",flightPathData:s.path??void 0}):e.jsx("div",{className:"flex gap-2 items-center",children:s.path?.length?s.path.map((g,f)=>e.jsxs(e.Fragment,{children:[e.jsx(D,{fw:700,children:g},f),f<s.path.length-1&&(g===s.path[f+1]?" | ":" → ")]})):e.jsx(D,{fw:700,className:"flex gap-2 items-center",c:"red",children:"Missing"})}),a?e.jsx(b,{name:"flightClass",control:x,defaultValue:s.class??void 0,render:({field:g,fieldState:f})=>e.jsx(q,{form:`form ${s.id}`,"data-autofocus":!0,...g,data:qt,value:g.value,label:"Flight Class",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:f.error?.message,withinPortal:!0})}):e.jsx(D,{c:s.class?void 0:"red",fz:"sm",children:`Class: ${s.class??"Missing"}`})]})})})}),e.jsx("td",{children:a?e.jsx(b,{name:"attendeeIds",control:x,defaultValue:s.attendees?.map(g=>g.id)??void 0,render:({field:g,fieldState:f})=>e.jsx(_e,{...g,form:`form ${s.id}`,data:u,value:g.value??[],label:"Attendees",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:f.error?.message,withinPortal:!0})}):e.jsx(xe,{listStyleType:"disc",children:s.attendees?.length?s.attendees.map(g=>e.jsx(xe.Item,{children:g.name},g.id)):e.jsx(D,{c:"red",fz:"sm",children:"Missing"})})}),e.jsx("td",{children:r&&e.jsxs(e.Fragment,{children:[e.jsx(w,{label:"Edit",children:e.jsx(v,{disabled:l,variant:a?"default":"outline",size:"icon",className:"size-7.5",onClick:g=>{g.stopPropagation(),o(f=>!f)},children:e.jsx(J,{className:"size-5"})})}),a&&e.jsx(w,{label:"Confirm Changes",children:e.jsx(v,{type:"submit",form:`form ${s.id}`,variant:"outline",size:"icon",className:"size-7.5 text-green-500",children:e.jsx(ee,{className:"size-5"})})}),e.jsx(ce,{businessTripExpenseId:s.id,businessTripId:n,onChange:r}),e.jsx(de,{businessTripExpenseId:s.id,onDelete:r})]})})]},s.id)},Ge=({businessTripId:i,expenses:n,attendees:r,onChange:t})=>{if(!n?.length)return t?e.jsx(Ae,{businessTripId:i,onAdd:t}):e.jsx(e.Fragment,{});const s=n.map(a=>A(js,a));return e.jsx("div",{className:"flex flex-col gap-2 mt-5",children:e.jsxs(se,{highlightOnHover:!0,withBorder:!0,children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx(ue,{}),e.jsx("th",{children:"Flight"}),e.jsx("th",{children:"Attendees"}),e.jsx("th",{})]})}),e.jsxs("tbody",{children:[s.sort((a,o)=>a.date&&o.date?a.date<o.date?1:-1:a.date?-1:o.date?1:0).map(a=>e.jsx(Gt,{data:a,businessTripId:i,onChange:t,attendees:r},a.id)),t&&e.jsx("tr",{children:e.jsx("td",{colSpan:5,children:e.jsx(Ae,{businessTripId:i,onAdd:t})})})]})]})})},Yt=({data:i,businessTripId:n,onChange:r})=>{const t=A(fs,i),[s,a]=p.useState(!1),[o,d]=p.useState(!1),{control:x,handleSubmit:m}=N({defaultValues:{businessTripId:n,attendeeId:t.id,arrivalDate:t.arrivalDate,departureDate:t.departureDate}}),{updateBusinessTripAttendee:h,fetching:l}=$t(),c=u=>{h({fields:u}).then(()=>{r?.(),a(!1)})};return e.jsxs(e.Fragment,{children:[e.jsxs("tr",{children:[e.jsx("td",{children:t.name}),e.jsx("td",{children:s?e.jsx("form",{id:`form ${t.id}`,onSubmit:m(c),children:e.jsx(b,{name:"arrivalDate",control:x,defaultValue:t.arrivalDate,rules:{pattern:{value:U,message:"Date must be im format yyyy-mm-dd"}},render:({field:u,fieldState:g})=>e.jsx(W,{...u,onChange:f=>{const T=f?typeof f=="string"?f:M(f,"yyyy-MM-dd"):void 0;T!==u.value&&u.onChange(T)},"data-autofocus":!0,value:u.value?new Date(u.value):void 0,error:g.error?.message,label:"Arrival",popoverProps:{withinPortal:!0}})})}):t.arrivalDate}),e.jsx("td",{children:s?e.jsx(b,{name:"departureDate",control:x,defaultValue:t.departureDate,rules:{pattern:{value:U,message:"Date must be im format yyyy-mm-dd"}},render:({field:u,fieldState:g})=>e.jsx(W,{...u,onChange:f=>{const T=f?typeof f=="string"?f:M(f,"yyyy-MM-dd"):void 0;T!==u.value&&u.onChange(T)},value:u.value?new Date(u.value):void 0,error:g.error?.message,label:"Departure",popoverProps:{withinPortal:!0}})}):t.departureDate}),e.jsxs("td",{className:"flex items-center gap-2",children:[e.jsx(w,{label:"Edit",children:e.jsx(v,{disabled:l,variant:s?"default":"outline",size:"icon",className:"size-7.5",onClick:u=>{u.stopPropagation(),a(g=>!g)},children:e.jsx(J,{className:"size-5"})})}),s&&e.jsx(w,{label:"Confirm Changes",children:e.jsx(v,{type:"submit",form:`form ${t.id}`,variant:"outline",size:"icon",className:"size-7.5 text-green-500",children:e.jsx(ee,{className:"size-5"})})}),e.jsx(kt,{businessTripId:n,attendeeId:t.id,onDelete:r}),e.jsx(Ks,{toggleExpansion:d,isExpanded:o})]})]},t.id),o&&e.jsx("tr",{children:e.jsx("td",{colSpan:4,children:e.jsx(He,{shadow:"sm",withBorder:!0,children:e.jsxs("div",{className:"flex flex-col gap-2",children:[t.flights&&e.jsxs(e.Fragment,{children:[e.jsx("div",{children:"Flights:"}),e.jsx(Ge,{businessTripId:n,attendees:[],expenses:t.flights})]}),t.accommodations&&e.jsxs(e.Fragment,{children:[e.jsx("div",{children:"Accommodations:"}),e.jsx(We,{businessTripId:n,expenses:t.accommodations})]})]})})})},`${t.id}-expension`)]})},Zt=({data:i,onChange:n})=>{const{attendees:r,id:t}=A(vs,i);return r?.length?e.jsx("div",{className:"flex flex-col gap-2 mt-5",children:e.jsxs(se,{highlightOnHover:!0,withBorder:!0,children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Name"}),e.jsx("th",{children:"Arrival Date"}),e.jsx("th",{children:"Departure Date"}),e.jsx("th",{})]})}),e.jsxs("tbody",{children:[r.sort((s,a)=>s.name.toLocaleLowerCase()>a.name.toLocaleLowerCase()?1:-1).map(s=>e.jsx(Yt,{data:s,businessTripId:t,onChange:n},s.id)),e.jsx("tr",{children:e.jsx("td",{colSpan:4,children:e.jsx(Ce,{businessTripId:t,onAdd:n})})})]})]})}):e.jsx(Ce,{businessTripId:t,onAdd:n})},pe="addBusinessTripCarRentalExpense",Kt=()=>{const[{fetching:i},n]=B(bs),r=p.useCallback(async t=>{const s="Error adding business trip car rental expense";j.loading("Adding car rental expense...",{id:pe});try{const a=await n(t),o=S(a,s,pe);if(o)return j.success("Success",{id:pe,description:"Car rental expense added"}),o.addBusinessTripCarRentalExpense}catch(a){console.error(`${s}: ${a}`),j.error("Error",{id:pe,description:s,duration:1e5,closeButton:!0})}},[n]);return{fetching:i,addBusinessTripCarRentalExpense:r}};function we(i){const{businessTripId:n,onAdd:r}=i,[t,{close:s,open:a}]=L(!1);return e.jsxs(e.Fragment,{children:[e.jsx(w,{label:"Add Car Rental Expense",children:e.jsx(v,{variant:"outline",size:"icon",onClick:o=>{o.stopPropagation(),a()},className:"size-7.5",children:e.jsx(G,{className:"size-5"})})}),t&&e.jsx(Xt,{businessTripId:n,opened:t,close:s,onAdd:r})]})}function Xt({businessTripId:i,opened:n,close:r,onAdd:t}){const s=N({defaultValues:{businessTripId:i}}),{control:a,handleSubmit:o}=s,[d,x]=p.useState(!1),{addBusinessTripCarRentalExpense:m,fetching:h}=Kt(),l=c=>{m({fields:c}).then(()=>{t?.(),r()})};return e.jsxs(C,{opened:n,onClose:r,centered:!0,lockScroll:!0,children:[e.jsx(C.Title,{children:"Add Car Rental Expense"}),e.jsx(C.Body,{children:e.jsx(I,{...s,children:e.jsxs("form",{onSubmit:o(l),children:[e.jsx(oe,{businessTripId:i,control:a,setFetching:x}),e.jsx(b,{name:"days",control:a,render:({field:c,fieldState:u})=>e.jsx(ae,{...c,value:c.value??void 0,hideControls:!0,precision:2,removeTrailingZeros:!0,error:u.error?.message,label:"Rent Days"})}),e.jsx(z,{name:"isFuelExpense",control:a,render:({field:{value:c,...u}})=>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(X,{children:"Is Fuel Expense"})}),e.jsx($,{children:e.jsx(je,{...u,checked:c===!0,onCheckedChange:u.onChange})}),e.jsx(_,{})]})}),e.jsx("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:"Add"})})]})})}),(h||d)&&e.jsx(Y,{blur:1,center:!0,children:e.jsx(Z,{})})]})}const Qt="updateBusinessTripCarRentalExpense",Jt=()=>{const[{fetching:i},n]=B(ys),r=p.useCallback(async t=>{const s="Error updating business trip car rental expense",a=Qt;j.loading("Updating trip car rental expense",{id:a});try{const o=await n(t),d=S(o,s,a);if(d)return j.success("Success",{id:a,description:"Business trip car rental expense was updated"}),d.updateBusinessTripCarRentalExpense}catch(o){console.error(`${s}: ${o}`),j.error("Error",{id:a,description:s,duration:1e5,closeButton:!0})}},[n]);return{fetching:i,updateBusinessTripCarRentalExpense:r}},en=({data:i,businessTripId:n,onChange:r})=>{const t=A(Ts,i),[s,a]=p.useState(!1),o=N({defaultValues:{id:t.id,businessTripId:n}}),{control:d,handleSubmit:x}=o,{updateBusinessTripCarRentalExpense:m,fetching:h}=Jt(),l=c=>{m({fields:c}).then(()=>{r?.(),a(!1)})};return e.jsxs("tr",{children:[e.jsx(le,{data:t,isEditMode:s,control:d,businessTripId:n}),e.jsx("td",{children:e.jsx(I,{...o,children:e.jsx("form",{id:`form ${t.id}`,onSubmit:x(l),children:e.jsx("div",{className:"flex flex-col gap-2 justify-center",children:t.isFuelExpense!==!0&&(s?e.jsx(b,{name:"days",control:d,defaultValue:t.days,render:({field:c,fieldState:u})=>e.jsx(ae,{...c,value:c.value??void 0,form:`form ${t.id}`,hideControls:!0,precision:2,removeTrailingZeros:!0,error:u.error?.message,placeholder:"Rent Days"})}):e.jsx(D,{c:t.days?void 0:"red",children:t.days??"Missing"}))})})})}),e.jsx("td",{children:s?e.jsx(I,{...o,children:e.jsx(z,{name:"isFuelExpense",control:d,defaultValue:t.isFuelExpense,render:({field:c})=>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(X,{children:"Is Fuel Expense"})}),e.jsx($,{children:e.jsx(je,{form:`form ${t.id}`,checked:c.value===!0,onCheckedChange:c.onChange})})]})})}):t.isFuelExpense===!0?e.jsx(nt,{}):e.jsx(st,{})}),e.jsxs("td",{children:[e.jsx(w,{label:"Edit",children:e.jsx(v,{disabled:h,variant:s?"default":"outline",size:"icon",className:"size-7.5",onClick:c=>{c.stopPropagation(),a(u=>!u)},children:e.jsx(J,{className:"size-5"})})}),s&&e.jsx(w,{label:"Confirm Changes",children:e.jsx(v,{type:"submit",form:`form ${t.id}`,variant:"outline",size:"icon",className:"size-7.5 text-green-500",children:e.jsx(ee,{className:"size-5"})})}),e.jsx(ce,{businessTripExpenseId:t.id,businessTripId:n,onChange:r}),e.jsx(de,{businessTripExpenseId:t.id,onDelete:r})]})]},t.id)},sn=({data:i,onChange:n})=>{const{carRentalExpenses:r,id:t}=A(Es,i);return r?.length?e.jsx("div",{className:"flex flex-col gap-2 mt-5",children:e.jsxs(se,{highlightOnHover:!0,withBorder:!0,children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx(ue,{}),e.jsx("th",{children:"Days"}),e.jsx("th",{children:"Type"}),e.jsx("th",{})]})}),e.jsxs("tbody",{children:[r.sort((s,a)=>s.date&&a.date?s.date<a.date?1:-1:s.date?-1:a.date?1:0).map(s=>e.jsx(en,{data:s,businessTripId:t,onChange:n},s.id)),e.jsx("tr",{children:e.jsx("td",{colSpan:6,children:e.jsx(we,{businessTripId:t,onAdd:n})})})]})]})}):e.jsx(we,{businessTripId:t,onAdd:n})},tn=({data:i,onChange:n})=>{const{flightExpenses:r,id:t,attendees:s}=A(Cs,i);return e.jsx(Ge,{businessTripId:t,attendees:s,expenses:r,onChange:n})},nn="addBusinessTripOtherExpense",rn=()=>{const[{fetching:i},n]=B(As),r=p.useCallback(async t=>{const s='Error adding business trip "other" expense',a=nn;j.loading('Adding trip "other" expense',{id:a});try{const o=await n(t),d=S(o,s,a);if(d)return j.success("Success",{id:a,description:'Business trip "other" expense was added'}),d.addBusinessTripOtherExpense}catch(o){console.error(`${s}: ${o}`),j.error("Error",{id:a,description:s,duration:1e5,closeButton:!0})}},[n]);return{fetching:i,addBusinessTripOtherExpense:r}};function De(i){const{businessTripId:n,onAdd:r}=i,[t,{close:s,open:a}]=L(!1);return e.jsxs(e.Fragment,{children:[e.jsx(w,{label:"Add Other Expense",children:e.jsx(v,{variant:"outline",size:"icon",className:"size-7.5",onClick:o=>{o.stopPropagation(),a()},children:e.jsx(G,{className:"size-5"})})}),t&&e.jsx(an,{businessTripId:n,opened:t,close:s,onAdd:r})]})}function an({businessTripId:i,opened:n,close:r,onAdd:t}){const s=N({defaultValues:{businessTripId:i}}),{control:a,handleSubmit:o}=s,[d,x]=p.useState(!1),{addBusinessTripOtherExpense:m,fetching:h}=rn(),l=c=>{m({fields:c}).then(()=>{t?.(),r()})};return e.jsxs(C,{opened:n,onClose:r,centered:!0,lockScroll:!0,children:[e.jsx(C.Title,{children:"Add Other Expense"}),e.jsx(C.Body,{children:e.jsx(I,{...s,children:e.jsxs("form",{onSubmit:o(l),className:"space-y-3",children:[e.jsx(oe,{businessTripId:i,control:a,setFetching:x}),e.jsx(z,{name:"description",control:a,render:({field:c})=>e.jsxs(P,{children:[e.jsx(X,{children:"Description"}),e.jsx($,{children:e.jsx(Q,{...c,value:c.value??void 0})}),e.jsx(_,{})]})}),e.jsx(z,{control:s.control,name:"deductibleExpense",render:({field:c})=>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(X,{children:"Deductible Expense"})}),e.jsx($,{children:e.jsx(je,{checked:c.value===!0,onCheckedChange:c.onChange})})]})}),e.jsx("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:"Add"})})]})})}),(h||d)&&e.jsx(Y,{blur:1,center:!0,children:e.jsx(Z,{})})]})}const on="updateBusinessTripOtherExpense",cn=()=>{const[{fetching:i},n]=B(ws),r=p.useCallback(async t=>{const s='Error updating business trip "other" expense',a=on;j.loading('Updating business trip "other" expense',{id:a});try{const o=await n(t),d=S(o,s,a);if(d)return j.success("Success",{id:a,description:'Business trip "other" expense was updated'}),d.updateBusinessTripOtherExpense}catch(o){console.error(`${s}: ${o}`),j.error("Error",{id:a,description:s,duration:1e5,closeButton:!0})}},[n]);return{fetching:i,updateBusinessTripOtherExpense:r}},dn=({data:i,businessTripId:n,onChange:r})=>{const t=A(Ds,i),[s,a]=p.useState(!1),o=N({defaultValues:{id:t.id,businessTripId:n}}),{control:d,handleSubmit:x}=o,{updateBusinessTripOtherExpense:m,fetching:h}=cn(),l=c=>{m({fields:c}).then(()=>{r?.(),a(!1)})};return e.jsxs("tr",{children:[e.jsx(le,{data:t,isEditMode:s,control:d,businessTripId:n}),e.jsx("td",{children:e.jsx(I,{...o,children:e.jsx("form",{id:`form ${t.id}`,onSubmit:x(l),children:s?e.jsx(z,{name:"description",control:d,defaultValue:t.description,render:({field:c})=>e.jsxs(P,{children:[e.jsx($,{children:e.jsx(Q,{form:`form ${t.id}`,...c,value:c.value??void 0})}),e.jsx(_,{})]})}):e.jsx(D,{c:t.description?void 0:"red",children:t.description??"Missing"})})})}),e.jsx("td",{children:e.jsx("div",{className:"flex flex-col gap-2 justify-center",children:s?e.jsx(I,{...o,children:e.jsx(z,{name:"deductibleExpense",control:o.control,defaultValue:t.deductibleExpense,render:({field:c})=>e.jsx(P,{children:e.jsx($,{children:e.jsx(je,{form:`form ${t.id}`,checked:c.value===!0,onCheckedChange:c.onChange})})})})}):e.jsx(D,{c:t.deductibleExpense?void 0:"red",children:t.deductibleExpense===!0?"Yes":t.deductibleExpense===!1?"No":"Missing"})})}),e.jsxs("td",{children:[e.jsx(w,{label:"Edit",children:e.jsx(v,{disabled:h,variant:s?"default":"outline",size:"icon",className:"size-7.5",onClick:c=>{c.stopPropagation(),a(u=>!u)},children:e.jsx(J,{className:"size-5"})})}),s&&e.jsx(w,{label:"Confirm Changes",children:e.jsx(v,{type:"submit",form:`form ${t.id}`,variant:"outline",size:"icon",className:"size-7.5 text-green-500",children:e.jsx(ee,{className:"size-5"})})}),e.jsx(ce,{businessTripExpenseId:t.id,businessTripId:n,onChange:r}),e.jsx(de,{businessTripExpenseId:t.id,onDelete:r})]})]},t.id)},ln=({data:i,onChange:n})=>{const{otherExpenses:r,id:t}=A(Bs,i);return r?.length?e.jsx("div",{className:"flex flex-col gap-2 mt-5",children:e.jsxs(se,{highlightOnHover:!0,withBorder:!0,children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx(ue,{}),e.jsx("th",{children:"Description"}),e.jsx("th",{children:"Deductible Expense"}),e.jsx("th",{})]})}),e.jsxs("tbody",{children:[r.sort((s,a)=>s.date&&a.date?s.date<a.date?1:-1:s.date?-1:a.date?1:0).map(s=>e.jsx(dn,{data:s,businessTripId:t,onChange:n},s.id)),e.jsx("tr",{children:e.jsx("td",{colSpan:6,children:e.jsx(De,{businessTripId:t,onAdd:n})})})]})]})}):e.jsx(De,{businessTripId:t,onAdd:n})},un="addBusinessTripTravelAndSubsistenceExpense",hn=()=>{const[{fetching:i},n]=B(Ss),r=p.useCallback(async t=>{const s="Error adding business trip travel&subsistence expense",a=un;j.loading("Adding trip travel&subsistence expense",{id:a});try{const o=await n(t),d=S(o,s,a);if(d)return j.success("Success",{id:a,description:"Business trip travel&subsistence expense was added"}),d.addBusinessTripTravelAndSubsistenceExpense}catch(o){console.error(`${s}: ${o}`),j.error("Error",{id:a,description:s,duration:1e5,closeButton:!0})}},[n]);return{fetching:i,addBusinessTripTravelAndSubsistenceExpense:r}};function Be(i){const{businessTripId:n,onAdd:r}=i,[t,{close:s,open:a}]=L(!1);return e.jsxs(e.Fragment,{children:[e.jsx(w,{label:"Add T&S Expense",children:e.jsx(v,{variant:"outline",size:"icon",className:"size-7.5",onClick:o=>{o.stopPropagation(),a()},children:e.jsx(G,{className:"size-5"})})}),t&&e.jsx(pn,{businessTripId:n,opened:t,close:s,onAdd:r})]})}function pn({businessTripId:i,opened:n,close:r,onAdd:t}){const s=N({defaultValues:{businessTripId:i}}),{control:a,handleSubmit:o}=s,[d,x]=p.useState(!1),{addBusinessTripTravelAndSubsistenceExpense:m,fetching:h}=hn(),l=c=>{m({fields:c}).then(()=>{t?.(),r()})};return e.jsxs(C,{opened:n,onClose:r,centered:!0,lockScroll:!0,children:[e.jsx(C.Title,{children:"Add Travel & Subsistence Expense"}),e.jsx(C.Body,{children:e.jsx(I,{...s,children:e.jsxs("form",{onSubmit:o(l),className:"space-y-3",children:[e.jsx(oe,{businessTripId:i,control:a,setFetching:x}),e.jsx(z,{name:"expenseType",control:a,render:({field:c})=>e.jsxs(P,{children:[e.jsx(X,{children:"Expense Type"}),e.jsx($,{children:e.jsx(Q,{...c,value:c.value??void 0})}),e.jsx(_,{})]})}),e.jsx("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:"Add"})})]})})}),(h||d)&&e.jsx(Y,{blur:1,center:!0,children:e.jsx(Z,{})})]})}const xn="updateBusinessTripTravelAndSubsistenceExpense",mn=()=>{const[{fetching:i},n]=B(Is),r=p.useCallback(async t=>{const s="Error updating business trip travel&subsistence expense",a=xn;j.loading("Updating trip travel&subsistence expense",{id:a});try{const o=await n(t),d=S(o,s,a);if(d)return j.success("Success",{id:a,description:"Business trip travel&subsistence expense was updated"}),d.updateBusinessTripTravelAndSubsistenceExpense}catch(o){console.error(`${s}: ${o}`),j.error("Error",{id:a,description:s,duration:1e5,closeButton:!0})}},[n]);return{fetching:i,updateBusinessTripTravelAndSubsistenceExpense:r}},gn=({data:i,businessTripId:n,onChange:r})=>{const t=A(Ns,i),[s,a]=p.useState(!1),o=N({defaultValues:{id:t.id,businessTripId:n}}),{control:d,handleSubmit:x}=o,{updateBusinessTripTravelAndSubsistenceExpense:m,fetching:h}=mn(),l=c=>{m({fields:c}).then(()=>{r?.(),a(!1)})};return e.jsxs("tr",{children:[e.jsx(le,{data:t,isEditMode:s,control:d,businessTripId:n}),e.jsx("td",{children:e.jsx(I,{...o,children:e.jsx("form",{id:`form ${t.id}`,onSubmit:x(l),children:s?e.jsx(z,{name:"expenseType",control:d,defaultValue:t.expenseType,render:({field:c})=>e.jsxs(P,{children:[e.jsx($,{children:e.jsx(Q,{form:`form ${t.id}`,...c,value:c.value??void 0})}),e.jsx(_,{})]})}):e.jsx(D,{c:t.expenseType?void 0:"red",children:t.expenseType??"Missing"})})})}),e.jsxs("td",{children:[e.jsx(w,{label:"Edit",children:e.jsx(v,{disabled:h,variant:s?"default":"outline",size:"icon",className:"size-7.5",onClick:c=>{c.stopPropagation(),a(u=>!u)},children:e.jsx(J,{className:"size-5"})})}),s&&e.jsx(w,{label:"Confirm Changes",children:e.jsx(v,{type:"submit",form:`form ${t.id}`,variant:"outline",size:"icon",className:"size-7.5 text-green-500",children:e.jsx(ee,{className:"size-5"})})}),e.jsx(ce,{businessTripExpenseId:t.id,businessTripId:n,onChange:r}),e.jsx(de,{businessTripExpenseId:t.id,onDelete:r})]})]},t.id)},jn=({data:i,onChange:n})=>{const{travelAndSubsistenceExpenses:r,id:t}=A(Fs,i);return r?.length?e.jsx("div",{className:"flex flex-col gap-2 mt-5",children:e.jsxs(se,{highlightOnHover:!0,withBorder:!0,children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx(ue,{}),e.jsx("th",{children:"Expense Type"}),e.jsx("th",{})]})}),e.jsxs("tbody",{children:[r.sort((s,a)=>s.date&&a.date?s.date<a.date?1:-1:s.date?-1:a.date?1:0).map(s=>e.jsx(gn,{data:s,businessTripId:t,onChange:n},s.id)),e.jsx("tr",{children:e.jsx("td",{colSpan:6,children:e.jsx(Be,{businessTripId:t,onAdd:n})})})]})]})}):e.jsx(Be,{businessTripId:t,onAdd:n})},fn=({data:i})=>{const n=A(Ms,i),r="effectiveDate"in n?n.effectiveDate:void 0;return e.jsx("td",{children:e.jsxs("div",{className:"flex flex-col justify-center",children:[e.jsx("div",{children:r&&M(new Date(r),"dd/MM/yy")}),n.sourceEffectiveDate&&e.jsxs("div",{className:"text-xs text-gray-500",children:["(Originally ",M(new Date(n.sourceEffectiveDate),"dd/MM/yy"),")"]})]})})},vn=({data:i})=>{const n=A(zs,i),r="eventDate"in n?n.eventDate:void 0;return e.jsx("td",{children:e.jsx("div",{className:"flex flex-col justify-center",children:r&&M(new Date(r),"dd/MM/yy")})})},bn=({data:i})=>{const n=A(Ps,i),{account:r}=n,t=r.type,s=r.name;return e.jsx("td",{children:e.jsxs("div",{className:"flex flex-col gap-2 items-center",children:[e.jsx("p",{children:t}),e.jsx("p",{children:s})]})})},yn=({data:i})=>{const n=A($s,i),r="sourceDescription"in n?n.sourceDescription:"Missing";return e.jsx("td",{children:e.jsx("div",{className:"flex flex-wrap",children:e.jsx("div",{className:"flex flex-col justify-center",children:r})})})},Tn=({data:i})=>{const n=A(Os,i);return e.jsx("td",{children:e.jsx("div",{className:"flex flex-wrap",children:e.jsx("div",{className:"flex flex-col justify-center",children:n.referenceKey})})})};function En({data:i,onChange:n,enableEdit:r}){const{id:t,counterparty:s,missingInfoSuggestions:a,id:o,sourceDescription:d}=A(Rs,i),x=!!a?.business&&r,m=x?a?.business?.name:"Missing",h=x?a?.business?.id:null,l=s?.name??m,[c,u]=p.useState(!1),{updateTransaction:g,fetching:f}=Xs(),T=p.useCallback(async V=>{await g({transactionId:o,fields:{counterpartyId:V}}),u(!0)},[o,g]),y=p.useCallback(async V=>{await T(V),n?.()},[T,n]),{selectableBusinesses:O,fetching:K}=Oe(),[F,R]=p.useState(h??null),[k,re]=p.useState(d);return e.jsxs("td",{children:[e.jsx("div",{className:"flex flex-wrap gap-1 items-center justify-center",children:s?.id?e.jsx(be,{to:ye.BUSINESSES.DETAIL(s.id),target:"_blank",rel:"noreferrer",onClick:V=>V.stopPropagation(),className:"inline-flex items-center font-semibold",children:l}):e.jsxs(e.Fragment,{children:[e.jsx(ks,{options:O,value:F,onChange:R,search:k,onSearchChange:re,placeholder:"Choose or create a business",empty:k?e.jsx(Hs,{description:k,onAdd:y}):null}),e.jsx(Js,{content:"Approve",children:e.jsx(v,{variant:"outline",size:"icon",onClick:()=>F&&T(F),disabled:f||K||!F,children:e.jsx(ee,{className:"size-4"})})})]})}),e.jsx(Qs,{transactionId:t,counterpartyId:s?.id??F,open:c,onOpenChange:u,onClose:n})]})}const Cn="categorizeBusinessTripExpense",An=()=>{const[{fetching:i},n]=B(_s),r=p.useCallback(async t=>{const s="Error updating business trip expense category",a=Cn;j.loading("Updating trip expense category",{id:a});try{const o=await n(t),d=S(o,s,a);if(d)return j.success("Success",{id:a,description:"Business trip expense category was updated"}),d.categorizeBusinessTripExpense}catch(o){console.error(`${s}: ${o}`),j.error("Error",{id:a,description:s,duration:1e5,closeButton:!0})}},[n]);return{fetching:i,categorizeBusinessTripExpense:r}};function wn(i){const{businessTripId:n,transactionId:r,onChange:t,defaultAmount:s}=i,[a,{close:o,open:d}]=L(!1);return e.jsxs(e.Fragment,{children:[e.jsx(w,{label:"Categorize",children:e.jsx(v,{variant:"outline",size:"icon",className:"size-7.5",onClick:x=>{x.stopPropagation(),d()},children:e.jsx(J,{className:"size-5"})})}),a&&e.jsx(Bn,{businessTripId:n,transactionId:r,opened:a,close:o,onChange:t,defaultAmount:s})]})}const Dn=Object.entries(Vs).map(([i,n])=>({value:n,label:i}));function Bn({businessTripId:i,transactionId:n,defaultAmount:r,opened:t,close:s,onChange:a}){const{control:o,handleSubmit:d}=N({defaultValues:{businessTripId:i,transactionId:n}}),{categorizeBusinessTripExpense:x,fetching:m}=An(),h=l=>{x({fields:l}).then(()=>{a?.(),s()})};return e.jsxs(C,{opened:t,onClose:s,centered:!0,children:[e.jsx(C.Title,{children:"Set Expense Category"}),e.jsx(C.Body,{children:e.jsxs("form",{onSubmit:d(h),className:"flex flex-col gap-3 mt-3",children:[e.jsx(b,{name:"category",control:o,render:({field:l,fieldState:c})=>e.jsx(q,{"data-autofocus":!0,...l,data:Dn,value:l.value,label:"Category",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:c.error?.message,withinPortal:!0})}),e.jsx(b,{name:"amount",control:o,defaultValue:r,render:({field:l,fieldState:c})=>e.jsx(ae,{...l,value:l.value??void 0,hideControls:!0,precision:2,removeTrailingZeros:!0,error:c.error?.message,label:"Amount"})}),e.jsx("div",{className:"flex justify-center 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:"Confirm"})})]})}),m&&e.jsx(Y,{blur:1,center:!0,children:e.jsx(Z,{})})]})}const Sn=({data:i,onChange:n})=>{const{uncategorizedTransactions:r,id:t}=A(Ls,i);return r?.length?e.jsx("div",{className:"flex flex-col gap-2 mt-5",children:e.jsxs(se,{highlightOnHover:!0,withBorder:!0,children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Event Date"}),e.jsx("th",{children:"Debit Date"}),e.jsx("th",{children:"Amount"}),e.jsx("th",{}),e.jsx("th",{children:"Account"}),e.jsx("th",{children:"Description"}),e.jsx("th",{children:"Reference#"}),e.jsx("th",{children:"Counterparty"}),e.jsx("th",{})]})}),e.jsx("tbody",{children:r.sort((s,a)=>s.transaction.eventDate.localeCompare(a.transaction.eventDate)).map(s=>e.jsxs("tr",{children:[e.jsx(vn,{data:s.transaction}),e.jsx(fn,{data:s.transaction}),e.jsx(In,{data:s}),e.jsx("td",{children:e.jsx(be,{to:ye.CHARGES.DETAIL(s.transaction.chargeId),target:"_blank",rel:"noreferrer",onClick:a=>a.stopPropagation(),className:"inline-flex items-center font-semibold",children:"To Charge"})}),e.jsx(bn,{data:s.transaction}),e.jsx(yn,{data:s.transaction}),e.jsx(Tn,{data:s.transaction}),e.jsx(En,{data:s.transaction}),e.jsx("td",{children:e.jsx(wn,{businessTripId:t,transactionId:s.transaction.id,onChange:n,defaultAmount:s.transaction.amount.raw})})]},s.transaction.id))})]})}):e.jsx(e.Fragment,{})},In=({data:i})=>{const{transaction:n,categorizedAmount:r,errors:t}=A(Us,i),s="amount"in n?n.amount:void 0,a=s?.raw!==r.raw&&r.raw!==0;return e.jsx("td",{children:e.jsxs("div",{className:"flex flex-col whitespace-nowrap",style:{color:Number(s?.raw)>0?"green":"red"},children:[e.jsxs("div",{className:"flex gap-1",children:[s?.formatted,t.length>0&&e.jsx(Nn,{errors:t})]}),a&&e.jsxs("div",{className:"text-gray-500 ml-2",children:[r.formatted," categorized "]}),n.cryptoExchangeRate&&e.jsxs("div",{className:"text-gray-500 ml-2",children:[`(Rate: ${n.cryptoExchangeRate.rate})`,e.jsx("br",{}),s?.raw?`${Ws(s.raw*n.cryptoExchangeRate.rate)}$`:null]})]})})},Nn=({errors:i})=>{const[n,{close:r,open:t}]=L(!1);return e.jsxs(fe,{width:200,position:"bottom",shadow:"md",opened:n,children:[e.jsx(fe.Target,{children:e.jsx(qs,{onMouseEnter:t,onMouseLeave:r})}),e.jsx(fe.Dropdown,{sx:{pointerEvents:"none"},className:"whitespace-normal text-red-500",children:i.map((s,a)=>e.jsx(D,{size:"sm",children:s},a))})]})};function _n({tripId:i,isExtended:n=!1}){const[r,t]=p.useState(),[s,a]=p.useState([]),[{data:o},d]=ne({query:Gs,variables:{businessTripId:i}});function x(h){s.includes(h)?a(l=>l.filter(c=>c!==h)):a(l=>[...l,h])}const m=d;return p.useEffect(()=>{o?.businessTrip&&t(o.businessTrip)},[o?.businessTrip]),e.jsx(He,{shadow:"sm",radius:"md",withBorder:!0,children:r?e.jsxs(e.Fragment,{children:[e.jsx(Ys,{data:r,onChange:m}),e.jsxs(E,{className:"w-full",multiple:!0,value:s,chevron:e.jsx(G,{size:"1rem"}),styles:{chevron:{"&[data-rotate]":{transform:"rotate(45deg)"}}},children:[e.jsxs(E.Item,{value:"attendees",children:[e.jsx(E.Control,{onClick:()=>x("attendees"),children:"Attendees"}),e.jsx(E.Panel,{children:e.jsx(Zt,{data:r,onChange:m})})]}),n&&e.jsxs(E.Item,{value:"uncategorized-transactions",children:[e.jsx(E.Control,{onClick:()=>x("uncategorized-transactions"),disabled:!r.uncategorizedTransactions?.length,children:"Uncategorized Transactions"}),e.jsx(E.Panel,{children:e.jsx(Sn,{data:r,onChange:m})})]}),e.jsxs(E.Item,{value:"flights",children:[e.jsx(E.Control,{onClick:()=>x("flights"),children:"Flights"}),e.jsx(E.Panel,{children:e.jsx(tn,{data:r,onChange:m})})]}),e.jsxs(E.Item,{value:"accommodations",children:[e.jsx(E.Control,{onClick:()=>x("accommodations"),children:"Accommodations"}),e.jsx(E.Panel,{children:e.jsx(Nt,{data:r,onChange:m})})]}),e.jsxs(E.Item,{value:"travelAndSubsistence",children:[e.jsx(E.Control,{onClick:()=>x("travelAndSubsistence"),children:"Travel & Subsistence"}),e.jsx(E.Panel,{children:e.jsx(jn,{data:r,onChange:m})})]}),e.jsxs(E.Item,{value:"other",children:[e.jsx(E.Control,{onClick:()=>x("other"),children:"Other"}),e.jsx(E.Panel,{children:e.jsx(ln,{data:r,onChange:m})})]}),e.jsxs(E.Item,{value:"carRental",children:[e.jsx(E.Control,{onClick:()=>x("carRental"),children:"Car Rental"}),e.jsx(E.Panel,{children:e.jsx(sn,{data:r,onChange:m})})]}),e.jsxs(E.Item,{value:"summary",children:[e.jsx(E.Control,{onClick:()=>x("summary"),children:"Summary"}),e.jsx(E.Panel,{children:e.jsx(Zs,{data:r})})]})]})]}):e.jsx(Se,{className:"h-10 w-10 animate-spin mr-2 self-center"})})}export{ut as C,_n as E,Hn as P};
1
+ import{v as ve,bt as Ye,ce as Ze,r as p,bu as Ke,cf as ie,aF as Xe,bv as Qe,cg as Je,ch as es,j as e,B as v,L as Se,g as B,ci as ss,t as j,i as S,H as Ie,u as ne,cj as ge,bz as b,bC as q,ck as ae,cl as Ne,aC as ts,bA as U,bB as W,w as M,ay as Fe,cm as Me,l as L,T as w,a3 as G,y as N,n as C,V as I,Y as z,Z as P,_ as X,$,I as Q,a1 as _,b3 as ze,cn as Y,d as Z,co as ns,cp as rs,cq as is,bq as D,cr as as,bT as Pe,cs as $e,G as A,ai as be,R as ye,ct as os,ah as J,e as ee,cu as cs,cv as ds,cw as ls,cx as us,by as Oe,cy as hs,cz as ps,cA as xs,cB as Re,cC as ms,cD as gs,cE as js,cF as fs,cG as vs,cH as bs,at as je,cI as ys,cJ as Ts,cK as Es,cL as Cs,cM as As,cN as ws,cO as Ds,cP as Bs,cQ as Ss,cR as Is,cS as Ns,cT as Fs,cU as Ms,cV as zs,cW as Ps,cX as $s,cY as Os,cZ as Rs,c_ as ks,q as Hs,c$ as _s,d0 as Vs,d1 as Ls,d2 as Us,d3 as Ws,d4 as fe,d5 as qs,d6 as Gs}from"./index-qAF5sGRO.js";import{L as ke}from"./list-plus-DEqGGtBU.js";import{G as te,L as xe,C as He,R as Ys,A as E,S as Zs}from"./summary-ZTGFg2Jz.js";import{T as se}from"./Table-C5b9rbOB.js";import{T as Ks}from"./toggle-expansion-button-DYABrNZG.js";import{M as _e}from"./MultiSelect-DRJD_QDr.js";import{u as Xs,S as Qs}from"./similar-transactions-modal-Dn4dMAAO.js";import{T as Js}from"./tooltip-Br1wJ5zm.js";const et=[["path",{d:"M19 17h2c.6 0 1-.4 1-1v-3c0-.9-.7-1.7-1.5-1.9C18.7 10.6 16 10 16 10s-1.3-1.4-2.2-2.3c-.5-.4-1.1-.7-1.8-.7H5c-.6 0-1.1.4-1.4.9l-1.4 2.9A3.7 3.7 0 0 0 2 12v4c0 .6.4 1 1 1h2",key:"5owen"}],["circle",{cx:"7",cy:"17",r:"2",key:"u2ysq9"}],["path",{d:"M9 17h6",key:"r8uit2"}],["circle",{cx:"17",cy:"17",r:"2",key:"axvx0g"}]],st=ve("car",et);const tt=[["path",{d:"M14 13h2a2 2 0 0 1 2 2v2a2 2 0 0 0 4 0v-6.998a2 2 0 0 0-.59-1.42L18 5",key:"1wtuz0"}],["path",{d:"M14 21V5a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v16",key:"e09ifn"}],["path",{d:"M2 21h13",key:"1x0fut"}],["path",{d:"M3 9h11",key:"1p7c0w"}]],nt=ve("fuel",tt);const rt=[["path",{d:"M6 18H4a2 2 0 0 1-2-2v-5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v5a2 2 0 0 1-2 2h-2",key:"143wyd"}],["path",{d:"M6 9V3a1 1 0 0 1 1-1h10a1 1 0 0 1 1 1v6",key:"1itne7"}],["rect",{x:"6",y:"14",width:"12",height:"8",rx:"1",key:"1ue0tg"}]],it=ve("printer",rt);var at=Ye((i,{fluid:n,sizes:r},{size:t})=>({root:{paddingLeft:i.spacing.md,paddingRight:i.spacing.md,maxWidth:n?"100%":Ze({size:t,sizes:r}),marginLeft:"auto",marginRight:"auto"}})),ot=Object.defineProperty,me=Object.getOwnPropertySymbols,Ve=Object.prototype.hasOwnProperty,Le=Object.prototype.propertyIsEnumerable,Te=(i,n,r)=>n in i?ot(i,n,{enumerable:!0,configurable:!0,writable:!0,value:r}):i[n]=r,ct=(i,n)=>{for(var r in n||(n={}))Ve.call(n,r)&&Te(i,r,n[r]);if(me)for(var r of me(n))Le.call(n,r)&&Te(i,r,n[r]);return i},dt=(i,n)=>{var r={};for(var t in i)Ve.call(i,t)&&n.indexOf(t)<0&&(r[t]=i[t]);if(i!=null&&me)for(var t of me(i))n.indexOf(t)<0&&Le.call(i,t)&&(r[t]=i[t]);return r};const lt={sizes:{xs:ie(540),sm:ie(720),md:ie(960),lg:ie(1140),xl:ie(1320)}},ut=p.forwardRef((i,n)=>{const r=Ke("Container",lt,i),{className:t,fluid:s,size:a,unstyled:o,sizes:d,variant:x}=r,m=dt(r,["className","fluid","size","unstyled","sizes","variant"]),{classes:h,cx:l}=at({fluid:s,sizes:d},{unstyled:o,name:"Container",variant:x,size:a});return Xe.createElement(Qe,ct({className:l(h.root,t),ref:n},m))});ut.displayName="@mantine/core/Container";var H=3.77952755906,he={method:"save",resolution:3,page:{margin:0,format:"A4",orientation:"portrait"},canvas:{mimeType:"image/jpeg",qualityRatio:1,useCORS:!0,logging:!1},overrides:{}},ht=class{pdf;canvas;options;constructor(i,n){this.canvas=i,this.options=n,this.pdf=new es({format:this.options.page.format,orientation:this.options.page.orientation,...this.options.overrides?.pdf,unit:"mm"})}getMarginTopMM(){const i=typeof this.options.page.margin=="object"?this.options.page.margin.top:this.options.page.margin;return Number(i)}getMarginLeftMM(){const i=typeof this.options.page.margin=="object"?this.options.page.margin.left:this.options.page.margin;return Number(i)}getMarginRightMM(){const i=typeof this.options.page.margin=="object"?this.options.page.margin.right:this.options.page.margin;return Number(i)}getMarginBottomMM(){const i=typeof this.options.page.margin=="object"?this.options.page.margin.bottom:this.options.page.margin;return Number(i)}getMarginTop(){return this.getMarginTopMM()*H}getMarginBottom(){return this.getMarginBottomMM()*H}getMarginLeft(){return this.getMarginLeftMM()*H}getMarginRight(){return this.getMarginRightMM()*H}getScale(){return this.options.resolution}getPageHeight(){return this.getPageHeightMM()*H}getPageHeightMM(){return this.pdf.internal.pageSize.height}getPageWidthMM(){return this.pdf.internal.pageSize.width}getPageWidth(){return this.getPageWidthMM()*H}getOriginalCanvasWidth(){return this.canvas.width/this.getScale()}getOriginalCanvasHeight(){return this.canvas.height/this.getScale()}getCanvasPageAvailableHeight(){return this.getPageAvailableHeight()*this.getScale()*this.getHorizontalFitFactor()}getPageAvailableWidth(){return this.getPageWidth()-(this.getMarginLeft()+this.getMarginRight())}getPageAvailableHeight(){return this.getPageHeight()-(this.getMarginTop()+this.getMarginBottom())}getPageAvailableWidthMM(){return this.getPageAvailableWidth()/H}getPageAvailableHeightMM(){return this.getPageAvailableHeight()/H}getNumberPages(){return Math.ceil(this.canvas.height/this.getCanvasPageAvailableHeight())}getHorizontalFitFactor(){return this.getPageAvailableWidth()<this.getOriginalCanvasWidth()?this.getOriginalCanvasWidth()/this.getPageAvailableWidth():1}getCanvasOffsetY(i){return this.getCanvasPageAvailableHeight()*(i-1)}getCanvasHeightLeft(i){return this.canvas.height-this.getCanvasOffsetY(i)}getCanvasPageHeight(i){if(this.canvas.height<this.getCanvasPageAvailableHeight())return this.canvas.height;const n=this.getCanvasHeightLeft(i);return n<this.getCanvasPageAvailableHeight()?n:this.getCanvasPageAvailableHeight()}getCanvasPageWidth(){return this.canvas.width}createCanvasPage(i){const n=this.getCanvasPageWidth(),r=this.getCanvasPageHeight(i),t=document.createElement("canvas");return t.setAttribute("width",String(n)),t.setAttribute("height",String(r)),t.getContext("2d").drawImage(this.canvas,0,this.getCanvasOffsetY(i),this.canvas.width,r,0,0,this.canvas.width,r),t}convert(){let i=1;const n=this.getNumberPages();for(;i<=n;){i>1&&this.pdf.addPage(this.options.page.format,this.options.page.orientation);const r=this.createCanvasPage(i),t=r.toDataURL(this.options.canvas.mimeType,this.options.canvas.qualityRatio);this.pdf.setPage(i),this.pdf.addImage({imageData:t,width:r.width/(this.getScale()*H*this.getHorizontalFitFactor()),height:r.height/(this.getScale()*H*this.getHorizontalFitFactor()),x:this.getMarginLeftMM(),y:this.getMarginTopMM()}),i+=1}return this.pdf}},pt=i=>i?{...he,...i,canvas:{...he.canvas,...i.canvas},page:{...he.page,...i.page}}:he,xt=i=>typeof i=="function"?i():i?.current,mt=async(i,n)=>{const r=pt(n),t=xt(i);if(!t){console.error("Unable to get the target element.");return}const s=await Je(t,{useCORS:r.canvas.useCORS,logging:r.canvas.logging,scale:r.resolution,...r.overrides?.canvas}),o=new ht(s,r).convert();switch(r.method){case"build":return o;case"open":return window.open(o.output("bloburl"),"_blank"),o;case"save":default:{const d=r.filename??`${new Date().getTime()}.pdf`;return await o.save(d,{returnPromise:!0}),o}}},gt=mt;const jt={method:"open",overrides:{pdf:{compress:!0}}},ft=()=>document.getElementById("main-page"),Hn=({filename:i})=>{const[n,r]=p.useState(!1),t=async()=>{r(!0),await gt(ft,{...jt,filename:i}),r(!1)};return e.jsx(v,{variant:"outline",size:"icon",className:"size-7.5",onClick:t,disabled:n,children:n?e.jsx(Se,{className:"h-10 w-10 animate-spin mr-2 self-center"}):e.jsx(it,{className:"size-5"})})},vt="addBusinessTripAccommodationsExpense",bt=()=>{const[{fetching:i},n]=B(ss),r=p.useCallback(async t=>{const s="Error adding business trip accommodations expense",a=vt;j.loading("Adding Business Trip Accommodations Expense",{id:a});try{const o=await n(t),d=S(o,s,a);if(d)return j.success("Success",{id:a,description:"Business trip accommodations expense added"}),d.addBusinessTripAccommodationsExpense}catch(o){console.error(`${s}: ${o}`),j.error("Error",{id:a,description:s,duration:1e5,closeButton:!0})}},[n]);return{fetching:i,addBusinessTripAccommodationsExpense:r}};function Ue({formManager:i,attendeesStayPath:n,attendeesData:r,fetchingAttendees:t=!1,businessTripId:s}){const{control:a,watch:o,trigger:d}=i,{fields:x,append:m,remove:h}=Ie({control:a,name:n}),[l,c]=p.useState(t),[u,g]=p.useState(r??[]),f=o(n),T=x.map((F,R)=>({...F,...f[R]}));p.useEffect(()=>{r&&g(r)},[r]),p.useEffect(()=>{c(t)},[t]);const[{data:y,fetching:O},K]=ne({query:ge,pause:!0,variables:{businessTripId:s??""}});return p.useEffect(()=>{if(y?.businessTrip?.attendees.length){const F=y.businessTrip.attendees.map(R=>({value:R.id,label:R.name}))??[];g(F)}},[y?.businessTrip?.attendees]),p.useEffect(()=>{c(O)},[O]),p.useEffect(()=>{!r&&!y&&!t&&!O&&K({businessTripId:s})},[r,t,O,K,s,y]),!s&&!r?e.jsx("div",{children:"Cannot edit attendees stay, lacking some mandatory information!"}):e.jsxs("div",{children:[e.jsx("span",{className:"mantine-InputWrapper-label mantine-Select-label",children:"Employees Stay"}),e.jsxs("div",{className:"h-full flex flex-col overflow-hidden",children:[T?.map((F,R)=>e.jsxs("div",{className:"flex items-end gap-2 text-gray-600 mb-2",children:[e.jsx("div",{className:"w-full mt-1 relative rounded-md shadow-xs",children:e.jsx(b,{name:`${n}.${R}.attendeeId`,control:a,rules:{required:"Required"},render:({field:k,fieldState:re})=>e.jsx(q,{...k,disabled:l,data:u,value:k.value??void 0,label:"Attendee",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:re.error?.message,withinPortal:!0,required:!0})})}),e.jsx("div",{className:"w-full mt-1 relative rounded-md shadow-xs",children:e.jsx(b,{control:a,name:`${n}.${R}.nightsCount`,render:({field:k,fieldState:re})=>e.jsx(ae,{className:"w-full",...k,min:0,label:"Nights Count",value:k.value??void 0,hideControls:!0,precision:0,error:re.error?.message,required:!0,onChange:V=>k.onChange(V&&typeof V=="number"?V:void 0)})})}),e.jsx(v,{variant:"ghost",size:"icon",className:"mb-2 size-7.5",onClick:()=>{h(R),d(n)},children:e.jsx(Ne,{className:"size-5"})})]},F.id)),e.jsx(v,{variant:"ghost",size:"icon",className:"size-7.5",onClick:()=>{m({}),d(n)},children:e.jsx(ke,{className:"size-5"})})]})]})}function oe({businessTripId:i,control:n,setFetching:r}){const[t,s]=p.useState([]),[{data:a,fetching:o,error:d}]=ne({query:ge,variables:{businessTripId:i}}),{userContext:x}=p.useContext(ts);p.useEffect(()=>{a?.businessTrip?.attendees.length&&s(a.businessTrip.attendees.map(h=>({value:h.id,label:h.name})).sort((h,l)=>h.label>l.label?1:-1))},[a,s]),p.useEffect(()=>{r(o)},[r,o]),p.useEffect(()=>{d&&j.error("Error",{description:"Oops, we have an error fetching attendees"})},[d]);const m=p.useMemo(()=>x?.context.ledgerLock,[x]);return e.jsxs(e.Fragment,{children:[e.jsx(b,{name:"date",control:n,rules:{min:m?{value:m,message:`Date must be after ${m}`}:void 0,pattern:{value:U,message:"Date must be im format yyyy-mm-dd"}},render:({field:h,fieldState:l})=>e.jsx(W,{"data-autofocus":!0,...h,onChange:c=>{const u=c?typeof c=="string"?c:M(c,"yyyy-MM-dd"):void 0;u!==h.value&&h.onChange(u)},value:h.value?new Date(h.value):void 0,error:l.error?.message,label:"Date",popoverProps:{withinPortal:!0}})}),e.jsx(b,{name:"valueDate",control:n,rules:{pattern:{value:U,message:"Date must be im format yyyy-mm-dd"},min:m?{value:m,message:`Date must be after ${m}`}:void 0},render:({field:h,fieldState:l})=>e.jsx(W,{...h,onChange:c=>{const u=c?typeof c=="string"?c:M(c,"yyyy-MM-dd"):void 0;u!==h.value&&h.onChange(u)},value:h.value?new Date(h.value):void 0,error:l.error?.message,label:"Value Date",popoverProps:{withinPortal:!0}})}),e.jsx(b,{name:"amount",control:n,render:({field:h,fieldState:l})=>e.jsx(b,{name:"currency",control:n,defaultValue:Fe.Ils,render:({field:c,fieldState:u})=>e.jsx(Me,{...h,value:h.value??void 0,error:l.error?.message||u.error?.message,label:"Amount",currencyCodeProps:{...c,label:"Currency"}})})}),e.jsx(b,{name:"employeeBusinessId",control:n,render:({field:h,fieldState:l})=>e.jsx(q,{...h,data:t,value:h.value,disabled:o,label:"Attendee",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:l.error?.message,withinPortal:!0})})]})}function Ee(i){const{businessTripId:n,onAdd:r}=i,[t,{close:s,open:a}]=L(!1);return e.jsxs(e.Fragment,{children:[e.jsx(w,{label:"Add Accommodations Expense",children:e.jsx(v,{variant:"outline",size:"icon",className:"size-7.5",onClick:o=>{o.stopPropagation(),a()},children:e.jsx(G,{className:"size-5"})})}),t&&e.jsx(yt,{businessTripId:n,opened:t,close:s,onAdd:r})]})}function yt({businessTripId:i,opened:n,close:r,onAdd:t}){const s=N({defaultValues:{businessTripId:i}}),{control:a,handleSubmit:o}=s,[d,x]=p.useState(!1),{addBusinessTripAccommodationsExpense:m,fetching:h}=bt(),l=c=>{m({fields:c}).then(()=>{t?.(),r()})};return e.jsxs(C,{opened:n,onClose:r,centered:!0,lockScroll:!0,children:[e.jsx(C.Title,{children:"Add Accommodation Expense"}),e.jsx(C.Body,{children:e.jsx(I,{...s,children:e.jsxs("form",{onSubmit:o(l),className:"space-y-3",children:[e.jsx(oe,{businessTripId:i,control:a,setFetching:x}),e.jsx(z,{control:a,name:"country",render:({field:c})=>e.jsxs(P,{children:[e.jsx(X,{children:"Country"}),e.jsx($,{children:e.jsx(Q,{...c,value:c.value??void 0})}),e.jsx(_,{})]})}),e.jsx(z,{name:"nightsCount",control:a,render:({field:c})=>e.jsxs(P,{children:[e.jsx(X,{children:"Nights Count"}),e.jsx($,{children:e.jsx(ze,{...c,value:c.value??void 0,hideControls:!0,decimalScale:0,thousandSeparator:","})}),e.jsx(_,{})]})}),e.jsx(Ue,{formManager:s,attendeesStayPath:"attendeesStay",businessTripId:i}),e.jsx("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:"Add"})})]})})}),(h||d)&&e.jsx(Y,{blur:1,center:!0,children:e.jsx(Z,{})})]})}const Tt="updateBusinessTripAccommodationsExpense",Et=()=>{const[{fetching:i},n]=B(ns),r=p.useCallback(async t=>{const s="Error updating business trip accommodations expense",a=Tt;j.loading("Updating trip accommodations expense",{id:a});try{const o=await n(t),d=S(o,s,a);if(d)return j.success("Success",{id:a,description:"Business trip accommodations expense was updated"}),d.updateBusinessTripAccommodationsExpense}catch(o){console.error(`${s}: ${o}`),j.error("Error",{id:a,description:s,duration:1e5,closeButton:!0})}},[n]);return{fetching:i,updateBusinessTripAccommodationsExpense:r}},Ct="categorizeIntoExistingBusinessTripExpense",At=()=>{const[{fetching:i},n]=B(rs),r=p.useCallback(async t=>{const s="Error updating business trip expense category",a=Ct;j.loading("Updating business trip expense category",{id:a});try{const o=await n(t),d=S(o,s,a);if(d)return j.success("Success",{id:a,description:"Business trip expense category was updated"}),d.categorizeIntoExistingBusinessTripExpense}catch(o){console.error(`${s}: ${o}`),j.error("Error",{id:a,description:s,duration:1e5,closeButton:!0})}},[n]);return{fetching:i,categorizeIntoExistingBusinessTripExpense:r}};function ce(i){const{businessTripExpenseId:n,businessTripId:r,onChange:t}=i,[s,{close:a,open:o}]=L(!1);return e.jsxs(e.Fragment,{children:[e.jsx(w,{label:"Attach Uncategorized Transaction",children:e.jsx(v,{variant:"outline",size:"icon",className:"size-7.5",onClick:d=>{d.stopPropagation(),o()},children:e.jsx(G,{className:"size-5"})})}),s&&e.jsx(wt,{businessTripExpenseId:n,businessTripId:r,opened:s,close:a,onChange:t})]})}function wt({businessTripExpenseId:i,businessTripId:n,opened:r,close:t,onChange:s}){const{control:a,handleSubmit:o,setValue:d}=N({defaultValues:{businessTripExpenseId:i}}),[x,m]=p.useState([]),[{data:h,fetching:l,error:c}]=ne({query:is,variables:{businessTripId:n}}),{categorizeIntoExistingBusinessTripExpense:u,fetching:g}=At(),f=T=>{u({fields:T}).then(()=>{s?.(),t()})};return p.useEffect(()=>{if(h?.businessTrip?.uncategorizedTransactions.length){const T=h.businessTrip.uncategorizedTransactions.filter(y=>y?.transaction);m(T.map(({transaction:y})=>({eventDate:y.eventDate,sourceDescription:y.sourceDescription,referenceKey:y.referenceKey,counterparty:y.counterparty?.name,amount:y.amount.formatted,rawAmount:y.amount.raw,value:y.id,label:`${y.eventDate} | ${y.counterparty?.name} | ${y.amount.formatted}`})).sort((y,O)=>y.eventDate.localeCompare(O.eventDate)))}},[h,m]),p.useEffect(()=>{c&&j.error("Error",{description:"Oops, we have an error fetching transactions to categorize"})},[c]),e.jsxs(C,{opened:r,onClose:t,centered:!0,children:[e.jsx(C.Title,{children:"Set Transaction Category"}),e.jsx(C.Body,{children:e.jsxs("form",{onSubmit:o(f),className:"flex flex-col gap-3 mt-3",children:[e.jsx(b,{name:"transactionId",control:a,render:({field:T,fieldState:y})=>e.jsx(q,{...T,itemComponent:Dt,data:x??[],disabled:l,label:"Transactions",placeholder:"Scroll to see all options",maxDropdownHeight:160,error:y.error?.message,withAsterisk:!0,withinPortal:!0,onChange:O=>{const K=x.find(F=>F.value===O);K?.rawAmount&&d("amount",K.rawAmount),T.onChange(O)}})}),e.jsx(b,{name:"amount",control:a,render:({field:T,fieldState:y})=>e.jsx(ae,{...T,value:T.value??void 0,hideControls:!0,precision:2,removeTrailingZeros:!0,error:y.error?.message,label:"Amount"})}),e.jsx("div",{className:"flex justify-center 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:"Confirm"})})]})}),g&&e.jsx(Y,{blur:1,center:!0,children:e.jsx(Z,{})})]})}const Dt=p.forwardRef(({eventDate:i,sourceDescription:n,referenceKey:r,counterparty:t,amount:s,...a},o)=>e.jsx("div",{ref:o,...a,children:e.jsxs(te,{children:[e.jsx(te.Col,{span:4,children:i}),e.jsx(te.Col,{span:4,children:e.jsx(D,{size:"sm",children:t})}),e.jsx(te.Col,{span:4,children:e.jsx(D,{size:"sm",children:s})}),e.jsx(te.Col,{span:8,children:e.jsx(D,{size:"xs",opacity:.65,children:n})}),e.jsxs(te.Col,{span:4,children:["Reference: ",r]})]})})),Bt="deleteBusinessTripExpense",St=()=>{const[{fetching:i},n]=B(as),r=p.useCallback(async t=>{const s="Error deleting business trip expense",a=`${Bt}-${t.businessTripExpenseId}`;j.loading("Deleting trip expense",{id:a});try{const o=await n(t),d=S(o,s,a);if(d)return j.success("Success",{id:a,description:"Business trip expense was deleted"}),d.deleteBusinessTripExpense}catch(o){console.error(`${s}: ${o}`),j.error("Error",{id:a,description:s,duration:1e5,closeButton:!0})}},[n]);return{fetching:i,deleteBusinessTripExpense:r}};function de(i){const{fetching:n,deleteBusinessTripExpense:r}=St(),t=p.useCallback(()=>{r({businessTripExpenseId:i.businessTripExpenseId}).then(()=>{i.onDelete?.()})},[i,r]);return e.jsx(Pe,{onConfirm:t,title:"Are you sure you want to remove expense?",children:e.jsx(w,{label:"Remove Expense",children:e.jsx(v,{variant:"outline",size:"icon",className:"size-7.5 text-red-500",disabled:n,children:e.jsx($e,{className:"size-5"})})})})}const le=({data:i,isEditMode:n=!1,control:r,businessTripId:t})=>{const s=A(os,i),[a,o]=p.useState([]),[{data:d,fetching:x,error:m}]=ne({query:ge,variables:{businessTripId:t}});p.useEffect(()=>{d?.businessTrip?.attendees.length&&o(d.businessTrip.attendees.map(l=>({value:l.id,label:l.name})).sort((l,c)=>l.label>c.label?1:-1))},[d,o]),p.useEffect(()=>{m&&j.error("Error",{description:"Oops, we have an error fetching attendees"})},[m]);const h=Array.from(new Set(s.charges?.map(l=>l.id)));return e.jsxs(e.Fragment,{children:[e.jsx("td",{children:e.jsx("div",{className:"flex flex-col gap-2 justify-center",children:n&&s.payedByEmployee?e.jsxs(e.Fragment,{children:[e.jsx(b,{name:"date",control:r,defaultValue:s.date,rules:{pattern:{value:U,message:"Date must be im format yyyy-mm-dd"}},render:({field:l,fieldState:c})=>e.jsx(W,{...l,form:`form ${s.id}`,"data-autofocus":!0,onChange:u=>{const g=u?typeof u=="string"?u:M(u,"yyyy-MM-dd"):void 0;g!==l.value&&l.onChange(g)},value:l.value?new Date(l.value):void 0,label:"Date",error:c.error?.message,popoverProps:{withinPortal:!0}})}),e.jsx(b,{name:"valueDate",control:r,defaultValue:s.valueDate,rules:{pattern:{value:U,message:"Date must be im format yyyy-mm-dd"}},render:({field:l,fieldState:c})=>e.jsx(W,{...l,form:`form ${s.id}`,onChange:u=>{const g=u?typeof u=="string"?u:M(u,"yyyy-MM-dd"):void 0;g!==l.value&&l.onChange(g)},value:l.value?new Date(l.value):void 0,label:"Value Date",error:c.error?.message,popoverProps:{withinPortal:!0}})})]}):e.jsxs(e.Fragment,{children:[s.date&&M(new Date(s.date),"dd/MM/yy"),e.jsx(D,{fz:"sm",c:"dimmed",children:s.valueDate&&M(new Date(s.valueDate),"dd/MM/yy")})]})})}),e.jsx("td",{children:n&&s.payedByEmployee?e.jsx(b,{name:"amount",control:r,defaultValue:s.amount?.raw??void 0,render:({field:l,fieldState:c})=>e.jsx(b,{name:"currency",control:r,defaultValue:s.amount?.currency??Fe.Ils,render:({field:u,fieldState:g})=>e.jsx(Me,{form:`form ${s.id}`,...l,value:l.value??void 0,error:c.error?.message||g.error?.message,label:"Amount",currencyCodeProps:{...u,label:"Currency",form:`form ${s.id}`}})})}):e.jsx("div",{children:s.amount?.formatted})}),e.jsx("td",{children:e.jsx("div",{className:"flex flex-col gap-2 justify-center",children:n&&s.payedByEmployee?e.jsx(b,{name:"employeeBusinessId",control:r,defaultValue:s.employee?.id,render:({field:l,fieldState:c})=>e.jsx(q,{form:`form ${s.id}`,...l,data:a,value:l.value,disabled:x,label:"Attendee",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:c.error?.message,withinPortal:!0})}):e.jsx("div",{className:"flex flex-row gap-2 items-center",children:s.payedByEmployee&&e.jsx(D,{c:s.employee?.name?void 0:"red",children:s.employee?.name??"Missing"})})})}),e.jsx("td",{children:e.jsx("div",{className:"flex flex-col gap-2",children:h.map(l=>e.jsx(be,{to:ye.CHARGES.DETAIL(l),target:"_blank",rel:"noreferrer",onClick:c=>c.stopPropagation(),className:"inline-flex items-center font-semibold",children:"To Charge"},l))})})]})},ue=()=>e.jsxs(e.Fragment,{children:[e.jsx("th",{children:"Date"}),e.jsx("th",{children:"Amount"}),e.jsx("th",{children:"Payed By Attendee"}),e.jsx("th",{children:"Charges"})]}),It=({data:i,businessTripId:n,onChange:r})=>{const t=A(cs,i),[s,a]=p.useState(!1),o=N({defaultValues:{id:t.id,businessTripId:n,attendeesStay:t.attendeesStay.map(c=>({attendeeId:c.id,nightsCount:c.nightsCount}))}}),{control:d,handleSubmit:x}=o,{updateBusinessTripAccommodationsExpense:m,fetching:h}=Et(),l=c=>{m({fields:c}).then(()=>{r?.(),a(!1)})};return e.jsxs("tr",{children:[e.jsx(le,{data:t,isEditMode:s,control:d,businessTripId:n}),e.jsx("td",{children:e.jsx(I,{...o,children:e.jsx("form",{id:`form ${t.id}`,onSubmit:x(l),children:s?e.jsx(z,{name:"country",control:d,defaultValue:t.country,render:({field:c})=>e.jsxs(P,{children:[e.jsx($,{children:e.jsx(Q,{form:`form ${t.id}`,...c,value:c.value??void 0})}),e.jsx(_,{})]})}):e.jsx(D,{c:t.country?void 0:"red",children:t.country??"Missing"})})})}),e.jsx("td",{children:e.jsx("div",{className:"flex flex-col gap-2 justify-center",children:s?e.jsx(I,{...o,children:e.jsx(z,{name:"nightsCount",control:d,defaultValue:t.nightsCount,render:({field:c})=>e.jsxs(P,{children:[e.jsx($,{children:e.jsx(ze,{...c,value:c.value??void 0,form:`form ${t.id}`,hideControls:!0,decimalScale:0,thousandSeparator:","})}),e.jsx(_,{})]})})}):e.jsx(D,{c:t.nightsCount?void 0:"red",children:t.nightsCount??"Missing"})})}),e.jsx("td",{children:s?e.jsx(I,{...o,children:e.jsx(Ue,{formManager:o,attendeesStayPath:"attendeesStay",businessTripId:n})}):e.jsx(xe,{listStyleType:"disc",children:t.attendeesStay?.length?t.attendeesStay.map(c=>e.jsxs(xe.Item,{children:[c.attendee.name," (",c.nightsCount,")"]},c.id)):e.jsx(D,{c:"red",fz:"sm",children:"Missing"})})}),e.jsx("td",{children:r&&e.jsxs(e.Fragment,{children:[e.jsx(w,{label:"Edit",children:e.jsx(v,{disabled:h,variant:s?"default":"outline",size:"icon",className:"size-7.5",onClick:c=>{c.stopPropagation(),a(u=>!u)},children:e.jsx(J,{className:"size-5"})})}),s&&e.jsx(w,{label:"Confirm Changes",children:e.jsx(v,{type:"submit",form:`form ${t.id}`,variant:"outline",size:"icon",className:"size-7.5 text-green-500",children:e.jsx(ee,{className:"size-5"})})}),e.jsx(ce,{businessTripExpenseId:t.id,businessTripId:n,onChange:r}),e.jsx(de,{businessTripExpenseId:t.id,onDelete:r})]})})]},t.id)},We=({businessTripId:i,expenses:n,onChange:r})=>{if(!n?.length)return r?e.jsx(Ee,{businessTripId:i,onAdd:r}):e.jsx(e.Fragment,{});const t=n.map(s=>A(ds,s));return e.jsx("div",{className:"flex flex-col gap-2 mt-5",children:e.jsxs(se,{highlightOnHover:!0,withBorder:!0,children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx(ue,{}),e.jsx("th",{children:"Location"}),e.jsx("th",{children:"Nights"}),e.jsx("th",{children:"Attendees Stay"}),e.jsx("th",{})]})}),e.jsxs("tbody",{children:[t.sort((s,a)=>s.date&&a.date?s.date<a.date?1:-1:s.date?-1:a.date?1:0).map(s=>e.jsx(It,{data:s,businessTripId:i,onChange:r},s.id)),r&&e.jsx("tr",{children:e.jsx("td",{colSpan:6,children:e.jsx(Ee,{businessTripId:i,onAdd:r})})})]})]})})},Nt=({data:i,onChange:n})=>{const{accommodationExpenses:r,id:t}=A(ls,i);return e.jsx(We,{businessTripId:t,expenses:r,onChange:n})},Ft="insertBusinessTripAttendee",Mt=()=>{const[{fetching:i},n]=B(us),r=p.useCallback(async t=>{const s="Error adding attendee to business trip",a=Ft;j.loading("Adding attendee",{id:a});try{const o=await n(t),d=S(o,s,a);if(d)return j.success("Success",{id:a,description:"Attendee was added to the business trip"}),d.insertBusinessTripAttendee}catch(o){console.error(`${s}: ${o}`),j.error("Error",{id:a,description:s,duration:1e5,closeButton:!0})}},[n]);return{fetching:i,insertBusinessTripAttendee:r}};function Ce(i){const{businessTripId:n,onAdd:r}=i,[t,{close:s,open:a}]=L(!1);return e.jsxs(e.Fragment,{children:[e.jsx(w,{label:"Add Attendee",children:e.jsx(v,{variant:"outline",size:"icon",onClick:o=>{o.stopPropagation(),a()},className:"size-7.5",children:e.jsx(G,{className:"size-5"})})}),t&&e.jsx(zt,{businessTripId:n,opened:t,close:s,onAdd:r})]})}function zt({businessTripId:i,opened:n,close:r,onAdd:t}){const{selectableBusinesses:s,fetching:a}=Oe(),{control:o,handleSubmit:d}=N({defaultValues:{businessTripId:i}}),{insertBusinessTripAttendee:x,fetching:m}=Mt(),h=l=>{x({fields:l}).then(()=>{t?.(),r()})};return e.jsxs(C,{opened:n,onClose:r,centered:!0,children:[e.jsx(C.Title,{children:"Add Attendee"}),e.jsx(C.Body,{children:e.jsxs("form",{onSubmit:d(h),children:[e.jsx(b,{name:"attendeeId",control:o,render:({field:l,fieldState:c})=>e.jsx(q,{"data-autofocus":!0,...l,data:s,value:l.value,disabled:a,label:"Attendee",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:c.error?.message,withAsterisk:!0,withinPortal:!0})}),e.jsx(b,{name:"arrivalDate",control:o,rules:{pattern:{value:U,message:"Date must be im format yyyy-mm-dd"}},render:({field:l,fieldState:c})=>e.jsx(W,{...l,onChange:u=>{const g=u?typeof u=="string"?u:M(u,"yyyy-MM-dd"):void 0;g!==l.value&&l.onChange(g)},value:l.value?new Date(l.value):void 0,error:c.error?.message,label:"Arrival",popoverProps:{withinPortal:!0}})}),e.jsx(b,{name:"departureDate",control:o,rules:{pattern:{value:U,message:"Date must be im format yyyy-mm-dd"}},render:({field:l,fieldState:c})=>e.jsx(W,{...l,onChange:u=>{const g=u?typeof u=="string"?u:M(u,"yyyy-MM-dd"):void 0;g!==l.value&&l.onChange(g)},value:l.value?new Date(l.value):void 0,error:c.error?.message,label:"Departure",popoverProps:{withinPortal:!0}})}),e.jsx("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:"Add"})})]})}),(m||a)&&e.jsx(Y,{blur:1,center:!0,children:e.jsx(Z,{})})]})}const Pt="updateBusinessTripAttendee",$t=()=>{const[{fetching:i},n]=B(hs),r=p.useCallback(async t=>{const s="Error updating business trip attendee",a=Pt;j.loading("Updating trip attendee",{id:a});try{const o=await n(t),d=S(o,s,a);if(d)return j.success("Success",{id:a,description:"Business trip attendee was updated"}),d.updateBusinessTripAttendee}catch(o){console.error(`${s}: ${o}`),j.error("Error",{id:a,description:s,duration:1e5,closeButton:!0})}},[n]);return{fetching:i,updateBusinessTripAttendee:r}},Ot="deleteBusinessTripAttendee",Rt=()=>{const[{fetching:i},n]=B(ps),r=p.useCallback(async t=>{const s="Error removing business trip attendee",a=Ot;j.loading("Removing business trip attendee",{id:a});try{const o=await n(t),d=S(o,s,a);if(d)return j.success("Success",{id:a,description:"Business trip attendee was removed"}),d.deleteBusinessTripAttendee}catch(o){console.error(`${s}: ${o}`),j.error("Error",{id:a,description:s,duration:1e5,closeButton:!0})}},[n]);return{fetching:i,deleteBusinessTripAttendee:r}};function kt(i){const{fetching:n,deleteBusinessTripAttendee:r}=Rt(),t=p.useCallback(()=>{r({fields:{businessTripId:i.businessTripId,attendeeId:i.attendeeId}}).then(()=>{i.onDelete?.()})},[i,r]);return e.jsx(Pe,{onConfirm:t,title:"Are you sure you want to remove attendee?",children:e.jsx(w,{label:"Remove Attendee",children:e.jsx(v,{variant:"outline",size:"icon",className:"size-7.5 text-red-500",disabled:n,children:e.jsx($e,{className:"size-5"})})})})}const Ht="addBusinessTripFlightsExpense",_t=()=>{const[{fetching:i},n]=B(xs),r=p.useCallback(async t=>{const s="Error adding business trip flight expense",a=Ht;j.loading("Adding business trip flight expense",{id:a});try{const o=await n(t),d=S(o,s,a);if(d)return j.success("Success",{id:a,description:"Business trip flight expense added"}),d.addBusinessTripFlightsExpense}catch(o){console.error(`${s}: ${o}`),j.error("Error",{id:a,description:s,duration:1e5,closeButton:!0})}},[n]);return{fetching:i,addBusinessTripFlightsExpense:r}};function qe({formManager:i,flightPathPath:n,flightPathData:r}){const{control:t,watch:s,trigger:a}=i,{fields:o,append:d,remove:x}=Ie({control:t,name:n}),m=s(n),h=o.map((l,c)=>({...l,...m[c]}));return r?e.jsxs("div",{children:[e.jsx("span",{className:"mantine-InputWrapper-label mantine-Select-label",children:"Flight Path"}),e.jsxs("div",{className:"h-full flex flex-col overflow-hidden",children:[h?.map((l,c)=>e.jsxs("div",{className:"flex items-end gap-2 text-gray-600 mb-2",children:[e.jsx("div",{className:"w-full mt-1 relative rounded-md shadow-xs",children:e.jsx(z,{name:`${n}.${c}`,control:t,rules:{required:"Required"},render:({field:u})=>e.jsxs(P,{children:[e.jsx($,{children:e.jsx(Q,{...u,value:u.value??void 0,placeholder:"Destination"})}),e.jsx(_,{})]})})}),e.jsx(v,{variant:"ghost",size:"icon",className:"mb-2 size-7.5",onClick:()=>{x(c),a(n)},children:e.jsx(Ne,{className:"size-5"})})]},l.id)),e.jsx(v,{variant:"ghost",size:"icon",className:"size-7.5",onClick:()=>{d(""),a(n)},children:e.jsx(ke,{className:"size-5"})})]})]}):e.jsx("div",{children:"Cannot edit flight path stay, lacking some mandatory information!"})}function Ae(i){const{businessTripId:n,onAdd:r}=i,[t,{close:s,open:a}]=L(!1);return e.jsxs(e.Fragment,{children:[e.jsx(w,{label:"Add Flight Expense",children:e.jsx(v,{variant:"outline",size:"icon",className:"size-7.5",onClick:o=>{o.stopPropagation(),a()},children:e.jsx(G,{className:"size-5"})})}),t&&e.jsx(Lt,{businessTripId:n,opened:t,close:s,onAdd:r})]})}const Vt=Object.entries(Re).map(([i,n])=>({value:n,label:i}));function Lt({businessTripId:i,opened:n,close:r,onAdd:t}){const s=N({defaultValues:{businessTripId:i}}),{control:a,handleSubmit:o}=s,[d,x]=p.useState(!1),[{data:m,fetching:h}]=ne({query:ge,variables:{businessTripId:i}}),{addBusinessTripFlightsExpense:l,fetching:c}=_t(),u=f=>{l({fields:f}).then(()=>{t?.(),r()})},g=m?.businessTrip?.attendees.map(f=>({value:f.id,label:f.name}))??[];return e.jsxs(C,{opened:n,onClose:r,centered:!0,lockScroll:!0,children:[e.jsx(C.Title,{children:"Add Flight Expense"}),e.jsx(C.Body,{children:e.jsx(I,{...s,children:e.jsxs("form",{onSubmit:o(u),children:[e.jsx(oe,{businessTripId:i,control:a,setFetching:x}),e.jsx(qe,{formManager:s,flightPathPath:"path"}),e.jsx(b,{name:"flightClass",control:a,render:({field:f,fieldState:T})=>e.jsx(q,{...f,data:Vt,value:f.value,label:"Flight Class",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:T.error?.message,withinPortal:!0})}),e.jsx(b,{name:"attendeeIds",control:a,render:({field:f,fieldState:T})=>e.jsx(_e,{...f,disabled:h,data:g,value:f.value??[],label:"Attendees",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:T.error?.message,withinPortal:!0})}),e.jsx("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:"Add"})})]})})}),(c||d)&&e.jsx(Y,{blur:1,center:!0,children:e.jsx(Z,{})})]})}const Ut="updateBusinessTripFlightsExpense",Wt=()=>{const[{fetching:i},n]=B(ms),r=p.useCallback(async t=>{const s="Error updating business trip flights expense",a=Ut;j.loading("Updating trip flights expense",{id:a});try{const o=await n(t),d=S(o,s,a);if(d)return j.success("Success",{id:a,description:"Business trip flights expense was updated"}),d.updateBusinessTripFlightsExpense}catch(o){console.error(`${s}: ${o}`),j.error("Error",{id:a,description:s,duration:1e5,closeButton:!0})}},[n]);return{fetching:i,updateBusinessTripFlightsExpense:r}},qt=Object.entries(Re).map(([i,n])=>({value:n,label:i})),Gt=({data:i,businessTripId:n,onChange:r,attendees:t})=>{const s=A(gs,i),[a,o]=p.useState(!1),d=N({defaultValues:{id:s.id,businessTripId:n,attendeeIds:s.attendees?.map(g=>g.id)??[],path:s.path??[]}}),{control:x,handleSubmit:m}=d,{updateBusinessTripFlightsExpense:h,fetching:l}=Wt(),c=g=>{h({fields:g}).then(()=>{r?.(),o(!1)})},u=t.map(g=>({value:g.id,label:g.name}));return e.jsxs("tr",{children:[e.jsx(le,{data:s,isEditMode:a,control:x,businessTripId:n}),e.jsx("td",{children:e.jsx(I,{...d,children:e.jsx("form",{id:`form ${s.id}`,onSubmit:m(c),children:e.jsxs("div",{className:"flex flex-col gap-2 justify-center",children:[a?e.jsx(qe,{formManager:d,flightPathPath:"path",flightPathData:s.path??void 0}):e.jsx("div",{className:"flex gap-2 items-center",children:s.path?.length?s.path.map((g,f)=>e.jsxs(e.Fragment,{children:[e.jsx(D,{fw:700,children:g},f),f<s.path.length-1&&(g===s.path[f+1]?" | ":" → ")]})):e.jsx(D,{fw:700,className:"flex gap-2 items-center",c:"red",children:"Missing"})}),a?e.jsx(b,{name:"flightClass",control:x,defaultValue:s.class??void 0,render:({field:g,fieldState:f})=>e.jsx(q,{form:`form ${s.id}`,"data-autofocus":!0,...g,data:qt,value:g.value,label:"Flight Class",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:f.error?.message,withinPortal:!0})}):e.jsx(D,{c:s.class?void 0:"red",fz:"sm",children:`Class: ${s.class??"Missing"}`})]})})})}),e.jsx("td",{children:a?e.jsx(b,{name:"attendeeIds",control:x,defaultValue:s.attendees?.map(g=>g.id)??void 0,render:({field:g,fieldState:f})=>e.jsx(_e,{...g,form:`form ${s.id}`,data:u,value:g.value??[],label:"Attendees",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:f.error?.message,withinPortal:!0})}):e.jsx(xe,{listStyleType:"disc",children:s.attendees?.length?s.attendees.map(g=>e.jsx(xe.Item,{children:g.name},g.id)):e.jsx(D,{c:"red",fz:"sm",children:"Missing"})})}),e.jsx("td",{children:r&&e.jsxs(e.Fragment,{children:[e.jsx(w,{label:"Edit",children:e.jsx(v,{disabled:l,variant:a?"default":"outline",size:"icon",className:"size-7.5",onClick:g=>{g.stopPropagation(),o(f=>!f)},children:e.jsx(J,{className:"size-5"})})}),a&&e.jsx(w,{label:"Confirm Changes",children:e.jsx(v,{type:"submit",form:`form ${s.id}`,variant:"outline",size:"icon",className:"size-7.5 text-green-500",children:e.jsx(ee,{className:"size-5"})})}),e.jsx(ce,{businessTripExpenseId:s.id,businessTripId:n,onChange:r}),e.jsx(de,{businessTripExpenseId:s.id,onDelete:r})]})})]},s.id)},Ge=({businessTripId:i,expenses:n,attendees:r,onChange:t})=>{if(!n?.length)return t?e.jsx(Ae,{businessTripId:i,onAdd:t}):e.jsx(e.Fragment,{});const s=n.map(a=>A(js,a));return e.jsx("div",{className:"flex flex-col gap-2 mt-5",children:e.jsxs(se,{highlightOnHover:!0,withBorder:!0,children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx(ue,{}),e.jsx("th",{children:"Flight"}),e.jsx("th",{children:"Attendees"}),e.jsx("th",{})]})}),e.jsxs("tbody",{children:[s.sort((a,o)=>a.date&&o.date?a.date<o.date?1:-1:a.date?-1:o.date?1:0).map(a=>e.jsx(Gt,{data:a,businessTripId:i,onChange:t,attendees:r},a.id)),t&&e.jsx("tr",{children:e.jsx("td",{colSpan:5,children:e.jsx(Ae,{businessTripId:i,onAdd:t})})})]})]})})},Yt=({data:i,businessTripId:n,onChange:r})=>{const t=A(fs,i),[s,a]=p.useState(!1),[o,d]=p.useState(!1),{control:x,handleSubmit:m}=N({defaultValues:{businessTripId:n,attendeeId:t.id,arrivalDate:t.arrivalDate,departureDate:t.departureDate}}),{updateBusinessTripAttendee:h,fetching:l}=$t(),c=u=>{h({fields:u}).then(()=>{r?.(),a(!1)})};return e.jsxs(e.Fragment,{children:[e.jsxs("tr",{children:[e.jsx("td",{children:t.name}),e.jsx("td",{children:s?e.jsx("form",{id:`form ${t.id}`,onSubmit:m(c),children:e.jsx(b,{name:"arrivalDate",control:x,defaultValue:t.arrivalDate,rules:{pattern:{value:U,message:"Date must be im format yyyy-mm-dd"}},render:({field:u,fieldState:g})=>e.jsx(W,{...u,onChange:f=>{const T=f?typeof f=="string"?f:M(f,"yyyy-MM-dd"):void 0;T!==u.value&&u.onChange(T)},"data-autofocus":!0,value:u.value?new Date(u.value):void 0,error:g.error?.message,label:"Arrival",popoverProps:{withinPortal:!0}})})}):t.arrivalDate}),e.jsx("td",{children:s?e.jsx(b,{name:"departureDate",control:x,defaultValue:t.departureDate,rules:{pattern:{value:U,message:"Date must be im format yyyy-mm-dd"}},render:({field:u,fieldState:g})=>e.jsx(W,{...u,onChange:f=>{const T=f?typeof f=="string"?f:M(f,"yyyy-MM-dd"):void 0;T!==u.value&&u.onChange(T)},value:u.value?new Date(u.value):void 0,error:g.error?.message,label:"Departure",popoverProps:{withinPortal:!0}})}):t.departureDate}),e.jsxs("td",{className:"flex items-center gap-2",children:[e.jsx(w,{label:"Edit",children:e.jsx(v,{disabled:l,variant:s?"default":"outline",size:"icon",className:"size-7.5",onClick:u=>{u.stopPropagation(),a(g=>!g)},children:e.jsx(J,{className:"size-5"})})}),s&&e.jsx(w,{label:"Confirm Changes",children:e.jsx(v,{type:"submit",form:`form ${t.id}`,variant:"outline",size:"icon",className:"size-7.5 text-green-500",children:e.jsx(ee,{className:"size-5"})})}),e.jsx(kt,{businessTripId:n,attendeeId:t.id,onDelete:r}),e.jsx(Ks,{toggleExpansion:d,isExpanded:o})]})]},t.id),o&&e.jsx("tr",{children:e.jsx("td",{colSpan:4,children:e.jsx(He,{shadow:"sm",withBorder:!0,children:e.jsxs("div",{className:"flex flex-col gap-2",children:[t.flights&&e.jsxs(e.Fragment,{children:[e.jsx("div",{children:"Flights:"}),e.jsx(Ge,{businessTripId:n,attendees:[],expenses:t.flights})]}),t.accommodations&&e.jsxs(e.Fragment,{children:[e.jsx("div",{children:"Accommodations:"}),e.jsx(We,{businessTripId:n,expenses:t.accommodations})]})]})})})},`${t.id}-expension`)]})},Zt=({data:i,onChange:n})=>{const{attendees:r,id:t}=A(vs,i);return r?.length?e.jsx("div",{className:"flex flex-col gap-2 mt-5",children:e.jsxs(se,{highlightOnHover:!0,withBorder:!0,children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Name"}),e.jsx("th",{children:"Arrival Date"}),e.jsx("th",{children:"Departure Date"}),e.jsx("th",{})]})}),e.jsxs("tbody",{children:[r.sort((s,a)=>s.name.toLocaleLowerCase()>a.name.toLocaleLowerCase()?1:-1).map(s=>e.jsx(Yt,{data:s,businessTripId:t,onChange:n},s.id)),e.jsx("tr",{children:e.jsx("td",{colSpan:4,children:e.jsx(Ce,{businessTripId:t,onAdd:n})})})]})]})}):e.jsx(Ce,{businessTripId:t,onAdd:n})},pe="addBusinessTripCarRentalExpense",Kt=()=>{const[{fetching:i},n]=B(bs),r=p.useCallback(async t=>{const s="Error adding business trip car rental expense";j.loading("Adding car rental expense...",{id:pe});try{const a=await n(t),o=S(a,s,pe);if(o)return j.success("Success",{id:pe,description:"Car rental expense added"}),o.addBusinessTripCarRentalExpense}catch(a){console.error(`${s}: ${a}`),j.error("Error",{id:pe,description:s,duration:1e5,closeButton:!0})}},[n]);return{fetching:i,addBusinessTripCarRentalExpense:r}};function we(i){const{businessTripId:n,onAdd:r}=i,[t,{close:s,open:a}]=L(!1);return e.jsxs(e.Fragment,{children:[e.jsx(w,{label:"Add Car Rental Expense",children:e.jsx(v,{variant:"outline",size:"icon",onClick:o=>{o.stopPropagation(),a()},className:"size-7.5",children:e.jsx(G,{className:"size-5"})})}),t&&e.jsx(Xt,{businessTripId:n,opened:t,close:s,onAdd:r})]})}function Xt({businessTripId:i,opened:n,close:r,onAdd:t}){const s=N({defaultValues:{businessTripId:i}}),{control:a,handleSubmit:o}=s,[d,x]=p.useState(!1),{addBusinessTripCarRentalExpense:m,fetching:h}=Kt(),l=c=>{m({fields:c}).then(()=>{t?.(),r()})};return e.jsxs(C,{opened:n,onClose:r,centered:!0,lockScroll:!0,children:[e.jsx(C.Title,{children:"Add Car Rental Expense"}),e.jsx(C.Body,{children:e.jsx(I,{...s,children:e.jsxs("form",{onSubmit:o(l),children:[e.jsx(oe,{businessTripId:i,control:a,setFetching:x}),e.jsx(b,{name:"days",control:a,render:({field:c,fieldState:u})=>e.jsx(ae,{...c,value:c.value??void 0,hideControls:!0,precision:2,removeTrailingZeros:!0,error:u.error?.message,label:"Rent Days"})}),e.jsx(z,{name:"isFuelExpense",control:a,render:({field:{value:c,...u}})=>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(X,{children:"Is Fuel Expense"})}),e.jsx($,{children:e.jsx(je,{...u,checked:c===!0,onCheckedChange:u.onChange})}),e.jsx(_,{})]})}),e.jsx("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:"Add"})})]})})}),(h||d)&&e.jsx(Y,{blur:1,center:!0,children:e.jsx(Z,{})})]})}const Qt="updateBusinessTripCarRentalExpense",Jt=()=>{const[{fetching:i},n]=B(ys),r=p.useCallback(async t=>{const s="Error updating business trip car rental expense",a=Qt;j.loading("Updating trip car rental expense",{id:a});try{const o=await n(t),d=S(o,s,a);if(d)return j.success("Success",{id:a,description:"Business trip car rental expense was updated"}),d.updateBusinessTripCarRentalExpense}catch(o){console.error(`${s}: ${o}`),j.error("Error",{id:a,description:s,duration:1e5,closeButton:!0})}},[n]);return{fetching:i,updateBusinessTripCarRentalExpense:r}},en=({data:i,businessTripId:n,onChange:r})=>{const t=A(Ts,i),[s,a]=p.useState(!1),o=N({defaultValues:{id:t.id,businessTripId:n}}),{control:d,handleSubmit:x}=o,{updateBusinessTripCarRentalExpense:m,fetching:h}=Jt(),l=c=>{m({fields:c}).then(()=>{r?.(),a(!1)})};return e.jsxs("tr",{children:[e.jsx(le,{data:t,isEditMode:s,control:d,businessTripId:n}),e.jsx("td",{children:e.jsx(I,{...o,children:e.jsx("form",{id:`form ${t.id}`,onSubmit:x(l),children:e.jsx("div",{className:"flex flex-col gap-2 justify-center",children:t.isFuelExpense!==!0&&(s?e.jsx(b,{name:"days",control:d,defaultValue:t.days,render:({field:c,fieldState:u})=>e.jsx(ae,{...c,value:c.value??void 0,form:`form ${t.id}`,hideControls:!0,precision:2,removeTrailingZeros:!0,error:u.error?.message,placeholder:"Rent Days"})}):e.jsx(D,{c:t.days?void 0:"red",children:t.days??"Missing"}))})})})}),e.jsx("td",{children:s?e.jsx(I,{...o,children:e.jsx(z,{name:"isFuelExpense",control:d,defaultValue:t.isFuelExpense,render:({field:c})=>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(X,{children:"Is Fuel Expense"})}),e.jsx($,{children:e.jsx(je,{form:`form ${t.id}`,checked:c.value===!0,onCheckedChange:c.onChange})})]})})}):t.isFuelExpense===!0?e.jsx(nt,{}):e.jsx(st,{})}),e.jsxs("td",{children:[e.jsx(w,{label:"Edit",children:e.jsx(v,{disabled:h,variant:s?"default":"outline",size:"icon",className:"size-7.5",onClick:c=>{c.stopPropagation(),a(u=>!u)},children:e.jsx(J,{className:"size-5"})})}),s&&e.jsx(w,{label:"Confirm Changes",children:e.jsx(v,{type:"submit",form:`form ${t.id}`,variant:"outline",size:"icon",className:"size-7.5 text-green-500",children:e.jsx(ee,{className:"size-5"})})}),e.jsx(ce,{businessTripExpenseId:t.id,businessTripId:n,onChange:r}),e.jsx(de,{businessTripExpenseId:t.id,onDelete:r})]})]},t.id)},sn=({data:i,onChange:n})=>{const{carRentalExpenses:r,id:t}=A(Es,i);return r?.length?e.jsx("div",{className:"flex flex-col gap-2 mt-5",children:e.jsxs(se,{highlightOnHover:!0,withBorder:!0,children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx(ue,{}),e.jsx("th",{children:"Days"}),e.jsx("th",{children:"Type"}),e.jsx("th",{})]})}),e.jsxs("tbody",{children:[r.sort((s,a)=>s.date&&a.date?s.date<a.date?1:-1:s.date?-1:a.date?1:0).map(s=>e.jsx(en,{data:s,businessTripId:t,onChange:n},s.id)),e.jsx("tr",{children:e.jsx("td",{colSpan:6,children:e.jsx(we,{businessTripId:t,onAdd:n})})})]})]})}):e.jsx(we,{businessTripId:t,onAdd:n})},tn=({data:i,onChange:n})=>{const{flightExpenses:r,id:t,attendees:s}=A(Cs,i);return e.jsx(Ge,{businessTripId:t,attendees:s,expenses:r,onChange:n})},nn="addBusinessTripOtherExpense",rn=()=>{const[{fetching:i},n]=B(As),r=p.useCallback(async t=>{const s='Error adding business trip "other" expense',a=nn;j.loading('Adding trip "other" expense',{id:a});try{const o=await n(t),d=S(o,s,a);if(d)return j.success("Success",{id:a,description:'Business trip "other" expense was added'}),d.addBusinessTripOtherExpense}catch(o){console.error(`${s}: ${o}`),j.error("Error",{id:a,description:s,duration:1e5,closeButton:!0})}},[n]);return{fetching:i,addBusinessTripOtherExpense:r}};function De(i){const{businessTripId:n,onAdd:r}=i,[t,{close:s,open:a}]=L(!1);return e.jsxs(e.Fragment,{children:[e.jsx(w,{label:"Add Other Expense",children:e.jsx(v,{variant:"outline",size:"icon",className:"size-7.5",onClick:o=>{o.stopPropagation(),a()},children:e.jsx(G,{className:"size-5"})})}),t&&e.jsx(an,{businessTripId:n,opened:t,close:s,onAdd:r})]})}function an({businessTripId:i,opened:n,close:r,onAdd:t}){const s=N({defaultValues:{businessTripId:i}}),{control:a,handleSubmit:o}=s,[d,x]=p.useState(!1),{addBusinessTripOtherExpense:m,fetching:h}=rn(),l=c=>{m({fields:c}).then(()=>{t?.(),r()})};return e.jsxs(C,{opened:n,onClose:r,centered:!0,lockScroll:!0,children:[e.jsx(C.Title,{children:"Add Other Expense"}),e.jsx(C.Body,{children:e.jsx(I,{...s,children:e.jsxs("form",{onSubmit:o(l),className:"space-y-3",children:[e.jsx(oe,{businessTripId:i,control:a,setFetching:x}),e.jsx(z,{name:"description",control:a,render:({field:c})=>e.jsxs(P,{children:[e.jsx(X,{children:"Description"}),e.jsx($,{children:e.jsx(Q,{...c,value:c.value??void 0})}),e.jsx(_,{})]})}),e.jsx(z,{control:s.control,name:"deductibleExpense",render:({field:c})=>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(X,{children:"Deductible Expense"})}),e.jsx($,{children:e.jsx(je,{checked:c.value===!0,onCheckedChange:c.onChange})})]})}),e.jsx("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:"Add"})})]})})}),(h||d)&&e.jsx(Y,{blur:1,center:!0,children:e.jsx(Z,{})})]})}const on="updateBusinessTripOtherExpense",cn=()=>{const[{fetching:i},n]=B(ws),r=p.useCallback(async t=>{const s='Error updating business trip "other" expense',a=on;j.loading('Updating business trip "other" expense',{id:a});try{const o=await n(t),d=S(o,s,a);if(d)return j.success("Success",{id:a,description:'Business trip "other" expense was updated'}),d.updateBusinessTripOtherExpense}catch(o){console.error(`${s}: ${o}`),j.error("Error",{id:a,description:s,duration:1e5,closeButton:!0})}},[n]);return{fetching:i,updateBusinessTripOtherExpense:r}},dn=({data:i,businessTripId:n,onChange:r})=>{const t=A(Ds,i),[s,a]=p.useState(!1),o=N({defaultValues:{id:t.id,businessTripId:n}}),{control:d,handleSubmit:x}=o,{updateBusinessTripOtherExpense:m,fetching:h}=cn(),l=c=>{m({fields:c}).then(()=>{r?.(),a(!1)})};return e.jsxs("tr",{children:[e.jsx(le,{data:t,isEditMode:s,control:d,businessTripId:n}),e.jsx("td",{children:e.jsx(I,{...o,children:e.jsx("form",{id:`form ${t.id}`,onSubmit:x(l),children:s?e.jsx(z,{name:"description",control:d,defaultValue:t.description,render:({field:c})=>e.jsxs(P,{children:[e.jsx($,{children:e.jsx(Q,{form:`form ${t.id}`,...c,value:c.value??void 0})}),e.jsx(_,{})]})}):e.jsx(D,{c:t.description?void 0:"red",children:t.description??"Missing"})})})}),e.jsx("td",{children:e.jsx("div",{className:"flex flex-col gap-2 justify-center",children:s?e.jsx(I,{...o,children:e.jsx(z,{name:"deductibleExpense",control:o.control,defaultValue:t.deductibleExpense,render:({field:c})=>e.jsx(P,{children:e.jsx($,{children:e.jsx(je,{form:`form ${t.id}`,checked:c.value===!0,onCheckedChange:c.onChange})})})})}):e.jsx(D,{c:t.deductibleExpense?void 0:"red",children:t.deductibleExpense===!0?"Yes":t.deductibleExpense===!1?"No":"Missing"})})}),e.jsxs("td",{children:[e.jsx(w,{label:"Edit",children:e.jsx(v,{disabled:h,variant:s?"default":"outline",size:"icon",className:"size-7.5",onClick:c=>{c.stopPropagation(),a(u=>!u)},children:e.jsx(J,{className:"size-5"})})}),s&&e.jsx(w,{label:"Confirm Changes",children:e.jsx(v,{type:"submit",form:`form ${t.id}`,variant:"outline",size:"icon",className:"size-7.5 text-green-500",children:e.jsx(ee,{className:"size-5"})})}),e.jsx(ce,{businessTripExpenseId:t.id,businessTripId:n,onChange:r}),e.jsx(de,{businessTripExpenseId:t.id,onDelete:r})]})]},t.id)},ln=({data:i,onChange:n})=>{const{otherExpenses:r,id:t}=A(Bs,i);return r?.length?e.jsx("div",{className:"flex flex-col gap-2 mt-5",children:e.jsxs(se,{highlightOnHover:!0,withBorder:!0,children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx(ue,{}),e.jsx("th",{children:"Description"}),e.jsx("th",{children:"Deductible Expense"}),e.jsx("th",{})]})}),e.jsxs("tbody",{children:[r.sort((s,a)=>s.date&&a.date?s.date<a.date?1:-1:s.date?-1:a.date?1:0).map(s=>e.jsx(dn,{data:s,businessTripId:t,onChange:n},s.id)),e.jsx("tr",{children:e.jsx("td",{colSpan:6,children:e.jsx(De,{businessTripId:t,onAdd:n})})})]})]})}):e.jsx(De,{businessTripId:t,onAdd:n})},un="addBusinessTripTravelAndSubsistenceExpense",hn=()=>{const[{fetching:i},n]=B(Ss),r=p.useCallback(async t=>{const s="Error adding business trip travel&subsistence expense",a=un;j.loading("Adding trip travel&subsistence expense",{id:a});try{const o=await n(t),d=S(o,s,a);if(d)return j.success("Success",{id:a,description:"Business trip travel&subsistence expense was added"}),d.addBusinessTripTravelAndSubsistenceExpense}catch(o){console.error(`${s}: ${o}`),j.error("Error",{id:a,description:s,duration:1e5,closeButton:!0})}},[n]);return{fetching:i,addBusinessTripTravelAndSubsistenceExpense:r}};function Be(i){const{businessTripId:n,onAdd:r}=i,[t,{close:s,open:a}]=L(!1);return e.jsxs(e.Fragment,{children:[e.jsx(w,{label:"Add T&S Expense",children:e.jsx(v,{variant:"outline",size:"icon",className:"size-7.5",onClick:o=>{o.stopPropagation(),a()},children:e.jsx(G,{className:"size-5"})})}),t&&e.jsx(pn,{businessTripId:n,opened:t,close:s,onAdd:r})]})}function pn({businessTripId:i,opened:n,close:r,onAdd:t}){const s=N({defaultValues:{businessTripId:i}}),{control:a,handleSubmit:o}=s,[d,x]=p.useState(!1),{addBusinessTripTravelAndSubsistenceExpense:m,fetching:h}=hn(),l=c=>{m({fields:c}).then(()=>{t?.(),r()})};return e.jsxs(C,{opened:n,onClose:r,centered:!0,lockScroll:!0,children:[e.jsx(C.Title,{children:"Add Travel & Subsistence Expense"}),e.jsx(C.Body,{children:e.jsx(I,{...s,children:e.jsxs("form",{onSubmit:o(l),className:"space-y-3",children:[e.jsx(oe,{businessTripId:i,control:a,setFetching:x}),e.jsx(z,{name:"expenseType",control:a,render:({field:c})=>e.jsxs(P,{children:[e.jsx(X,{children:"Expense Type"}),e.jsx($,{children:e.jsx(Q,{...c,value:c.value??void 0})}),e.jsx(_,{})]})}),e.jsx("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:"Add"})})]})})}),(h||d)&&e.jsx(Y,{blur:1,center:!0,children:e.jsx(Z,{})})]})}const xn="updateBusinessTripTravelAndSubsistenceExpense",mn=()=>{const[{fetching:i},n]=B(Is),r=p.useCallback(async t=>{const s="Error updating business trip travel&subsistence expense",a=xn;j.loading("Updating trip travel&subsistence expense",{id:a});try{const o=await n(t),d=S(o,s,a);if(d)return j.success("Success",{id:a,description:"Business trip travel&subsistence expense was updated"}),d.updateBusinessTripTravelAndSubsistenceExpense}catch(o){console.error(`${s}: ${o}`),j.error("Error",{id:a,description:s,duration:1e5,closeButton:!0})}},[n]);return{fetching:i,updateBusinessTripTravelAndSubsistenceExpense:r}},gn=({data:i,businessTripId:n,onChange:r})=>{const t=A(Ns,i),[s,a]=p.useState(!1),o=N({defaultValues:{id:t.id,businessTripId:n}}),{control:d,handleSubmit:x}=o,{updateBusinessTripTravelAndSubsistenceExpense:m,fetching:h}=mn(),l=c=>{m({fields:c}).then(()=>{r?.(),a(!1)})};return e.jsxs("tr",{children:[e.jsx(le,{data:t,isEditMode:s,control:d,businessTripId:n}),e.jsx("td",{children:e.jsx(I,{...o,children:e.jsx("form",{id:`form ${t.id}`,onSubmit:x(l),children:s?e.jsx(z,{name:"expenseType",control:d,defaultValue:t.expenseType,render:({field:c})=>e.jsxs(P,{children:[e.jsx($,{children:e.jsx(Q,{form:`form ${t.id}`,...c,value:c.value??void 0})}),e.jsx(_,{})]})}):e.jsx(D,{c:t.expenseType?void 0:"red",children:t.expenseType??"Missing"})})})}),e.jsxs("td",{children:[e.jsx(w,{label:"Edit",children:e.jsx(v,{disabled:h,variant:s?"default":"outline",size:"icon",className:"size-7.5",onClick:c=>{c.stopPropagation(),a(u=>!u)},children:e.jsx(J,{className:"size-5"})})}),s&&e.jsx(w,{label:"Confirm Changes",children:e.jsx(v,{type:"submit",form:`form ${t.id}`,variant:"outline",size:"icon",className:"size-7.5 text-green-500",children:e.jsx(ee,{className:"size-5"})})}),e.jsx(ce,{businessTripExpenseId:t.id,businessTripId:n,onChange:r}),e.jsx(de,{businessTripExpenseId:t.id,onDelete:r})]})]},t.id)},jn=({data:i,onChange:n})=>{const{travelAndSubsistenceExpenses:r,id:t}=A(Fs,i);return r?.length?e.jsx("div",{className:"flex flex-col gap-2 mt-5",children:e.jsxs(se,{highlightOnHover:!0,withBorder:!0,children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx(ue,{}),e.jsx("th",{children:"Expense Type"}),e.jsx("th",{})]})}),e.jsxs("tbody",{children:[r.sort((s,a)=>s.date&&a.date?s.date<a.date?1:-1:s.date?-1:a.date?1:0).map(s=>e.jsx(gn,{data:s,businessTripId:t,onChange:n},s.id)),e.jsx("tr",{children:e.jsx("td",{colSpan:6,children:e.jsx(Be,{businessTripId:t,onAdd:n})})})]})]})}):e.jsx(Be,{businessTripId:t,onAdd:n})},fn=({data:i})=>{const n=A(Ms,i),r="effectiveDate"in n?n.effectiveDate:void 0;return e.jsx("td",{children:e.jsxs("div",{className:"flex flex-col justify-center",children:[e.jsx("div",{children:r&&M(new Date(r),"dd/MM/yy")}),n.sourceEffectiveDate&&e.jsxs("div",{className:"text-xs text-gray-500",children:["(Originally ",M(new Date(n.sourceEffectiveDate),"dd/MM/yy"),")"]})]})})},vn=({data:i})=>{const n=A(zs,i),r="eventDate"in n?n.eventDate:void 0;return e.jsx("td",{children:e.jsx("div",{className:"flex flex-col justify-center",children:r&&M(new Date(r),"dd/MM/yy")})})},bn=({data:i})=>{const n=A(Ps,i),{account:r}=n,t=r.type,s=r.name;return e.jsx("td",{children:e.jsxs("div",{className:"flex flex-col gap-2 items-center",children:[e.jsx("p",{children:t}),e.jsx("p",{children:s})]})})},yn=({data:i})=>{const n=A($s,i),r="sourceDescription"in n?n.sourceDescription:"Missing";return e.jsx("td",{children:e.jsx("div",{className:"flex flex-wrap",children:e.jsx("div",{className:"flex flex-col justify-center",children:r})})})},Tn=({data:i})=>{const n=A(Os,i);return e.jsx("td",{children:e.jsx("div",{className:"flex flex-wrap",children:e.jsx("div",{className:"flex flex-col justify-center",children:n.referenceKey})})})};function En({data:i,onChange:n,enableEdit:r}){const{id:t,counterparty:s,missingInfoSuggestions:a,id:o,sourceDescription:d}=A(Rs,i),x=!!a?.business&&r,m=x?a?.business?.name:"Missing",h=x?a?.business?.id:null,l=s?.name??m,[c,u]=p.useState(!1),{updateTransaction:g,fetching:f}=Xs(),T=p.useCallback(async V=>{await g({transactionId:o,fields:{counterpartyId:V}}),u(!0)},[o,g]),y=p.useCallback(async V=>{await T(V),n?.()},[T,n]),{selectableBusinesses:O,fetching:K}=Oe(),[F,R]=p.useState(h??null),[k,re]=p.useState(d);return e.jsxs("td",{children:[e.jsx("div",{className:"flex flex-wrap gap-1 items-center justify-center",children:s?.id?e.jsx(be,{to:ye.BUSINESSES.DETAIL(s.id),target:"_blank",rel:"noreferrer",onClick:V=>V.stopPropagation(),className:"inline-flex items-center font-semibold",children:l}):e.jsxs(e.Fragment,{children:[e.jsx(ks,{options:O,value:F,onChange:R,search:k,onSearchChange:re,placeholder:"Choose or create a business",empty:k?e.jsx(Hs,{description:k,onAdd:y}):null}),e.jsx(Js,{content:"Approve",children:e.jsx(v,{variant:"outline",size:"icon",onClick:()=>F&&T(F),disabled:f||K||!F,children:e.jsx(ee,{className:"size-4"})})})]})}),e.jsx(Qs,{transactionId:t,counterpartyId:s?.id??F,open:c,onOpenChange:u,onClose:n})]})}const Cn="categorizeBusinessTripExpense",An=()=>{const[{fetching:i},n]=B(_s),r=p.useCallback(async t=>{const s="Error updating business trip expense category",a=Cn;j.loading("Updating trip expense category",{id:a});try{const o=await n(t),d=S(o,s,a);if(d)return j.success("Success",{id:a,description:"Business trip expense category was updated"}),d.categorizeBusinessTripExpense}catch(o){console.error(`${s}: ${o}`),j.error("Error",{id:a,description:s,duration:1e5,closeButton:!0})}},[n]);return{fetching:i,categorizeBusinessTripExpense:r}};function wn(i){const{businessTripId:n,transactionId:r,onChange:t,defaultAmount:s}=i,[a,{close:o,open:d}]=L(!1);return e.jsxs(e.Fragment,{children:[e.jsx(w,{label:"Categorize",children:e.jsx(v,{variant:"outline",size:"icon",className:"size-7.5",onClick:x=>{x.stopPropagation(),d()},children:e.jsx(J,{className:"size-5"})})}),a&&e.jsx(Bn,{businessTripId:n,transactionId:r,opened:a,close:o,onChange:t,defaultAmount:s})]})}const Dn=Object.entries(Vs).map(([i,n])=>({value:n,label:i}));function Bn({businessTripId:i,transactionId:n,defaultAmount:r,opened:t,close:s,onChange:a}){const{control:o,handleSubmit:d}=N({defaultValues:{businessTripId:i,transactionId:n}}),{categorizeBusinessTripExpense:x,fetching:m}=An(),h=l=>{x({fields:l}).then(()=>{a?.(),s()})};return e.jsxs(C,{opened:t,onClose:s,centered:!0,children:[e.jsx(C.Title,{children:"Set Expense Category"}),e.jsx(C.Body,{children:e.jsxs("form",{onSubmit:d(h),className:"flex flex-col gap-3 mt-3",children:[e.jsx(b,{name:"category",control:o,render:({field:l,fieldState:c})=>e.jsx(q,{"data-autofocus":!0,...l,data:Dn,value:l.value,label:"Category",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:c.error?.message,withinPortal:!0})}),e.jsx(b,{name:"amount",control:o,defaultValue:r,render:({field:l,fieldState:c})=>e.jsx(ae,{...l,value:l.value??void 0,hideControls:!0,precision:2,removeTrailingZeros:!0,error:c.error?.message,label:"Amount"})}),e.jsx("div",{className:"flex justify-center 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:"Confirm"})})]})}),m&&e.jsx(Y,{blur:1,center:!0,children:e.jsx(Z,{})})]})}const Sn=({data:i,onChange:n})=>{const{uncategorizedTransactions:r,id:t}=A(Ls,i);return r?.length?e.jsx("div",{className:"flex flex-col gap-2 mt-5",children:e.jsxs(se,{highlightOnHover:!0,withBorder:!0,children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Event Date"}),e.jsx("th",{children:"Debit Date"}),e.jsx("th",{children:"Amount"}),e.jsx("th",{}),e.jsx("th",{children:"Account"}),e.jsx("th",{children:"Description"}),e.jsx("th",{children:"Reference#"}),e.jsx("th",{children:"Counterparty"}),e.jsx("th",{})]})}),e.jsx("tbody",{children:r.sort((s,a)=>s.transaction.eventDate.localeCompare(a.transaction.eventDate)).map(s=>e.jsxs("tr",{children:[e.jsx(vn,{data:s.transaction}),e.jsx(fn,{data:s.transaction}),e.jsx(In,{data:s}),e.jsx("td",{children:e.jsx(be,{to:ye.CHARGES.DETAIL(s.transaction.chargeId),target:"_blank",rel:"noreferrer",onClick:a=>a.stopPropagation(),className:"inline-flex items-center font-semibold",children:"To Charge"})}),e.jsx(bn,{data:s.transaction}),e.jsx(yn,{data:s.transaction}),e.jsx(Tn,{data:s.transaction}),e.jsx(En,{data:s.transaction}),e.jsx("td",{children:e.jsx(wn,{businessTripId:t,transactionId:s.transaction.id,onChange:n,defaultAmount:s.transaction.amount.raw})})]},s.transaction.id))})]})}):e.jsx(e.Fragment,{})},In=({data:i})=>{const{transaction:n,categorizedAmount:r,errors:t}=A(Us,i),s="amount"in n?n.amount:void 0,a=s?.raw!==r.raw&&r.raw!==0;return e.jsx("td",{children:e.jsxs("div",{className:"flex flex-col whitespace-nowrap",style:{color:Number(s?.raw)>0?"green":"red"},children:[e.jsxs("div",{className:"flex gap-1",children:[s?.formatted,t.length>0&&e.jsx(Nn,{errors:t})]}),a&&e.jsxs("div",{className:"text-gray-500 ml-2",children:[r.formatted," categorized "]}),n.cryptoExchangeRate&&e.jsxs("div",{className:"text-gray-500 ml-2",children:[`(Rate: ${n.cryptoExchangeRate.rate})`,e.jsx("br",{}),s?.raw?`${Ws(s.raw*n.cryptoExchangeRate.rate)}$`:null]})]})})},Nn=({errors:i})=>{const[n,{close:r,open:t}]=L(!1);return e.jsxs(fe,{width:200,position:"bottom",shadow:"md",opened:n,children:[e.jsx(fe.Target,{children:e.jsx(qs,{onMouseEnter:t,onMouseLeave:r})}),e.jsx(fe.Dropdown,{sx:{pointerEvents:"none"},className:"whitespace-normal text-red-500",children:i.map((s,a)=>e.jsx(D,{size:"sm",children:s},a))})]})};function _n({tripId:i,isExtended:n=!1}){const[r,t]=p.useState(),[s,a]=p.useState([]),[{data:o},d]=ne({query:Gs,variables:{businessTripId:i}});function x(h){s.includes(h)?a(l=>l.filter(c=>c!==h)):a(l=>[...l,h])}const m=d;return p.useEffect(()=>{o?.businessTrip&&t(o.businessTrip)},[o?.businessTrip]),e.jsx(He,{shadow:"sm",radius:"md",withBorder:!0,children:r?e.jsxs(e.Fragment,{children:[e.jsx(Ys,{data:r,onChange:m}),e.jsxs(E,{className:"w-full",multiple:!0,value:s,chevron:e.jsx(G,{size:"1rem"}),styles:{chevron:{"&[data-rotate]":{transform:"rotate(45deg)"}}},children:[e.jsxs(E.Item,{value:"attendees",children:[e.jsx(E.Control,{onClick:()=>x("attendees"),children:"Attendees"}),e.jsx(E.Panel,{children:e.jsx(Zt,{data:r,onChange:m})})]}),n&&e.jsxs(E.Item,{value:"uncategorized-transactions",children:[e.jsx(E.Control,{onClick:()=>x("uncategorized-transactions"),disabled:!r.uncategorizedTransactions?.length,children:"Uncategorized Transactions"}),e.jsx(E.Panel,{children:e.jsx(Sn,{data:r,onChange:m})})]}),e.jsxs(E.Item,{value:"flights",children:[e.jsx(E.Control,{onClick:()=>x("flights"),children:"Flights"}),e.jsx(E.Panel,{children:e.jsx(tn,{data:r,onChange:m})})]}),e.jsxs(E.Item,{value:"accommodations",children:[e.jsx(E.Control,{onClick:()=>x("accommodations"),children:"Accommodations"}),e.jsx(E.Panel,{children:e.jsx(Nt,{data:r,onChange:m})})]}),e.jsxs(E.Item,{value:"travelAndSubsistence",children:[e.jsx(E.Control,{onClick:()=>x("travelAndSubsistence"),children:"Travel & Subsistence"}),e.jsx(E.Panel,{children:e.jsx(jn,{data:r,onChange:m})})]}),e.jsxs(E.Item,{value:"other",children:[e.jsx(E.Control,{onClick:()=>x("other"),children:"Other"}),e.jsx(E.Panel,{children:e.jsx(ln,{data:r,onChange:m})})]}),e.jsxs(E.Item,{value:"carRental",children:[e.jsx(E.Control,{onClick:()=>x("carRental"),children:"Car Rental"}),e.jsx(E.Panel,{children:e.jsx(sn,{data:r,onChange:m})})]}),e.jsxs(E.Item,{value:"summary",children:[e.jsx(E.Control,{onClick:()=>x("summary"),children:"Summary"}),e.jsx(E.Panel,{children:e.jsx(Zs,{data:r})})]})]})]}):e.jsx(Se,{className:"h-10 w-10 animate-spin mr-2 self-center"})})}export{ut as C,_n as E,Hn as P};
@@ -1 +1 @@
1
- import{v as e}from"./index-CHtpNrAW.js";const a=[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]],t=e("eye-off",a);export{t as E};
1
+ import{v as e}from"./index-qAF5sGRO.js";const a=[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]],t=e("eye-off",a);export{t as E};
@@ -1 +1 @@
1
- import{v as e}from"./index-CHtpNrAW.js";const n=[["path",{d:"M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z",key:"sc7q7i"}]],a=e("funnel",n);export{a as F};
1
+ import{v as e}from"./index-qAF5sGRO.js";const n=[["path",{d:"M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z",key:"sc7q7i"}]],a=e("funnel",n);export{a as F};
@@ -1 +1 @@
1
- import{j as e,bM as D,bP as a,w as f,d3 as n,G as R,gg as v,r as d,bD as E,D as T,aU as A,B as w,x as I,bw as O,y as M,dm as P,V as L,Y as y,Z as C,_ as F,$ as V,b3 as B,a1 as g,b1 as U,au as _,F as k,aC as q,u as $,c as G,bK as Q,bL as z,bN as o,bO as H,gh as J}from"./index-CHtpNrAW.js";import{u as S}from"./use-url-query-DMunwqS4.js";import{P as K}from"./page-layout-Cs7LzhPs.js";import{F as Z}from"./funnel-4UXATjU3.js";const W=({record:s})=>{const t=R(v,s);return e.jsxs(D,{children:[e.jsx(a,{children:s.description}),e.jsx(a,{children:f(new Date(s.purchaseDate),"dd/MM/yyyy")}),e.jsx(a,{children:s.activationDate?f(new Date(s.activationDate),"dd/MM/yyyy"):void 0}),e.jsx(a,{children:t.originalCost?n(t.originalCost,0):void 0}),e.jsx(a,{children:t.reportYearDelta?n(t.reportYearDelta,0):void 0}),e.jsx(a,{children:n(t.totalDepreciableCosts,0)}),e.jsxs(a,{children:[n(s.statutoryDepreciationRate,0),"%"]}),e.jsx(a,{children:s.claimedDepreciationRate?`${n(s.claimedDepreciationRate,1)}%`:"-"}),e.jsx(a,{children:t.reportYearClaimedDepreciation?n(t.reportYearClaimedDepreciation,0):"-"}),e.jsx(a,{children:t.pastYearsAccumulatedDepreciation?n(t.pastYearsAccumulatedDepreciation,0):"-"}),e.jsx(a,{children:t.totalDepreciation?n(t.totalDepreciation,0):"-"}),e.jsx(a,{children:t.netValue?n(t.netValue,0):"-"})]})};function X(s){return!s||O(s)?null:encodeURIComponent(JSON.stringify(s))}const b="depreciationReportFilters";function ee({filter:s,setFilter:t,close:r}){const m=M({defaultValues:{...s}}),{control:c,handleSubmit:x}=m,{selectableFinancialEntities:u,fetching:l}=P(),j=i=>{t({...i,year:Number(i.year)}),r()};return e.jsx(L,{...m,children:e.jsxs("form",{onSubmit:x(j),className:"space-y-4",children:[e.jsx(y,{name:"year",control:c,rules:{required:"Year is required",validate:i=>{const p=Number(i);return Number.isNaN(p)||p<2e3||p>2100?"Invalid year":!0}},render:({field:i})=>e.jsxs(C,{children:[e.jsx(F,{children:"Year"}),e.jsx(V,{children:e.jsx(B,{...i,hideControls:!0,decimalScale:0})}),e.jsx(g,{})]})}),e.jsx(y,{name:"financialEntityId",defaultValue:s?.financialEntityId,control:c,render:({field:i})=>e.jsxs(C,{children:[e.jsx(F,{children:"Owner"}),e.jsx(U,{...i,data:u,value:i.value??void 0,disabled:l,placeholder:"Select a financial entity",formPart:!0}),e.jsx(g,{})]})}),e.jsx(_,{children:e.jsx(w,{type:"submit",disabled:l,children:"Filter"})})]})})}function ae({filter:s,setFilter:t}){const[r,m]=d.useState(!1),{get:c,set:x}=S();d.useEffect(()=>{const l=X(s),j=c(b);l!==j&&x(b,l)},[s,c,x]);const u=d.useCallback(l=>{E(l,s)||t(l)},[s,t]);return e.jsxs(T,{open:r,onOpenChange:m,children:[e.jsx(A,{asChild:!0,children:e.jsx(w,{variant:"outline",size:"icon",children:e.jsx(Z,{size:20})})}),e.jsx(I,{className:"sm:max-w-[425px]",children:e.jsx(ee,{filter:s,setFilter:u,close:()=>m(!1)})})]})}const N=({data:s,groupName:t})=>{const r=R(v,s);return e.jsxs(D,{className:"font-bold border-b border-black",children:[e.jsx(a,{children:t?"Group Total":"Overall Total"}),e.jsx(a,{colSpan:2,children:t}),e.jsx(a,{children:r.originalCost?n(r.originalCost,0):void 0}),e.jsx(a,{children:r.reportYearDelta?n(r.reportYearDelta,0):void 0}),e.jsx(a,{children:r.totalDepreciableCosts?n(r.totalDepreciableCosts,0):void 0}),e.jsx(a,{}),e.jsx(a,{}),e.jsx(a,{children:r.reportYearClaimedDepreciation?n(r.reportYearClaimedDepreciation,0):void 0}),e.jsx(a,{children:r.pastYearsAccumulatedDepreciation?n(r.pastYearsAccumulatedDepreciation,0):void 0}),e.jsx(a,{children:r.totalDepreciation?n(r.totalDepreciation,0):void 0}),e.jsx(a,{children:r.netValue?n(r.netValue,0):void 0})]})},ne=()=>{const{setFiltersContext:s}=d.useContext(k),{userContext:t}=d.useContext(q),{get:r}=S(),m=d.useMemo(()=>{const i={financialEntityId:t?.context.adminBusinessId,year:new Date().getFullYear()},p=r(b);if(p)try{return JSON.parse(decodeURIComponent(p))}catch(h){console.error("Failed to parse depreciation report filters from URL",h)}return i},[t?.context.adminBusinessId]),[c,x]=d.useState(m),[{data:u,fetching:l}]=$({query:J,variables:{filters:c}});d.useEffect(()=>{s(e.jsx("div",{className:"flex flex-row gap-x-5",children:e.jsx(ae,{filter:c,setFilter:x})}))},[c,s,x]);const j=d.useMemo(()=>`Depreciation Report for ${c.year}`,[c.year]);return e.jsx(K,{title:"Depreciation Report",description:j,children:l?e.jsx(G,{}):e.jsxs(Q,{children:[e.jsxs(z,{children:[e.jsxs(D,{className:"font-bold text-xl",children:[e.jsx(o,{colSpan:6,className:"text-center border-x",children:"List of Assets and Costs"}),e.jsx(o,{colSpan:5,className:"text-center border-x",children:"Depreciation"}),e.jsx(o,{className:"text-center border-x",children:"Remaining"})]}),e.jsxs(D,{className:"border-b border-black",children:[e.jsx(o,{className:"whitespace-normal",children:"Assets List and Descriptions"}),e.jsx(o,{className:"whitespace-normal",children:"Date of Purchase"}),e.jsx(o,{className:"whitespace-normal",children:"Activation Date"}),e.jsx(o,{className:"whitespace-normal",children:"Original Cost"}),e.jsx(o,{className:"whitespace-normal",children:"Changes During the Year"}),e.jsx(o,{className:"whitespace-normal",children:"Total Depreciable Assets"}),e.jsx(o,{className:"whitespace-normal",children:"Statutory Depreciation Rate"}),e.jsx(o,{className:"whitespace-normal",children:"Claimed Depreciation Rate"}),e.jsx(o,{className:"whitespace-normal",children:"Depreciation Claimed This Year"}),e.jsx(o,{className:"whitespace-normal",children:"Previous Tax Years Accumulated Depreciation"}),e.jsx(o,{className:"whitespace-normal",children:"Total Depreciation"}),e.jsx(o,{className:"whitespace-normal",children:"Net Book Value"})]})]}),e.jsx(H,{children:u?.depreciationReport&&e.jsxs(e.Fragment,{children:[u.depreciationReport.categories.map((i,p)=>e.jsxs(d.Fragment,{children:[e.jsxs(D,{className:"font-bold",children:[e.jsx(a,{children:`Category ${p+1}`}),e.jsx(a,{colSpan:2,children:i.category.name}),e.jsx(a,{colSpan:3}),e.jsxs(a,{children:[n(i.category.percentage,0),"%"]}),e.jsx(a,{colSpan:5})]}),i.records.sort((h,Y)=>h.purchaseDate.localeCompare(Y.purchaseDate)).map(h=>e.jsx(W,{record:h},h.id)),e.jsx(N,{data:i.summary,groupName:i.category.name})]},i.id)),e.jsx(N,{data:u.depreciationReport.summary})]})})]})})};export{ne as DepreciationReport};
1
+ import{j as e,bM as D,bP as a,w as f,d3 as n,G as R,gg as v,r as d,bD as E,D as T,aU as A,B as w,x as I,bw as O,y as M,dm as P,V as L,Y as y,Z as C,_ as F,$ as V,b3 as B,a1 as g,b1 as U,au as _,F as k,aC as q,u as $,c as G,bK as Q,bL as z,bN as o,bO as H,gh as J}from"./index-qAF5sGRO.js";import{u as S}from"./use-url-query-CYeryni6.js";import{P as K}from"./page-layout-7iCtDTzs.js";import{F as Z}from"./funnel-Cn1E8rCW.js";const W=({record:s})=>{const t=R(v,s);return e.jsxs(D,{children:[e.jsx(a,{children:s.description}),e.jsx(a,{children:f(new Date(s.purchaseDate),"dd/MM/yyyy")}),e.jsx(a,{children:s.activationDate?f(new Date(s.activationDate),"dd/MM/yyyy"):void 0}),e.jsx(a,{children:t.originalCost?n(t.originalCost,0):void 0}),e.jsx(a,{children:t.reportYearDelta?n(t.reportYearDelta,0):void 0}),e.jsx(a,{children:n(t.totalDepreciableCosts,0)}),e.jsxs(a,{children:[n(s.statutoryDepreciationRate,0),"%"]}),e.jsx(a,{children:s.claimedDepreciationRate?`${n(s.claimedDepreciationRate,1)}%`:"-"}),e.jsx(a,{children:t.reportYearClaimedDepreciation?n(t.reportYearClaimedDepreciation,0):"-"}),e.jsx(a,{children:t.pastYearsAccumulatedDepreciation?n(t.pastYearsAccumulatedDepreciation,0):"-"}),e.jsx(a,{children:t.totalDepreciation?n(t.totalDepreciation,0):"-"}),e.jsx(a,{children:t.netValue?n(t.netValue,0):"-"})]})};function X(s){return!s||O(s)?null:encodeURIComponent(JSON.stringify(s))}const b="depreciationReportFilters";function ee({filter:s,setFilter:t,close:r}){const m=M({defaultValues:{...s}}),{control:c,handleSubmit:x}=m,{selectableFinancialEntities:u,fetching:l}=P(),j=i=>{t({...i,year:Number(i.year)}),r()};return e.jsx(L,{...m,children:e.jsxs("form",{onSubmit:x(j),className:"space-y-4",children:[e.jsx(y,{name:"year",control:c,rules:{required:"Year is required",validate:i=>{const p=Number(i);return Number.isNaN(p)||p<2e3||p>2100?"Invalid year":!0}},render:({field:i})=>e.jsxs(C,{children:[e.jsx(F,{children:"Year"}),e.jsx(V,{children:e.jsx(B,{...i,hideControls:!0,decimalScale:0})}),e.jsx(g,{})]})}),e.jsx(y,{name:"financialEntityId",defaultValue:s?.financialEntityId,control:c,render:({field:i})=>e.jsxs(C,{children:[e.jsx(F,{children:"Owner"}),e.jsx(U,{...i,data:u,value:i.value??void 0,disabled:l,placeholder:"Select a financial entity",formPart:!0}),e.jsx(g,{})]})}),e.jsx(_,{children:e.jsx(w,{type:"submit",disabled:l,children:"Filter"})})]})})}function ae({filter:s,setFilter:t}){const[r,m]=d.useState(!1),{get:c,set:x}=S();d.useEffect(()=>{const l=X(s),j=c(b);l!==j&&x(b,l)},[s,c,x]);const u=d.useCallback(l=>{E(l,s)||t(l)},[s,t]);return e.jsxs(T,{open:r,onOpenChange:m,children:[e.jsx(A,{asChild:!0,children:e.jsx(w,{variant:"outline",size:"icon",children:e.jsx(Z,{size:20})})}),e.jsx(I,{className:"sm:max-w-[425px]",children:e.jsx(ee,{filter:s,setFilter:u,close:()=>m(!1)})})]})}const N=({data:s,groupName:t})=>{const r=R(v,s);return e.jsxs(D,{className:"font-bold border-b border-black",children:[e.jsx(a,{children:t?"Group Total":"Overall Total"}),e.jsx(a,{colSpan:2,children:t}),e.jsx(a,{children:r.originalCost?n(r.originalCost,0):void 0}),e.jsx(a,{children:r.reportYearDelta?n(r.reportYearDelta,0):void 0}),e.jsx(a,{children:r.totalDepreciableCosts?n(r.totalDepreciableCosts,0):void 0}),e.jsx(a,{}),e.jsx(a,{}),e.jsx(a,{children:r.reportYearClaimedDepreciation?n(r.reportYearClaimedDepreciation,0):void 0}),e.jsx(a,{children:r.pastYearsAccumulatedDepreciation?n(r.pastYearsAccumulatedDepreciation,0):void 0}),e.jsx(a,{children:r.totalDepreciation?n(r.totalDepreciation,0):void 0}),e.jsx(a,{children:r.netValue?n(r.netValue,0):void 0})]})},ne=()=>{const{setFiltersContext:s}=d.useContext(k),{userContext:t}=d.useContext(q),{get:r}=S(),m=d.useMemo(()=>{const i={financialEntityId:t?.context.adminBusinessId,year:new Date().getFullYear()},p=r(b);if(p)try{return JSON.parse(decodeURIComponent(p))}catch(h){console.error("Failed to parse depreciation report filters from URL",h)}return i},[t?.context.adminBusinessId]),[c,x]=d.useState(m),[{data:u,fetching:l}]=$({query:J,variables:{filters:c}});d.useEffect(()=>{s(e.jsx("div",{className:"flex flex-row gap-x-5",children:e.jsx(ae,{filter:c,setFilter:x})}))},[c,s,x]);const j=d.useMemo(()=>`Depreciation Report for ${c.year}`,[c.year]);return e.jsx(K,{title:"Depreciation Report",description:j,children:l?e.jsx(G,{}):e.jsxs(Q,{children:[e.jsxs(z,{children:[e.jsxs(D,{className:"font-bold text-xl",children:[e.jsx(o,{colSpan:6,className:"text-center border-x",children:"List of Assets and Costs"}),e.jsx(o,{colSpan:5,className:"text-center border-x",children:"Depreciation"}),e.jsx(o,{className:"text-center border-x",children:"Remaining"})]}),e.jsxs(D,{className:"border-b border-black",children:[e.jsx(o,{className:"whitespace-normal",children:"Assets List and Descriptions"}),e.jsx(o,{className:"whitespace-normal",children:"Date of Purchase"}),e.jsx(o,{className:"whitespace-normal",children:"Activation Date"}),e.jsx(o,{className:"whitespace-normal",children:"Original Cost"}),e.jsx(o,{className:"whitespace-normal",children:"Changes During the Year"}),e.jsx(o,{className:"whitespace-normal",children:"Total Depreciable Assets"}),e.jsx(o,{className:"whitespace-normal",children:"Statutory Depreciation Rate"}),e.jsx(o,{className:"whitespace-normal",children:"Claimed Depreciation Rate"}),e.jsx(o,{className:"whitespace-normal",children:"Depreciation Claimed This Year"}),e.jsx(o,{className:"whitespace-normal",children:"Previous Tax Years Accumulated Depreciation"}),e.jsx(o,{className:"whitespace-normal",children:"Total Depreciation"}),e.jsx(o,{className:"whitespace-normal",children:"Net Book Value"})]})]}),e.jsx(H,{children:u?.depreciationReport&&e.jsxs(e.Fragment,{children:[u.depreciationReport.categories.map((i,p)=>e.jsxs(d.Fragment,{children:[e.jsxs(D,{className:"font-bold",children:[e.jsx(a,{children:`Category ${p+1}`}),e.jsx(a,{colSpan:2,children:i.category.name}),e.jsx(a,{colSpan:3}),e.jsxs(a,{children:[n(i.category.percentage,0),"%"]}),e.jsx(a,{colSpan:5})]}),i.records.sort((h,Y)=>h.purchaseDate.localeCompare(Y.purchaseDate)).map(h=>e.jsx(W,{record:h},h.id)),e.jsx(N,{data:i.summary,groupName:i.category.name})]},i.id)),e.jsx(N,{data:u.depreciationReport.summary})]})})]})})};export{ne as DepreciationReport};
@@ -1,4 +1,4 @@
1
- import{d9 as so,da as Ds,db as Fs,dc as zs,r as v,aG as Ie,dd as $e,de as Ns,j as x,df as or,dg as io,bw as oo,B as ao,y as lo,bz as In,bA as Br,bJ as Vr,w as Le,bC as co,ay as En,bD as uo,dh as b,di as Bs,G as fo,dj as ho,F as po,u as mo,dk as go,L as xo,dl as yo}from"./index-CHtpNrAW.js";import{u as Vs}from"./use-url-query-DMunwqS4.js";import{P as vo}from"./page-layout-Cs7LzhPs.js";import{P as bo}from"./modal-YTgF-R03.js";import{F as wo}from"./funnel-4UXATjU3.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-DclIL89E.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 Ro,j as Us,k as Oo,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-UiWBdxTZ.js";import"./addDays-CpwSVE6j.js";import"./subMonths-DZvdAXT7.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),O=c;n.modifiersData[r]=(t={},t[O]=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",O="clientWidth";if(k===ae(n)&&(k=Ne(n),Me(k).position!=="static"&&a==="absolute"&&(E="scrollHeight",O="scrollWidth")),k=k,s===re||(s===se||s===he)&&i===kt){C=fe;var R=d&&k===P&&P.visualViewport?P.visualViewport.height:k[E];p-=R-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[O];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}),O=Xn(Object.assign({},A,E)),R=f===ht?O:k,j={top:P.top-R.top+y.top,bottom:R.bottom-P.bottom+y.bottom,left:P.left-R.left+y.left,right:R.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 Ra(e){if(we(e)===ar)return[];var t=en(e);return[Kr(e),t,Kr(t)]}function Oa(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)]:Ra(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,O=!0,R=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})){R=T,O=!1;break}E.set(T,V)}if(O)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 R=Q,"break"},G=N;G>0;G--){var ie=U(G);if(ie==="break")break}t.placement!==R&&(t.modifiersData[r]._skip=!0,t.placement=R,t.reset=!0)}}const Ta={name:"flip",enabled:!0,phase:"main",fn:Oa,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,O=t.rects.popper,R=typeof p=="function"?p(Object.assign({},t.rects,{placement:t.placement})):p,j=typeof R=="number"?{mainAxis:R,altAxis:R}:Object.assign({mainAxis:0,altAxis:0},R),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?-O[_]/2:0,U=w===nt?E[_]:O[_],G=w===nt?-O[_]:-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]-O[Ht]-Dr+j.altAxis,zr=Sn?ve+E[Ht]+O[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,O=E===void 0?{}:E,R=P.name;typeof k=="function"&&(u=k({state:u,options:O,name:R,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,O]=v.useState(k),[R,j]=v.useState(Wn(r));v.useEffect(()=>{A.current&&A.current.forceUpdate()}),v.useEffect(()=>{r&&j(Wn(r))},[r]),$e(()=>{if(!R||!c)return;const M=F=>{O(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(R,y.current,{placement:k,...u,modifiers:_});return P.current(D),()=>{D.destroy(),P.current(null)}},[R,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 O=!u&&c&&(!p||A)?"none":void 0,R=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:O,...m},TransitionProps:R,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}=lo({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:a.value?new Date(a.value):null,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:a.value?new Date(a.value):null,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(co,{...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}=Vs();function o(a){a||={fromDate:Le(new Date,"yyyy-MM-DD"),toDate:Le(new Date,"yyyy-MM-DD")},uo(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(bo,{opened:n,onClose:()=>r(!1),content:x.jsx(wl,{filter:e,setFilter:o,closeModal:()=>r(!1)})}),x.jsx(ao,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>r(!0),children:x.jsx(wo,{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"],Rl=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])},Ol=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),Rn={appearance:ni,ascending:ri,descending:yl,insideOut:vl,none:hn,reverse:bl},On={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:Rn.none,stackingOffset:On.none}):i[a]===void 0?(i[a]=s.length,s.push({ids:[o],stackingOrder:Rn[c??r?.stackOrder??"none"],stackingOffset:On[l??r?.stackOffset??"diverging"]})):(s[i[a]].ids.push(o),c!==void 0&&(s[i[a]].stackingOrder=Rn[c]),l!==void 0&&(s[i[a]].stackingOffset=On[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{d9 as so,da as Ds,db as Fs,dc as zs,r as v,aG as Ie,dd as $e,de as Ns,j as x,df as or,dg as io,bw as oo,B as ao,y as lo,bz as In,bA as Br,bJ as Vr,w as Le,bC as co,ay as En,bD as uo,dh as b,di as Bs,G as fo,dj as ho,F as po,u as mo,dk as go,L as xo,dl as yo}from"./index-qAF5sGRO.js";import{u as Vs}from"./use-url-query-CYeryni6.js";import{P as vo}from"./page-layout-7iCtDTzs.js";import{P as bo}from"./modal-D_KAAYCr.js";import{F as wo}from"./funnel-Cn1E8rCW.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-CJ6IUHKs.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 Ro,j as Us,k as Oo,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-DgacWlyb.js";import"./addDays-oqtNz11p.js";import"./subMonths-oKYDpkY2.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),O=c;n.modifiersData[r]=(t={},t[O]=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",O="clientWidth";if(k===ae(n)&&(k=Ne(n),Me(k).position!=="static"&&a==="absolute"&&(E="scrollHeight",O="scrollWidth")),k=k,s===re||(s===se||s===he)&&i===kt){C=fe;var R=d&&k===P&&P.visualViewport?P.visualViewport.height:k[E];p-=R-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[O];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}),O=Xn(Object.assign({},A,E)),R=f===ht?O:k,j={top:P.top-R.top+y.top,bottom:R.bottom-P.bottom+y.bottom,left:P.left-R.left+y.left,right:R.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 Ra(e){if(we(e)===ar)return[];var t=en(e);return[Kr(e),t,Kr(t)]}function Oa(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)]:Ra(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,O=!0,R=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})){R=T,O=!1;break}E.set(T,V)}if(O)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 R=Q,"break"},G=N;G>0;G--){var ie=U(G);if(ie==="break")break}t.placement!==R&&(t.modifiersData[r]._skip=!0,t.placement=R,t.reset=!0)}}const Ta={name:"flip",enabled:!0,phase:"main",fn:Oa,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,O=t.rects.popper,R=typeof p=="function"?p(Object.assign({},t.rects,{placement:t.placement})):p,j=typeof R=="number"?{mainAxis:R,altAxis:R}:Object.assign({mainAxis:0,altAxis:0},R),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?-O[_]/2:0,U=w===nt?E[_]:O[_],G=w===nt?-O[_]:-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]-O[Ht]-Dr+j.altAxis,zr=Sn?ve+E[Ht]+O[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,O=E===void 0?{}:E,R=P.name;typeof k=="function"&&(u=k({state:u,options:O,name:R,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,O]=v.useState(k),[R,j]=v.useState(Wn(r));v.useEffect(()=>{A.current&&A.current.forceUpdate()}),v.useEffect(()=>{r&&j(Wn(r))},[r]),$e(()=>{if(!R||!c)return;const M=F=>{O(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(R,y.current,{placement:k,...u,modifiers:_});return P.current(D),()=>{D.destroy(),P.current(null)}},[R,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 O=!u&&c&&(!p||A)?"none":void 0,R=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:O,...m},TransitionProps:R,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}=lo({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:a.value?new Date(a.value):null,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:a.value?new Date(a.value):null,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(co,{...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}=Vs();function o(a){a||={fromDate:Le(new Date,"yyyy-MM-DD"),toDate:Le(new Date,"yyyy-MM-DD")},uo(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(bo,{opened:n,onClose:()=>r(!1),content:x.jsx(wl,{filter:e,setFilter:o,closeModal:()=>r(!1)})}),x.jsx(ao,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>r(!0),children:x.jsx(wo,{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"],Rl=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])},Ol=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),Rn={appearance:ni,ascending:ri,descending:yl,insideOut:vl,none:hn,reverse:bl},On={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:Rn.none,stackingOffset:On.none}):i[a]===void 0?(i[a]=s.length,s.push({ids:[o],stackingOrder:Rn[c??r?.stackOrder??"none"],stackingOffset:On[l??r?.stackOffset??"diverging"]})):(s[i[a]].ids.push(o),c!==void 0&&(s[i[a]].stackingOrder=Rn[c]),l!==void 0&&(s[i[a]].stackingOffset=On[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:Ol,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(`