@canton-network/example-portfolio 0.20.0 → 0.21.0

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.
@@ -1 +0,0 @@
1
- import{E as ue,Q as ge,G as fe,r as b,g as me,a as be,u as ye,H as J,c as ve,j as e,J as j,b as je,s as ee,K as Ce,L as Ie,q as Ae,f as We,N as Oe,O as Re,R as Le,U as re,V as te,T as o,W as ne,B as s,X as se,k as A,Y as O,P as U,Z as S,t as T,_ as Te,$ as Se,a0 as ke,p as we,y as Y,A as Pe}from"./index-C7M4apWO.js";import{u as $e,a as ze}from"./useWithdrawAllocation-8IytAm-f.js";import{C as R}from"./copyable-identifier-BFf0ARYa.js";import{a as De,b as Be,c as Ee}from"./query-options-CM__kwHn.js";import{A as oe,S as G}from"./Avatar-C-49N7Fz.js";function Me(t,r){return ue({...t,enabled:!0,suspense:!0,throwOnError:fe,placeholderData:void 0},ge)}function ae(t){const r=b.useRef({});return b.useEffect(()=>{r.current=t}),r.current}function qe(t){const{badgeContent:r,invisible:n=!1,max:a=99,showZero:d=!1}=t,h=ae({badgeContent:r,max:a});let p=n;n===!1&&r===0&&!d&&(p=!0);const{badgeContent:l,max:c=a}=p?h:t,x=l&&Number(l)>c?`${c}+`:l;return{badgeContent:l,invisible:p,max:c,displayValue:x}}function Ve(t){return me("MuiBadge",t)}const W=be("MuiBadge",["root","badge","dot","standard","anchorOriginTopRight","anchorOriginBottomRight","anchorOriginTopLeft","anchorOriginBottomLeft","invisible","colorError","colorInfo","colorPrimary","colorSecondary","colorSuccess","colorWarning","overlapRectangular","overlapCircular","anchorOriginTopLeftCircular","anchorOriginTopLeftRectangular","anchorOriginTopRightCircular","anchorOriginTopRightRectangular","anchorOriginBottomLeftCircular","anchorOriginBottomLeftRectangular","anchorOriginBottomRightCircular","anchorOriginBottomRightRectangular"]),V=10,F=4,Fe=t=>{const{color:r,anchorOrigin:n,invisible:a,overlap:d,variant:h,classes:p={}}=t,l={root:["root"],badge:["badge",h,a&&"invisible",`anchorOrigin${j(n.vertical)}${j(n.horizontal)}`,`anchorOrigin${j(n.vertical)}${j(n.horizontal)}${j(d)}`,`overlap${j(d)}`,r!=="default"&&`color${j(r)}`]};return je(l,Ve,p)},Ue=ee("span",{name:"MuiBadge",slot:"Root"})({position:"relative",display:"inline-flex",verticalAlign:"middle",flexShrink:0}),Ne=ee("span",{name:"MuiBadge",slot:"Badge",overridesResolver:(t,r)=>{const{ownerState:n}=t;return[r.badge,r[n.variant],r[`anchorOrigin${j(n.anchorOrigin.vertical)}${j(n.anchorOrigin.horizontal)}${j(n.overlap)}`],n.color!=="default"&&r[`color${j(n.color)}`],n.invisible&&r.invisible]}})(Ce(({theme:t})=>({display:"flex",flexDirection:"row",flexWrap:"wrap",justifyContent:"center",alignContent:"center",alignItems:"center",position:"absolute",boxSizing:"border-box",fontFamily:t.typography.fontFamily,fontWeight:t.typography.fontWeightMedium,fontSize:t.typography.pxToRem(12),minWidth:V*2,lineHeight:1,padding:"0 6px",height:V*2,borderRadius:V,zIndex:1,transition:t.transitions.create("transform",{easing:t.transitions.easing.easeInOut,duration:t.transitions.duration.enteringScreen}),variants:[...Object.entries(t.palette).filter(Ie(["contrastText"])).map(([r])=>({props:{color:r},style:{backgroundColor:(t.vars||t).palette[r].main,color:(t.vars||t).palette[r].contrastText}})),{props:{variant:"dot"},style:{borderRadius:F,height:F*2,minWidth:F*2,padding:0}},{props:({ownerState:r})=>r.anchorOrigin.vertical==="top"&&r.anchorOrigin.horizontal==="right"&&r.overlap==="rectangular",style:{top:0,right:0,transform:"scale(1) translate(50%, -50%)",transformOrigin:"100% 0%",[`&.${W.invisible}`]:{transform:"scale(0) translate(50%, -50%)"}}},{props:({ownerState:r})=>r.anchorOrigin.vertical==="bottom"&&r.anchorOrigin.horizontal==="right"&&r.overlap==="rectangular",style:{bottom:0,right:0,transform:"scale(1) translate(50%, 50%)",transformOrigin:"100% 100%",[`&.${W.invisible}`]:{transform:"scale(0) translate(50%, 50%)"}}},{props:({ownerState:r})=>r.anchorOrigin.vertical==="top"&&r.anchorOrigin.horizontal==="left"&&r.overlap==="rectangular",style:{top:0,left:0,transform:"scale(1) translate(-50%, -50%)",transformOrigin:"0% 0%",[`&.${W.invisible}`]:{transform:"scale(0) translate(-50%, -50%)"}}},{props:({ownerState:r})=>r.anchorOrigin.vertical==="bottom"&&r.anchorOrigin.horizontal==="left"&&r.overlap==="rectangular",style:{bottom:0,left:0,transform:"scale(1) translate(-50%, 50%)",transformOrigin:"0% 100%",[`&.${W.invisible}`]:{transform:"scale(0) translate(-50%, 50%)"}}},{props:({ownerState:r})=>r.anchorOrigin.vertical==="top"&&r.anchorOrigin.horizontal==="right"&&r.overlap==="circular",style:{top:"14%",right:"14%",transform:"scale(1) translate(50%, -50%)",transformOrigin:"100% 0%",[`&.${W.invisible}`]:{transform:"scale(0) translate(50%, -50%)"}}},{props:({ownerState:r})=>r.anchorOrigin.vertical==="bottom"&&r.anchorOrigin.horizontal==="right"&&r.overlap==="circular",style:{bottom:"14%",right:"14%",transform:"scale(1) translate(50%, 50%)",transformOrigin:"100% 100%",[`&.${W.invisible}`]:{transform:"scale(0) translate(50%, 50%)"}}},{props:({ownerState:r})=>r.anchorOrigin.vertical==="top"&&r.anchorOrigin.horizontal==="left"&&r.overlap==="circular",style:{top:"14%",left:"14%",transform:"scale(1) translate(-50%, -50%)",transformOrigin:"0% 0%",[`&.${W.invisible}`]:{transform:"scale(0) translate(-50%, -50%)"}}},{props:({ownerState:r})=>r.anchorOrigin.vertical==="bottom"&&r.anchorOrigin.horizontal==="left"&&r.overlap==="circular",style:{bottom:"14%",left:"14%",transform:"scale(1) translate(-50%, 50%)",transformOrigin:"0% 100%",[`&.${W.invisible}`]:{transform:"scale(0) translate(-50%, 50%)"}}},{props:{invisible:!0},style:{transition:t.transitions.create("transform",{easing:t.transitions.easing.easeInOut,duration:t.transitions.duration.leavingScreen})}}]})));function X(t){return{vertical:t?.vertical??"top",horizontal:t?.horizontal??"right"}}const Qe=b.forwardRef(function(r,n){const a=ye({props:r,name:"MuiBadge"}),{anchorOrigin:d,className:h,classes:p,component:l,components:c={},componentsProps:x={},children:u,overlap:f="rectangular",color:m="default",invisible:y=!1,max:v=99,badgeContent:L,slots:w,slotProps:P,showZero:k=!1,variant:C="standard",...B}=a,{badgeContent:$,invisible:E,max:M,displayValue:i}=qe({max:v,invisible:y,badgeContent:L,showZero:k}),g=ae({anchorOrigin:X(d),color:m,overlap:f,variant:C,badgeContent:L}),I=E||$==null&&C!=="dot",{color:z=m,overlap:ie=f,anchorOrigin:le,variant:K=C}=I?g:a,ce=X(le),H=K!=="dot"?i:void 0,q={...a,badgeContent:$,invisible:I,max:M,displayValue:H,showZero:k,anchorOrigin:ce,color:z,overlap:ie,variant:K},_=Fe(q),Z={slots:{root:w?.root??c.Root,badge:w?.badge??c.Badge},slotProps:{root:P?.root??x.root,badge:P?.badge??x.badge}},[de,xe]=J("root",{elementType:Ue,externalForwardedProps:{...Z,...B},ownerState:q,className:ve(_.root,h),ref:n,additionalProps:{as:l}}),[pe,he]=J("badge",{elementType:Ne,externalForwardedProps:Z,ownerState:q,className:_.badge});return e.jsxs(de,{...xe,children:[u,e.jsx(pe,{...he,children:H})]})}),Ke=()=>{const{exerciseTransfer:t}=Ae(),r=We(),n=Oe();return Re({mutationFn:async a=>t({registryUrls:r,...a}),onSuccess:async(a,d)=>{await n.invalidateQueries({queryKey:Le.listPendingTransfers.forParty(d.party)})}})},N=t=>t.currentPartyId===t.receiver,D=t=>N(t)?{label:"Sender",value:t.sender}:{label:"Receiver",value:t.receiver},Q=(t,r)=>t===r.transferLeg.sender,He=(t,r)=>t===r.transferLeg.receiver,_e=t=>t.transferLegs.filter(r=>Q(t.currentPartyId,r)&&r.allocations.length===0),Ze=t=>t.transferLegs.filter(r=>Q(t.currentPartyId,r)&&r.allocations.length>0),Je=t=>{const{item:r,open:n,isLoading:a,onClose:d,onAccept:h,onReject:p,onWithdraw:l}=t,c=()=>{a||d()};return e.jsxs(re,{open:n,onClose:c,maxWidth:"md",fullWidth:!0,disableEscapeKeyDown:a,children:[e.jsx(te,{sx:{pb:1},children:e.jsx(o,{variant:"h6",component:"div",fontWeight:"bold",children:"Transfer Details"})}),e.jsx(ne,{sx:{py:2},children:r&&e.jsxs(s,{sx:{display:"flex",flexDirection:"column",gap:3},children:[e.jsxs(s,{sx:{display:"flex",gap:3,p:2,borderRadius:2,border:"1px solid",borderColor:"divider"},children:[e.jsxs(s,{sx:{flex:1},children:[e.jsx(o,{variant:"caption",color:"text.secondary",sx:{fontWeight:500,textTransform:"uppercase",letterSpacing:.5},children:"Amount"}),e.jsxs(o,{variant:"h6",fontWeight:"bold",children:[r.amount," ",r.instrumentId.id]})]}),e.jsxs(s,{sx:{flex:1},children:[e.jsx(o,{variant:"caption",color:"text.secondary",sx:{fontWeight:500,textTransform:"uppercase",letterSpacing:.5},children:"Type"}),e.jsx(s,{sx:{display:"flex",alignItems:"center",gap:1},children:e.jsx(o,{variant:"body2",fontWeight:"medium",children:"Transfer Offer"})})]})]}),e.jsxs(s,{sx:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:3},children:[e.jsxs(s,{sx:{p:2,borderRadius:1,border:"1px solid",borderColor:"divider"},children:[e.jsx(o,{variant:"caption",color:"text.secondary",sx:{fontWeight:500,textTransform:"uppercase",letterSpacing:.5,mb:1,display:"block"},children:"Created"}),e.jsx(o,{variant:"body1",fontWeight:"medium",children:r.date})]}),e.jsxs(s,{sx:{p:2,borderRadius:1,border:"1px solid",borderColor:"divider"},children:[e.jsx(o,{variant:"caption",color:"text.secondary",sx:{fontWeight:500,textTransform:"uppercase",letterSpacing:.5,mb:1,display:"block"},children:"Expires"}),e.jsx(o,{variant:"body1",fontWeight:"medium",children:r.expiry})]})]}),e.jsxs(s,{sx:{p:2,borderRadius:1,border:"1px solid",borderColor:"divider"},children:[e.jsx(o,{variant:"caption",color:"text.secondary",sx:{fontWeight:500,textTransform:"uppercase",letterSpacing:.5,mb:1,display:"block"},children:D(r).label}),e.jsx(s,{sx:{display:"flex",alignItems:"center",gap:1},children:e.jsx(R,{value:D(r).value,maxLength:60})})]}),e.jsxs(s,{sx:{p:2,borderRadius:1,border:"1px solid",borderColor:"divider"},children:[e.jsx(o,{variant:"caption",color:"text.secondary",sx:{fontWeight:500,textTransform:"uppercase",letterSpacing:.5,mb:1,display:"block"},children:"Message"}),e.jsx(o,{variant:"body1",sx:{wordBreak:"break-word",lineHeight:1.6,color:"text.primary"},children:r.message})]}),e.jsxs(s,{sx:{p:2,borderRadius:1,border:"1px solid",borderColor:"divider"},children:[e.jsx(o,{variant:"caption",color:"text.secondary",sx:{fontWeight:500,textTransform:"uppercase",letterSpacing:.5,mb:1,display:"block"},children:"Contract ID"}),e.jsx(s,{sx:{display:"flex",alignItems:"center",gap:1},children:e.jsx(R,{value:r.id,maxLength:60})})]})]})}),e.jsxs(se,{sx:{px:3,pb:3,gap:2},children:[e.jsx(A,{onClick:c,variant:"outlined",color:"inherit",sx:{minWidth:100},disabled:a,children:"Cancel"}),e.jsx(s,{sx:{flex:1}}),r&&N(r)?e.jsxs(e.Fragment,{children:[e.jsx(A,{variant:"outlined",color:"error",sx:{minWidth:100},disabled:a,onClick:()=>p(r),children:a?e.jsx(O,{size:20,color:"inherit"}):"Reject"}),e.jsx(A,{variant:"contained",sx:{minWidth:100},disabled:a,onClick:()=>h(r),children:a?e.jsx(O,{size:20,color:"inherit"}):"Accept"})]}):e.jsx(A,{variant:"outlined",color:"warning",sx:{minWidth:100},disabled:a,onClick:()=>r&&l(r),children:a?e.jsx(O,{size:20,color:"inherit"}):"Withdraw"})]})]})},Ye=t=>{const{item:r,isLoading:n,onClick:a,onAccept:d,onReject:h,onWithdraw:p}=t;return e.jsxs(U,{elevation:1,variant:"elevation",sx:{p:2,display:"flex",justifyContent:"space-between",alignItems:"center",borderRadius:0,gap:2,cursor:n?"default":"pointer",opacity:n?.7:1,"&:hover":{backgroundColor:n?"inherit":"action.hover"}},onClick:()=>!n&&a(),children:[e.jsxs(s,{sx:{display:"flex",alignItems:"center",gap:3},children:[e.jsxs(s,{sx:{minWidth:120,flexShrink:0},children:[e.jsx(o,{variant:"body2",color:"textSecondary",children:"Type"}),e.jsx(o,{variant:"body1",fontWeight:"medium",children:r.type})]}),e.jsxs(s,{sx:{minWidth:80,flexShrink:0},children:[e.jsx(o,{variant:"body2",color:"textSecondary",children:"Amount"}),e.jsxs(o,{variant:"body1",children:[r.amount," ",r.instrumentId.id]})]}),e.jsxs(s,{sx:{minWidth:100,flexShrink:0},children:[e.jsx(o,{variant:"body2",color:"textSecondary",children:"Expires"}),e.jsx(o,{variant:"body1",children:r.expiry})]}),e.jsxs(s,{sx:{minWidth:100,flexShrink:0},children:[e.jsx(o,{variant:"body2",color:"textSecondary",children:D(r).label}),e.jsx(R,{value:D(r).value})]}),e.jsxs(s,{sx:{flex:1,minWidth:150},children:[e.jsx(o,{variant:"body2",color:"textSecondary",children:"Message"}),e.jsx(o,{variant:"body1",sx:{wordBreak:"break-word"},children:r.message.slice(0,30)+"..."})]})]}),e.jsx(s,{sx:{display:"flex",gap:2},children:N(r)?e.jsxs(e.Fragment,{children:[e.jsx(A,{variant:"contained",size:"small",sx:{minWidth:80},disabled:n,onClick:l=>{l.stopPropagation(),d()},children:n?e.jsx(O,{size:16,color:"inherit"}):"Accept"}),e.jsx(A,{variant:"outlined",size:"small",sx:{minWidth:80},disabled:n,onClick:l=>{l.stopPropagation(),h()},children:n?e.jsx(O,{size:16,color:"inherit"}):"Reject"})]}):e.jsx(A,{variant:"outlined",color:"warning",size:"small",sx:{minWidth:80},disabled:n,onClick:l=>{l.stopPropagation(),p()},children:n?e.jsx(O,{size:16,color:"inherit"}):"Withdraw"})})]})},Ge=t=>{const{item:r,isLoading:n,onClick:a}=t,d=_e(r),h=Ze(r),p=d.length>0,l=h.length>0,c=()=>p&&l?`${d.length} pending, ${h.length} allocated`:p?`${d.length} transfer leg${d.length>1?"s":""} requires allocation`:`${h.length} allocated`;return e.jsx(U,{elevation:1,variant:"elevation",sx:{p:2,display:"flex",justifyContent:"space-between",alignItems:"center",borderRadius:0,gap:2,cursor:n?"default":"pointer",opacity:n?.7:1,"&:hover":{backgroundColor:n?"inherit":"action.hover"}},onClick:()=>!n&&a(),children:e.jsxs(s,{sx:{display:"flex",alignItems:"center",gap:3},children:[e.jsxs(s,{sx:{minWidth:120,flexShrink:0},children:[e.jsx(o,{variant:"body2",color:"textSecondary",children:"Type"}),e.jsx(o,{variant:"body1",fontWeight:"medium",children:"Allocation"})]}),e.jsxs(s,{sx:{minWidth:100,flexShrink:0},children:[e.jsx(o,{variant:"body2",color:"textSecondary",children:"Allocate Before"}),e.jsx(o,{variant:"body1",children:r.expiry})]}),e.jsxs(s,{sx:{minWidth:100,flexShrink:0},children:[e.jsx(o,{variant:"body2",color:"textSecondary",children:"Transfer Legs"}),e.jsx(o,{variant:"body1",children:r.transferLegs.length})]}),e.jsxs(s,{sx:{flex:1,minWidth:150},children:[e.jsx(o,{variant:"body2",color:"textSecondary",children:"Status"}),e.jsx(o,{variant:"body1",sx:{color:p?"warning.main":"success.main"},children:c()})]})]})})},Xe=t=>{const{item:r,open:n,isLoading:a,loadingLegId:d,onClose:h,onCreateAllocation:p,onWithdrawAllocation:l}=t,c=()=>{a||h()};return e.jsxs(re,{open:n,onClose:c,maxWidth:"md",fullWidth:!0,disableEscapeKeyDown:a,children:[e.jsx(te,{sx:{pb:1},children:e.jsx(o,{variant:"h6",component:"div",fontWeight:"bold",children:"Allocation Details"})}),e.jsx(ne,{sx:{py:2},children:r&&e.jsxs(s,{sx:{display:"flex",flexDirection:"column",gap:3},children:[e.jsxs(s,{sx:{p:2,borderRadius:2,border:"1px solid",borderColor:"divider"},children:[e.jsx(o,{variant:"caption",color:"text.secondary",sx:{fontWeight:500,textTransform:"uppercase",letterSpacing:.5},children:"Type"}),e.jsx(o,{variant:"body2",fontWeight:"medium",children:"Allocation Request"})]}),e.jsxs(s,{sx:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:3},children:[e.jsxs(s,{sx:{p:2,borderRadius:1,border:"1px solid",borderColor:"divider"},children:[e.jsx(o,{variant:"caption",color:"text.secondary",sx:{fontWeight:500,textTransform:"uppercase",letterSpacing:.5,mb:1,display:"block"},children:"Settlement Reference"}),e.jsx(R,{value:r.settlement.settlementRef.id,maxLength:40})]}),e.jsxs(s,{sx:{p:2,borderRadius:1,border:"1px solid",borderColor:"divider"},children:[e.jsx(o,{variant:"caption",color:"text.secondary",sx:{fontWeight:500,textTransform:"uppercase",letterSpacing:.5,mb:1,display:"block"},children:"Allocate Before"}),e.jsx(o,{variant:"body1",fontWeight:"medium",children:r.expiry})]})]}),e.jsxs(s,{sx:{p:2,borderRadius:1,border:"1px solid",borderColor:"divider"},children:[e.jsx(o,{variant:"caption",color:"text.secondary",sx:{fontWeight:500,textTransform:"uppercase",letterSpacing:.5,mb:1,display:"block"},children:"Executor"}),e.jsx(R,{value:r.settlement.executor,maxLength:60})]}),e.jsxs(s,{children:[e.jsxs(o,{variant:"subtitle1",fontWeight:"bold",sx:{mb:2},children:["Transfer Legs (",r.transferLegs.length,")"]}),e.jsx(s,{sx:{display:"flex",flexDirection:"column",gap:2},children:r.transferLegs.map(x=>e.jsx(er,{leg:x,currentPartyId:r.currentPartyId,isLoading:a,isLegLoading:d===x.transferLegId,onCreateAllocation:()=>p(x),onWithdrawAllocation:u=>l(x,u)},x.transferLegId))})]})]})}),e.jsx(se,{sx:{px:3,pb:3,gap:2},children:e.jsx(A,{onClick:c,variant:"outlined",color:"inherit",sx:{minWidth:100},disabled:a,children:"Close"})})]})},er=({leg:t,currentPartyId:r,isLoading:n,isLegLoading:a,onCreateAllocation:d,onWithdrawAllocation:h})=>{const p=Q(r,t),l=He(r,t),c=t.allocations.length>0,x=()=>p&&l?e.jsx(S,{label:"Self-transfer",size:"small",color:"info"}):p?e.jsx(S,{label:"Sender",size:"small",color:"primary"}):l?e.jsx(S,{label:"Receiver",size:"small",color:"secondary"}):e.jsx(S,{label:"Observer",size:"small"});return e.jsxs(s,{sx:{p:2,borderRadius:1,border:"1px solid",borderColor:c?"success.light":"divider",backgroundColor:c?"success.50":"transparent"},children:[e.jsxs(s,{sx:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",mb:2},children:[e.jsxs(s,{sx:{display:"flex",alignItems:"center",gap:1},children:[e.jsxs(o,{variant:"body2",fontWeight:"medium",children:["Leg: ",t.transferLegId]}),x(),c&&e.jsx(S,{label:"Allocated",size:"small",color:"success"})]}),p&&e.jsx(s,{sx:{display:"flex",gap:1},children:c?t.allocations.map(u=>e.jsx(A,{variant:"outlined",color:"warning",size:"small",disabled:n,onClick:()=>h(u.contractId),children:a?e.jsx(O,{size:16,color:"inherit"}):"Withdraw"},u.contractId)):e.jsx(A,{variant:"contained",size:"small",disabled:n,onClick:d,children:a?e.jsx(O,{size:16,color:"inherit"}):"Create Allocation"})})]}),e.jsxs(s,{sx:{display:"grid",gridTemplateColumns:"repeat(3, 1fr)",gap:2},children:[e.jsxs(s,{children:[e.jsx(o,{variant:"caption",color:"text.secondary",children:"Amount"}),e.jsxs(o,{variant:"body2",children:[t.transferLeg.amount," ",t.transferLeg.instrumentId.id]})]}),e.jsxs(s,{children:[e.jsx(o,{variant:"caption",color:"text.secondary",children:"Sender"}),e.jsx(R,{value:t.transferLeg.sender,maxLength:20})]}),e.jsxs(s,{children:[e.jsx(o,{variant:"caption",color:"text.secondary",children:"Receiver"}),e.jsx(R,{value:t.transferLeg.receiver,maxLength:20})]})]})]})},rr=({items:t})=>{const[r,n]=b.useState(null),[a,d]=b.useState(!1),[h,p]=b.useState(null),[l,c]=b.useState(!1),[x,u]=b.useState(null),f=b.useMemo(()=>{if(!h)return null;const i=t.find(g=>g.kind==="allocation"&&g.id===h);return i||null},[t,h]),[m,y]=b.useState(null),v=Ke(),L=$e(),w=ze(),P=i=>{n(i),d(!0)},k=()=>{d(!1),n(null)},C=(i,g)=>{y(i.id),v.mutate({party:i.currentPartyId,contractId:i.id,instrumentId:i.instrumentId,instructionChoice:g},{onSuccess:()=>{T.success(`${g} transfer successful`),k()},onError:I=>T.error(`Failed to ${g.toLowerCase()} transfer: ${I instanceof Error?I.message:"Unknown error"}`),onSettled:()=>y(null)})},B=i=>{p(i.id),c(!0)},$=()=>{c(!1),p(null)},E=(i,g)=>{y(i.id),u(g.transferLegId),L.mutate({party:i.currentPartyId,allocationSpecification:{settlement:i.settlement,transferLegId:g.transferLegId,transferLeg:g.transferLeg}},{onSuccess:()=>{T.success("Allocation created successfully")},onError:I=>T.error(`Failed to create allocation: ${I instanceof Error?I.message:"Unknown error"}`),onSettled:()=>{y(null),u(null)}})},M=(i,g,I)=>{y(i.id),u(g.transferLegId),w.mutate({party:i.currentPartyId,contractId:I,instrumentId:g.transferLeg.instrumentId},{onSuccess:()=>{T.success("Allocation withdrawn successfully")},onError:z=>T.error(`Failed to withdraw allocation: ${z instanceof Error?z.message:"Unknown error"}`),onSettled:()=>{y(null),u(null)}})};return t.length===0?null:e.jsxs(s,{sx:{mb:6},children:[e.jsxs(s,{sx:{display:"flex",mb:2},children:[e.jsx(o,{variant:"h6",sx:{textTransform:"uppercase"},fontWeight:"bold",children:"Action Required"}),e.jsx(Qe,{badgeContent:t.length,color:"error",sx:{ml:2}})]}),e.jsx(s,{sx:{display:"flex",flexDirection:"column",gap:2},children:t.map(i=>{const g=m===i.id;switch(i.kind){case"allocation":return e.jsx(Ge,{item:i,isLoading:g,onClick:()=>B(i)},i.id);case"transfer":return e.jsx(Ye,{item:i,isLoading:g,onClick:()=>P(i),onAccept:()=>C(i,"Accept"),onReject:()=>C(i,"Reject"),onWithdraw:()=>C(i,"Withdraw")},i.id)}})}),e.jsx(Je,{item:r,open:a,isLoading:m!==null,onClose:k,onAccept:i=>C(i,"Accept"),onReject:i=>C(i,"Reject"),onWithdraw:i=>C(i,"Withdraw")}),e.jsx(Xe,{item:f,open:l,isLoading:m!==null,loadingLegId:x,onClose:$,onCreateAllocation:i=>f&&E(f,i),onWithdrawAllocation:(i,g)=>f&&M(f,i,g)})]})},tr=({partyId:t,walletName:r,isPrimary:n})=>{const{instruments:a,isLoading:d}=Te(t),h=a.length>0,p=e.jsxs(s,{sx:{p:1,display:"flex",justifyContent:"center",alignItems:"center",textAlign:"center"},children:[e.jsx(oe,{sx:{visibility:"hidden",m:1,height:25,width:25}}),e.jsx(o,{sx:{position:"absolute"},children:"There are currently no assets in this wallet"})]}),l=e.jsxs(s,{sx:{p:1},children:[e.jsx(G,{variant:"rectangular",height:40}),e.jsx(G,{variant:"rectangular",height:40,sx:{mt:1}})]}),c=a.map(x=>e.jsx(nr,{item:x},`${x.instrumentId.admin}::${x.instrumentId.id}`));return e.jsx(Se,{to:"/wallet/$walletId",params:{walletId:t},style:{textDecoration:"none",color:"inherit"},children:e.jsxs(s,{"data-testid":`wallet-preview-${t}`,sx:{display:"flex",flexDirection:"column"},children:[e.jsxs(s,{sx:{mb:1,display:"flex",flexDirection:"row",alignItems:"center",gap:1},children:[e.jsx(o,{sx:{textOverflow:"ellipsis",overflow:"hidden",whiteSpace:"nowrap",maxWidth:"200px"},fontWeight:"bold",color:"secondary",children:r}),n&&e.jsx(S,{label:"Primary",size:"small",color:"primary"})]}),e.jsx(s,{component:U,variant:"outlined",sx:{background:x=>x.palette.mode==="dark"?void 0:x.palette.grey[100],display:"flex",flexDirection:"column",cursor:"pointer",transition:"all 0.2s ease-in-out","&:hover":{borderColor:"primary.main",boxShadow:1}},children:d?l:h?c:p})]})})},nr=({item:t})=>{const r=t.instrument?.symbol??t.instrumentId.id,n=t.instrument?.name??t.instrumentId.id,a=t.lockedAmount!=="0";return e.jsxs(s,{"data-testid":`instrument-row-${r}`,borderRadius:0,sx:{"&:not(:first-of-type)":{borderTop:d=>`1px solid ${d.palette.divider}`},p:1,display:"flex",alignItems:"center"},children:[e.jsx(oe,{sx:{m:1,height:25,width:25},children:r[0]}),e.jsxs(s,{children:[e.jsx(o,{sx:{maxWidth:"100px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},color:"textSecondary",variant:"body2",children:n}),e.jsxs(o,{"data-testid":"instrument-total-amount",variant:"body2",fontWeight:"700",children:[t.totalAmount," ",r,a&&e.jsxs(o,{"data-testid":"instrument-available-amount",component:"span",variant:"body2",color:"textSecondary",sx:{ml:.5},children:["(",t.availableAmount," available)"]})]})]})]})},sr=()=>{const t=ke().slice().sort((r,n)=>Number(r.primary)-Number(n.primary));return e.jsxs(s,{sx:{mt:1},children:[e.jsx(o,{variant:"h6",sx:{textTransform:"uppercase",mb:2},fontWeight:"bold",children:"Wallets"}),e.jsx(s,{sx:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:6},children:t.map(r=>e.jsx(tr,{partyId:r.partyId,walletName:r.hint,isPrimary:r.primary},r.partyId))})]})};function dr(){const t=we()?.partyId,r=Me(De(t)),{data:n}=Y(Be(t)),{data:a}=Y(Ee(t)),d=b.useCallback((l,c)=>JSON.stringify([l.settlementRef.id,l.settlementRef.cid,c]),[]),h=b.useMemo(()=>{const l=new Map;for(const c of n??[]){const{settlement:x,transferLegs:u}=c.interfaceViewValue;for(const f in u){const m=d(x,f);l.set(m,[])}}for(const c of a??[]){const{settlement:x,transferLegId:u}=c.interfaceViewValue.allocation,f=d(x,u);l.has(f)&&l.get(f).push(c)}return l},[n,a,d]),p=b.useMemo(()=>{if(!t)return[];const l=[];if(r.data)for(const c of r.data){const x=c.interfaceViewValue,u=x.transfer,f=x.status,m="tag"in f?f.tag:f.current?.tag,y=u?.meta?.values?.[Pe.MEMO_KEY]??"",v={kind:"transfer",id:c.contractId,currentPartyId:t,tag:m,type:m?.startsWith("Transfer")?"Transfer":m,date:u.requestedAt,expiry:u.executeBefore,message:y,sender:u.sender,receiver:u.receiver,instrumentId:u.instrumentId,amount:u?.amount};l.push(v)}if(n)for(const c of n){const{settlement:x,transferLegs:u}=c.interfaceViewValue,m=Object.entries(u).map(([v,L])=>({transferLegId:v,transferLeg:L,allocations:h.get(d(x,v))??[]})).filter(v=>v.transferLeg.sender===t||v.transferLeg.receiver===t);if(m.length===0)continue;const y={kind:"allocation",id:c.contractId,currentPartyId:t,expiry:x.allocateBefore,settlement:x,transferLegs:m};l.push(y)}return l},[r.data,n,h,t,d]);return e.jsxs(s,{sx:{my:8},children:[e.jsx(o,{variant:"h3",component:"h1",sx:{mb:6},children:"Dashboard"}),e.jsx(rr,{items:p}),e.jsx(sr,{})]})}export{dr as component};
@@ -1 +0,0 @@
1
- import{z as R,j as e,v as P,r as h,n as I,p as x,q as y,f as b,A as C,e as H,y as f,C as D}from"./index-C7M4apWO.js";import{a as V,b as N,c as U}from"./query-options-CM__kwHn.js";import{u as E,a as M}from"./useTransactionHistory-DGWGZTMt.js";import{u as O,a as q}from"./useWithdrawAllocation-8IytAm-f.js";const p=({name:t,amount:s,instrument:o})=>{const i=R(o),a=`${o.id} from admin ${o.admin}`;return e.jsxs("span",{children:[t&&e.jsx("span",{children:t}),e.jsx("strong",{children:s}),i?e.jsxs("span",{title:a,children:[" ",i.instrument.symbol]}):e.jsxs("span",{title:a,children:[" ",o.id," (warning: unknown instrument)"]})]})},w=({value:t,onChange:s})=>{const o=P(),i=new Map;let a="";for(const[c,u]of o)for(const d of u){if(i.has(d.symbol))throw new Error(`duplicate symbol: ${d.symbol}`);i.set(d.symbol,{admin:c,id:d.id}),d.id===t?.id&&c===t?.admin&&(a=d.symbol)}const l=[...i.keys()].sort(),[r,n]=h.useState(a);return e.jsxs("select",{className:"select-instrument",value:r,onChange:c=>{n(c.target.value),s(i.get(c.target.value))},children:[e.jsx("option",{value:"",children:"Select an option..."},""),l.map(c=>e.jsx("option",{value:c,children:c},c))]})},F=()=>{const t=I().status?.session?.accessToken,s=x()?.partyId,{listHoldings:o,tap:i}=y(),a=b(),[l,r]=h.useState(void 0),[n,c]=h.useState(void 0),[u,d]=h.useState(1e4),g=new Date,j=h.useCallback(async()=>{if(s){const m=await o({party:s});r(m)}else r(void 0)},[s,o]);return h.useEffect(()=>{let m=!1;return(async()=>{if(s){const k=await o({party:s});m||r(k)}else r(void 0)})(),()=>{m=!0}},[s,o]),e.jsxs("div",{children:[e.jsxs("form",{onSubmit:m=>m.preventDefault(),className:"tap",children:[e.jsx(w,{value:n,onChange:m=>c(m)}),e.jsx("input",{type:"number",value:u,onChange:m=>d(Number(m.target.value))}),e.jsx("button",{type:"submit",disabled:!t||!s||!n,onClick:()=>{i({registryUrls:a,party:s,sessionToken:t,instrumentId:n,amount:u}).then(()=>j())},children:"TAP"})]}),e.jsx("ul",{children:l?.map(m=>e.jsxs("li",{children:[C.isHoldingLocked(m,g)&&e.jsx("span",{children:"🔒"}),e.jsx(p,{amount:m.amount,instrument:m.instrumentId})]},m.contractId))})]})},B=()=>{const t=H(),s=b(),[o,i]=h.useState(""),[a,l]=h.useState(""),r=[...s.keys()];return r.sort(),e.jsxs("div",{children:[e.jsx("h2",{children:"Registries"}),e.jsxs("table",{children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Party ID"}),e.jsx("th",{children:"Registry URL"})]})}),e.jsx("tbody",{children:r.map(n=>e.jsxs("tr",{children:[e.jsx("td",{children:n}),e.jsx("td",{children:s.get(n)}),e.jsx("td",{children:e.jsx("button",{type:"submit",onClick:()=>t.deleteRegistryUrl(n),children:"🗑️"})})]},n))})]}),e.jsx("h2",{children:"Add new registry"}),e.jsxs("form",{onSubmit:n=>n.preventDefault(),children:[e.jsx("p",{children:"The party ID is optional and will be retrieved from the URL if not specified. Note that in this case you need to trust the URL to provide the right information."}),e.jsx("label",{htmlFor:"partyId",children:"Party ID: "}),e.jsx("input",{id:"partyId",value:o,onChange:n=>i(n.target.value)}),e.jsx("br",{}),e.jsx("label",{htmlFor:"url",children:"Registry URL: "}),e.jsx("input",{id:"url",value:a,onChange:n=>l(n.target.value)}),e.jsx("br",{}),e.jsx("button",{type:"submit",onClick:async()=>t.setRegistryUrl(o&&void 0,a),children:"Add registry"})]})]})},L=()=>{const t=x()?.partyId;return f(V(t))},A=({party:t,contractId:s,transferInstructionView:o})=>{const i=b(),{exerciseTransfer:a}=y(),l=o.transfer,r=o.status,{meta:n}=l,c=n.values[C.MEMO_KEY],u="tag"in r?r.tag:r.current?.tag;return e.jsxs("div",{children:["status: ",e.jsx("strong",{children:u})," ",e.jsx("br",{}),"sender: ",e.jsx("strong",{children:l.sender})," ",e.jsx("br",{}),"receiver: ",e.jsx("strong",{children:l.receiver})," ",e.jsx("br",{}),c&&e.jsxs("span",{children:["message: ",e.jsx("strong",{children:c})," ",e.jsx("br",{})]}),e.jsx(p,{amount:l.amount,instrument:l.instrumentId}),u==="TransferPendingReceiverAcceptance"&&l.receiver===t&&e.jsxs("div",{children:[e.jsx("button",{disabled:!s,onClick:()=>{a({registryUrls:i,party:t,contractId:s,instrumentId:l.instrumentId,instructionChoice:"Accept"})},children:"Accept"}),e.jsx("button",{disabled:!s,onClick:()=>{a({registryUrls:i,party:t,contractId:s,instrumentId:l.instrumentId,instructionChoice:"Reject"})},children:"Reject"})]}),l.status=="pending"&&!l.incoming&&e.jsx("button",{onClick:()=>{a({registryUrls:i,party:t,contractId:l.contractId,instrumentId:l.instrumentId,instructionChoice:"Withdraw"})},children:"Withdraw"})]})},W=()=>{const t=x()?.partyId,{data:s}=L();return e.jsxs("div",{children:[e.jsx("h2",{children:"Pending transfers"}),t&&e.jsx("ul",{children:s?.map(o=>e.jsx("li",{children:e.jsx(A,{party:t,contractId:o.contractId,transferInstructionView:o.interfaceViewValue})},o.contractId))})]})},$=()=>{const t=x()?.partyId,{mutate:s}=D(),[o,i]=h.useState(""),[a,l]=h.useState(100),[r,n]=h.useState(""),[c,u]=h.useState(void 0);return e.jsxs("form",{onSubmit:d=>d.preventDefault(),children:[e.jsx("label",{htmlFor:"instrument",children:"Instrument "}),e.jsx(w,{value:c,onChange:d=>u(d)}),e.jsx("br",{}),e.jsx("label",{htmlFor:"receiver",children:"Receiver: "}),e.jsx("input",{id:"receiver",value:o,onChange:d=>i(d.target.value)}),e.jsx("br",{}),e.jsx("label",{htmlFor:"amount",children:"Amount to transfer: "}),e.jsx("input",{id:"amount",type:"number",value:a,onChange:d=>l(Number(d.target.value))}),e.jsx("br",{}),e.jsx("label",{htmlFor:"memo",children:"Message for receiver: "}),e.jsx("input",{id:"memo",value:r,onChange:d=>n(d.target.value)}),e.jsx("br",{}),e.jsx("button",{type:"submit",disabled:!t||!c,onClick:()=>{s({instrumentId:c,sender:t,receiver:o,amount:`${a}`,expiry:new Date(Date.now()+1440*60*1e3),memo:r||void 0})},children:"Transfer"})]})},v=({change:t})=>e.jsxs("span",{children:["In:",e.jsx(p,{instrument:t.instrumentId,amount:t.inputAmount}),", Out:",e.jsx(p,{instrument:t.instrumentId,amount:t.outputAmount}),", Change:",e.jsx(p,{instrument:t.instrumentId,amount:t.amountChange})]}),Q=()=>{const t=x()?.partyId,{status:s,fetchNextPage:o,isFetchingNextPage:i,hasNextPage:a}=E(),l=M();return e.jsxs("div",{children:[e.jsx("h2",{children:"Transaction History"}),t&&l.map(r=>e.jsxs("div",{children:[e.jsxs("code",{children:["At ",r.offset," (",r.recordTime,")"]}),e.jsx("br",{}),r.events.map((n,c)=>e.jsx("div",{children:n.transferInstruction?e.jsx(A,{party:t,transferInstructionView:n.transferInstruction}):e.jsxs("div",{children:[e.jsx("strong",{children:n.label.type}),n.lockedHoldingsChangeSummaries.length>0&&e.jsxs("div",{children:[e.jsx("strong",{children:"Locked:"}),n.lockedHoldingsChangeSummaries.map((u,d)=>e.jsx(v,{change:u},d))]}),n.unlockedHoldingsChangeSummaries.length>0&&e.jsxs("div",{children:[e.jsx("strong",{children:"Locked:"}),n.unlockedHoldingsChangeSummaries.map((u,d)=>e.jsx(v,{change:u},d))]})]})},c))]},r.updateId)),!a&&e.jsx("span",{children:"(end)"}),s==="pending"&&e.jsx("span",{children:"⏳"}),!i&&a&&t&&e.jsx("button",{disabled:i||!a||!t,onClick:()=>o(),children:"load more"})]})},G=()=>{const{error:t,status:s,connect:o,open:i,disconnect:a}=I(),l=s?.connection?.isConnected,r=x()?.partyId;return e.jsxs("div",{className:"card",children:[!l&&e.jsx("button",{onClick:()=>o(),children:"connect to Wallet Gateway"}),l&&e.jsx("button",{onClick:()=>a(),children:"disconnect"}),e.jsx("button",{onClick:()=>i(),children:"open Wallet Gateway"}),t&&e.jsxs("p",{className:"error",children:[e.jsx("b",{children:"Error:"})," ",e.jsx("i",{children:t})]}),e.jsx("br",{}),l&&e.jsxs("div",{children:["Party: ",r,e.jsx("br",{}),"SessionToken: ",s?.session?.accessToken?"ok":"nope"]})]})},K=()=>{const t=x()?.partyId;return f(N(t))},T=()=>{const t=x()?.partyId;return f(U(t))},S=({transferLegId:t,transferLeg:s})=>e.jsxs("div",{children:[e.jsxs("h3",{children:["Transfer leg ",t]}),e.jsx("strong",{children:"sender:"})," ",s.sender,e.jsx("br",{}),e.jsx("strong",{children:"receiver:"})," ",s.receiver,e.jsx("br",{}),e.jsx(p,{amount:s.amount,instrument:s.instrumentId})]}),X=({party:t,contractId:s,allocation:o})=>{const{settlement:i,transferLeg:a,transferLegId:l}=o.allocation,r=b(),{withdrawAllocation:n}=y(),{refetch:c}=T();return e.jsxs("div",{children:[e.jsx("h3",{children:"Settlement"}),e.jsx("strong",{children:"executor:"})," ",i.executor,e.jsx("br",{}),e.jsx("strong",{children:"allocateBefore:"})," ",i.allocateBefore,new Date(i.allocateBefore)<=new Date&&"(EXPIRED!)",e.jsx("br",{}),e.jsx(S,{transferLegId:l,transferLeg:a}),a.sender===t&&e.jsx("button",{onClick:async()=>{await n({registryUrls:r,party:t,instrumentId:a.instrumentId,contractId:s}),c()},children:"Withdraw"})]})},z=({settlementInfo:t})=>e.jsxs("div",{children:[e.jsx("h3",{children:"Settlement"}),e.jsx("strong",{children:"executor:"})," ",t.executor,e.jsx("br",{}),e.jsx("strong",{children:"allocateBefore:"})," ",t.allocateBefore,new Date(t.allocateBefore)<=new Date&&"(EXPIRED!)",e.jsx("br",{})]}),J=({party:t,allocationRequest:s,allocationsByTransferLegId:o})=>{const{settlement:i,transferLegs:a}=s,{mutate:l}=O(),{mutate:r}=q();return e.jsxs("div",{children:[e.jsx(z,{settlementInfo:i}),e.jsx("h3",{children:"Transfer Legs"}),Object.entries(a).map(([n,c])=>e.jsxs("div",{children:[e.jsx(S,{transferLegId:n,transferLeg:c}),c.sender===t&&e.jsx("button",{onClick:()=>l({party:t,allocationSpecification:{settlement:i,transferLegId:n,transferLeg:c}}),children:"Create Allocation"}),o?.get(n)?.map(u=>e.jsxs("div",{children:[e.jsx("span",{children:"Allocation Made"}),c.sender===t&&e.jsx("button",{onClick:()=>r({party:t,instrumentId:c.instrumentId,contractId:u.contractId}),children:"Withdraw Allocation"})]},u.contractId))]},n))]})},Y=()=>{const t=y(),s=x()?.partyId,{data:o}=K(),{data:i}=T(),a=h.useCallback((n,c)=>JSON.stringify([n.settlementRef.id,n.settlementRef.cid,c]),[]),[l,r]=h.useMemo(()=>{const n=new Map,c=[];for(const u of o??[]){const{settlement:d,transferLegs:g}=u.interfaceViewValue;for(const j in g){const m=a(d,j);n.set(m,[])}}for(const u of i??[]){const{settlement:d,transferLegId:g}=u.interfaceViewValue.allocation,j=a(d,g);n.has(j)?n.get(j).push(u):(console.log(n),c.push(u))}return[n,c]},[o,i,a]);return h.useEffect(()=>{s&&(async()=>{const n=await t.listAllocationInstructions({party:s});console.log("allocationInstructions",n)})()},[t,s]),e.jsxs("div",{children:[e.jsx("h2",{children:"Allocation requests"}),s&&o?.map(n=>e.jsx("div",{children:e.jsx(J,{party:s,allocationRequest:n.interfaceViewValue,allocationsByTransferLegId:new Map(Object.keys(n.interfaceViewValue.transferLegs).map(c=>[c,l.get(a(n.interfaceViewValue.settlement,c))??[]]))})},n.contractId)),e.jsx("h2",{children:"Unknown Allocations"}),s&&r?.map(n=>e.jsx("div",{children:e.jsx(X,{party:s,contractId:n.contractId,allocation:n.interfaceViewValue})},n.contractId))]})},_=({tabs:t,initialValue:s})=>{const o=s??t[0]?.value,[i,a]=h.useState(o),l=t.find(r=>r.value===i);return e.jsxs("div",{children:[e.jsx("div",{role:"tablist",className:"flex gap-2 border-b",children:t.map(r=>e.jsx("button",{role:"tab","aria-selected":i===r.value,className:`${i===r.value?"bg-blue-500":"opacity-60"}`,onClick:()=>a(r.value),children:i===r.value?`[${r.label}]`:r.label},r.value))}),e.jsx("div",{role:"tabpanel",children:l?.content})]})};function re(){return e.jsxs(e.Fragment,{children:[e.jsx("h1",{children:"dApp Portfolio"}),e.jsx(G,{}),e.jsx(_,{tabs:[{label:"Holdings",value:"holdings",content:e.jsx(F,{})},{label:"Transfer",value:"twoStepTransfer",content:e.jsx($,{})},{label:"Pending Transfers",value:"pendingTransfers",content:e.jsx(W,{})},{label:"Transaction History",value:"transactionHistory",content:e.jsx(Q,{})},{label:"Allocations",value:"allocations",content:e.jsx(Y,{})},{label:"Registry Settings",value:"registries",content:e.jsx(B,{})}]})]})}export{re as component};
@@ -1 +0,0 @@
1
- import{g as tt,a as et,r as h,u as nt,a1 as Wt,a2 as Et,a3 as $t,a4 as Mt,a5 as zt,H as I,c as Q,j as e,b as ot,s as R,K as U,a6 as ut,a7 as Dt,P as _,a8 as Ht,d as ct,v as Nt,y as Lt,a9 as Ft,aa as Bt,ab as Gt,R as Ut,A as Ot,B as u,T as b,k as ft,ac as Vt,ad as qt,a0 as Kt,$ as Qt}from"./index-C7M4apWO.js";import{b as Jt,c as Xt}from"./useTransactionHistory-DGWGZTMt.js";import{C as dt}from"./copyable-identifier-BFf0ARYa.js";import{A as Yt,S as G}from"./Avatar-C-49N7Fz.js";import{T as xt,a as mt,b as ht,c as X,d,e as gt}from"./TableRow-CsIbZW4V.js";function Zt(t){return tt("MuiCollapse",t)}et("MuiCollapse",["root","horizontal","vertical","entered","hidden","wrapper","wrapperInner"]);const _t=t=>{const{orientation:n,classes:o}=t,s={root:["root",`${n}`],entered:["entered"],hidden:["hidden"],wrapper:["wrapper",`${n}`],wrapperInner:["wrapperInner",`${n}`]};return ot(s,Zt,o)},te=R("div",{name:"MuiCollapse",slot:"Root",overridesResolver:(t,n)=>{const{ownerState:o}=t;return[n.root,n[o.orientation],o.state==="entered"&&n.entered,o.state==="exited"&&!o.in&&o.collapsedSize==="0px"&&n.hidden]}})(U(({theme:t})=>({height:0,overflow:"hidden",transition:t.transitions.create("height"),variants:[{props:{orientation:"horizontal"},style:{height:"auto",width:0,transition:t.transitions.create("width")}},{props:{state:"entered"},style:{height:"auto",overflow:"visible"}},{props:{state:"entered",orientation:"horizontal"},style:{width:"auto"}},{props:({ownerState:n})=>n.state==="exited"&&!n.in&&n.collapsedSize==="0px",style:{visibility:"hidden"}}]}))),ee=R("div",{name:"MuiCollapse",slot:"Wrapper"})({display:"flex",width:"100%",variants:[{props:{orientation:"horizontal"},style:{width:"auto",height:"100%"}}]}),ne=R("div",{name:"MuiCollapse",slot:"WrapperInner"})({width:"100%",variants:[{props:{orientation:"horizontal"},style:{width:"auto",height:"100%"}}]}),at=h.forwardRef(function(n,o){const s=nt({props:n,name:"MuiCollapse"}),{addEndListener:i,children:c,className:l,collapsedSize:a="0px",component:g,easing:C,in:x,onEnter:j,onEntered:f,onEntering:A,onExit:p,onExited:P,onExiting:y,orientation:T="vertical",slots:k={},slotProps:W={},style:N,timeout:v=Wt.standard,TransitionComponent:E=Et,...L}=s,$={...s,orientation:T,collapsedSize:a},M=_t($),m=$t(),O=Mt(),z=h.useRef(null),J=h.useRef(),V=typeof a=="number"?`${a}px`:a,F=T==="horizontal",B=F?"width":"height",q=h.useRef(null),st=zt(o,q),H=r=>w=>{if(r){const S=q.current;w===void 0?r(S):r(S,w)}},rt=()=>z.current?z.current[F?"clientWidth":"clientHeight"]:0,bt=H((r,w)=>{z.current&&F&&(z.current.style.position="absolute"),r.style[B]=V,j&&j(r,w)}),jt=H((r,w)=>{const S=rt();z.current&&F&&(z.current.style.position="");const{duration:D,easing:Y}=ut({style:N,timeout:v,easing:C},{mode:"enter"});if(v==="auto"){const pt=m.transitions.getAutoHeightDuration(S);r.style.transitionDuration=`${pt}ms`,J.current=pt}else r.style.transitionDuration=typeof D=="string"?D:`${D}ms`;r.style[B]=`${S}px`,r.style.transitionTimingFunction=Y,A&&A(r,w)}),vt=H((r,w)=>{r.style[B]="auto",f&&f(r,w)}),wt=H(r=>{r.style[B]=`${rt()}px`,p&&p(r)}),St=H(P),Ct=H(r=>{const w=rt(),{duration:S,easing:D}=ut({style:N,timeout:v,easing:C},{mode:"exit"});if(v==="auto"){const Y=m.transitions.getAutoHeightDuration(w);r.style.transitionDuration=`${Y}ms`,J.current=Y}else r.style.transitionDuration=typeof S=="string"?S:`${S}ms`;r.style[B]=V,r.style.transitionTimingFunction=D,y&&y(r)}),At=r=>{v==="auto"&&O.start(J.current||0,r),i&&i(q.current,r)},it={slots:k,slotProps:W,component:g},[Tt,lt]=I("root",{ref:st,className:Q(M.root,l),elementType:te,externalForwardedProps:it,ownerState:$,additionalProps:{style:{[F?"minWidth":"minHeight"]:V,...N}}}),[It,Rt]=I("wrapper",{ref:z,className:M.wrapper,elementType:ee,externalForwardedProps:it,ownerState:$}),[Pt,kt]=I("wrapperInner",{className:M.wrapperInner,elementType:ne,externalForwardedProps:it,ownerState:$});return e.jsx(E,{in:x,onEnter:bt,onEntered:vt,onEntering:jt,onExit:wt,onExited:St,onExiting:Ct,addEndListener:At,nodeRef:q,timeout:v==="auto"?null:v,...L,children:(r,{ownerState:w,...S})=>{const D={...$,state:r};return e.jsx(Tt,{...lt,className:Q(lt.className,{entered:M.entered,exited:!x&&V==="0px"&&M.hidden}[r]),ownerState:D,...S,children:e.jsx(It,{...Rt,ownerState:D,children:e.jsx(Pt,{...kt,ownerState:D,children:c})})})}})});at&&(at.muiSupportAuto=!0);const yt=h.createContext({});function oe(t){return tt("MuiAccordion",t)}const Z=et("MuiAccordion",["root","heading","rounded","expanded","disabled","gutters","region"]),se=t=>{const{classes:n,square:o,expanded:s,disabled:i,disableGutters:c}=t;return ot({root:["root",!o&&"rounded",s&&"expanded",i&&"disabled",!c&&"gutters"],heading:["heading"],region:["region"]},oe,n)},re=R(_,{name:"MuiAccordion",slot:"Root",overridesResolver:(t,n)=>{const{ownerState:o}=t;return[{[`& .${Z.region}`]:n.region},n.root,!o.square&&n.rounded,!o.disableGutters&&n.gutters]}})(U(({theme:t})=>{const n={duration:t.transitions.duration.shortest};return{position:"relative",transition:t.transitions.create(["margin"],n),overflowAnchor:"none","&::before":{position:"absolute",left:0,top:-1,right:0,height:1,content:'""',opacity:1,backgroundColor:(t.vars||t).palette.divider,transition:t.transitions.create(["opacity","background-color"],n)},"&:first-of-type":{"&::before":{display:"none"}},[`&.${Z.expanded}`]:{"&::before":{opacity:0},"&:first-of-type":{marginTop:0},"&:last-of-type":{marginBottom:0},"& + &":{"&::before":{display:"none"}}},[`&.${Z.disabled}`]:{backgroundColor:(t.vars||t).palette.action.disabledBackground}}}),U(({theme:t})=>({variants:[{props:n=>!n.square,style:{borderRadius:0,"&:first-of-type":{borderTopLeftRadius:(t.vars||t).shape.borderRadius,borderTopRightRadius:(t.vars||t).shape.borderRadius},"&:last-of-type":{borderBottomLeftRadius:(t.vars||t).shape.borderRadius,borderBottomRightRadius:(t.vars||t).shape.borderRadius,"@supports (-ms-ime-align: auto)":{borderBottomLeftRadius:0,borderBottomRightRadius:0}}}},{props:n=>!n.disableGutters,style:{[`&.${Z.expanded}`]:{margin:"16px 0"}}}]}))),ie=R("h3",{name:"MuiAccordion",slot:"Heading"})({all:"unset"}),ae=R("div",{name:"MuiAccordion",slot:"Region"})({}),ce=h.forwardRef(function(n,o){const s=nt({props:n,name:"MuiAccordion"}),{children:i,className:c,defaultExpanded:l=!1,disabled:a=!1,disableGutters:g=!1,expanded:C,onChange:x,slots:j={},slotProps:f={},TransitionComponent:A,TransitionProps:p,...P}=s,[y,T]=Dt({controlled:C,default:l,name:"Accordion",state:"expanded"}),k=h.useCallback(H=>{T(!y),x&&x(H,!y)},[y,x,T]),[W,...N]=h.Children.toArray(i),v=h.useMemo(()=>({expanded:y,disabled:a,disableGutters:g,toggle:k}),[y,a,g,k]),E={...s,disabled:a,disableGutters:g,expanded:y},L=se(E),$={transition:A,...j},M={transition:p,...f},m={slots:$,slotProps:M},[O,z]=I("root",{elementType:re,externalForwardedProps:{...m,...P},className:Q(L.root,c),shouldForwardComponentProp:!0,ownerState:E,ref:o}),[J,V]=I("heading",{elementType:ie,externalForwardedProps:m,className:L.heading,ownerState:E}),[F,B]=I("transition",{elementType:at,externalForwardedProps:m,ownerState:E}),[q,st]=I("region",{elementType:ae,externalForwardedProps:m,ownerState:E,className:L.region,additionalProps:{"aria-labelledby":W.props.id,id:W.props["aria-controls"],role:"region"}});return e.jsxs(O,{...z,children:[e.jsx(J,{...V,children:e.jsx(yt.Provider,{value:v,children:W})}),e.jsx(F,{in:y,timeout:"auto",...B,children:e.jsx(q,{...st,children:N})})]})});function de(t){return tt("MuiAccordionDetails",t)}et("MuiAccordionDetails",["root"]);const le=t=>{const{classes:n}=t;return ot({root:["root"]},de,n)},pe=R("div",{name:"MuiAccordionDetails",slot:"Root"})(U(({theme:t})=>({padding:t.spacing(1,2,2)}))),ue=h.forwardRef(function(n,o){const s=nt({props:n,name:"MuiAccordionDetails"}),{className:i,...c}=s,l=s,a=le(l);return e.jsx(pe,{className:Q(a.root,i),ref:o,ownerState:l,...c})});function xe(t){return tt("MuiAccordionSummary",t)}const K=et("MuiAccordionSummary",["root","expanded","focusVisible","disabled","gutters","contentGutters","content","expandIconWrapper"]),me=t=>{const{classes:n,expanded:o,disabled:s,disableGutters:i}=t;return ot({root:["root",o&&"expanded",s&&"disabled",!i&&"gutters"],focusVisible:["focusVisible"],content:["content",o&&"expanded",!i&&"contentGutters"],expandIconWrapper:["expandIconWrapper",o&&"expanded"]},xe,n)},he=R(Ht,{name:"MuiAccordionSummary",slot:"Root"})(U(({theme:t})=>{const n={duration:t.transitions.duration.shortest};return{display:"flex",width:"100%",minHeight:48,padding:t.spacing(0,2),transition:t.transitions.create(["min-height","background-color"],n),[`&.${K.focusVisible}`]:{backgroundColor:(t.vars||t).palette.action.focus},[`&.${K.disabled}`]:{opacity:(t.vars||t).palette.action.disabledOpacity},[`&:hover:not(.${K.disabled})`]:{cursor:"pointer"},variants:[{props:o=>!o.disableGutters,style:{[`&.${K.expanded}`]:{minHeight:64}}}]}})),ge=R("span",{name:"MuiAccordionSummary",slot:"Content"})(U(({theme:t})=>({display:"flex",textAlign:"start",flexGrow:1,margin:"12px 0",variants:[{props:n=>!n.disableGutters,style:{transition:t.transitions.create(["margin"],{duration:t.transitions.duration.shortest}),[`&.${K.expanded}`]:{margin:"20px 0"}}}]}))),fe=R("span",{name:"MuiAccordionSummary",slot:"ExpandIconWrapper"})(U(({theme:t})=>({display:"flex",color:(t.vars||t).palette.action.active,transform:"rotate(0deg)",transition:t.transitions.create("transform",{duration:t.transitions.duration.shortest}),[`&.${K.expanded}`]:{transform:"rotate(180deg)"}}))),ye=h.forwardRef(function(n,o){const s=nt({props:n,name:"MuiAccordionSummary"}),{children:i,className:c,expandIcon:l,focusVisibleClassName:a,onClick:g,slots:C,slotProps:x,...j}=s,{disabled:f=!1,disableGutters:A,expanded:p,toggle:P}=h.useContext(yt),y=m=>{P&&P(m),g&&g(m)},T={...s,expanded:p,disabled:f,disableGutters:A},k=me(T),W={slots:C,slotProps:x},[N,v]=I("root",{ref:o,shouldForwardComponentProp:!0,className:Q(k.root,c),elementType:he,externalForwardedProps:{...W,...j},ownerState:T,additionalProps:{focusRipple:!1,disableRipple:!0,disabled:f,"aria-expanded":p,focusVisibleClassName:Q(k.focusVisible,a)},getSlotProps:m=>({...m,onClick:O=>{m.onClick?.(O),y(O)}})}),[E,L]=I("content",{className:k.content,elementType:ge,externalForwardedProps:W,ownerState:T}),[$,M]=I("expandIconWrapper",{className:k.expandIconWrapper,elementType:fe,externalForwardedProps:W,ownerState:T});return e.jsxs(N,{...v,children:[e.jsx(E,{...L,children:i}),l&&e.jsx($,{...M,children:l})]})}),be=ct(e.jsx("path",{d:"M20 11H7.83l5.59-5.59L12 4l-8 8 8 8 1.41-1.41L7.83 13H20z"})),je=t=>{const n=Nt(),o=Lt({queryKey:Ut.listHoldings.forParty(t),queryFn:()=>Gt({party:t}),enabled:!!t});return{instruments:h.useMemo(()=>o.data?Ft(Bt(o.data),n):[],[o.data,n]),holdings:o.data??[],isLoading:o.isLoading,isError:o.isError,error:o.error,refetch:o.refetch}},ve=ct(e.jsx("path",{d:"M16.59 8.59 12 13.17 7.41 8.59 6 10l6 6 6-6z"})),we=ct(e.jsx("path",{d:"M18 8h-1V6c0-2.76-2.24-5-5-5S7 3.24 7 6v2H6c-1.1 0-2 .9-2 2v10c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V10c0-1.1-.9-2-2-2m-6 9c-1.1 0-2-.9-2-2s.9-2 2-2 2 .9 2 2-.9 2-2 2m3.1-9H8.9V6c0-1.71 1.39-3.1 3.1-3.1s3.1 1.39 3.1 3.1z"})),Se=({holding:t,symbol:n})=>{const o=Ot.isHoldingLocked(t,new Date);return e.jsxs(u,{sx:{py:1.5,px:2,display:"flex",alignItems:"center",justifyContent:"space-between","&:not(:last-child)":{borderBottom:s=>`1px solid ${s.palette.divider}`}},children:[e.jsxs(u,{sx:{display:"flex",alignItems:"center",gap:1},children:[e.jsxs(b,{variant:"body2",children:[t.amount," ",n]}),o&&e.jsx(we,{fontSize:"small",color:"warning",sx:{fontSize:16}})]}),e.jsx(dt,{value:t.contractId,maxLength:12})]})},Ce=({aggregatedHolding:t,holdings:n})=>{const o=t.instrument?.symbol??t.instrumentId.id,s=t.instrument?.name??t.instrumentId.id,i=t.lockedAmount!=="0";return e.jsxs(ce,{disableGutters:!0,sx:{"&:before":{display:"none"},boxShadow:"none","&:not(:last-child)":{borderBottom:c=>`1px solid ${c.palette.divider}`}},children:[e.jsx(ye,{expandIcon:e.jsx(ve,{}),sx:{"&:hover":{backgroundColor:"action.hover"}},children:e.jsxs(u,{sx:{display:"flex",alignItems:"center",gap:2,width:"100%",pr:2},children:[e.jsx(Yt,{sx:{width:32,height:32,fontSize:14},children:o[0]}),e.jsxs(u,{sx:{flexGrow:1},children:[e.jsx(b,{variant:"body2",color:"textSecondary",sx:{maxWidth:"150px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:s}),e.jsxs(b,{variant:"body1",fontWeight:"bold",children:[t.totalAmount," ",o]})]}),i&&e.jsxs(u,{sx:{textAlign:"right"},children:[e.jsxs(b,{variant:"body2",color:"success.main",children:[t.availableAmount," available"]}),e.jsxs(b,{variant:"body2",color:"textSecondary",children:[t.lockedAmount," locked"]})]})]})}),e.jsxs(ue,{sx:{p:0,pl:6},children:[e.jsxs(b,{variant:"caption",color:"textSecondary",sx:{px:2,pt:1,display:"block",textTransform:"uppercase",letterSpacing:.5},children:[t.numOfHoldings," holding",t.numOfHoldings!==1?"s":""]}),e.jsx(u,{children:n.map(c=>e.jsx(Se,{holding:c,symbol:o},c.contractId))})]})]})},Ae=t=>new Date(t).toLocaleString(),Te=t=>{const n=t.events[0];return n?n.label.type:"Unknown"},Ie=t=>{const n=t.events[0];if(!n)return"-";if(n.transferInstruction?.transfer?.instrumentId){const{admin:s,id:i}=n.transferInstruction.transfer.instrumentId;return i||s}const o=n.unlockedHoldingsChangeSummaries[0]||n.lockedHoldingsChangeSummaries[0];return o?.instrumentId?o.instrumentId.id||o.instrumentId.admin:"-"},Re=(t,n)=>{const o=t.events[0];if(!o)return{amount:"-",isOutgoing:!1};if(o.transferInstruction?.transfer){const i=o.transferInstruction.transfer,c=i.amount||"0",l=i.sender===n;return{amount:c,isOutgoing:l}}const s=o.unlockedHoldingsChangeSummaries[0]||o.lockedHoldingsChangeSummaries[0];if(s){const i=s.amountChange||"0",l=new Vt(i).isNegative();return{amount:i,isOutgoing:l}}return{amount:"-",isOutgoing:!1}},Pe=(t,n)=>{const o=t.events[0];if(!o)return"-";if(o.transferInstruction?.transfer){const s=o.transferInstruction.transfer;if(s.sender===n)return s.receiver||"-";if(s.receiver===n)return s.sender||"-"}return"-"},ke=({transactions:t,walletId:n,hasNextPage:o,isFetching:s,isFetchingNextPage:i,onLoadMore:c})=>{const l=t.length>0;return console.log("transactions",t),s&&!l?e.jsx(xt,{component:_,variant:"outlined",sx:{borderRadius:1,overflow:"hidden"},children:e.jsxs(mt,{size:"medium",children:[e.jsx(ht,{children:e.jsxs(X,{sx:{backgroundColor:"action.hover"},children:[e.jsx(d,{sx:{py:2,px:3,fontWeight:"medium"},children:"Type"}),e.jsx(d,{sx:{py:2,px:3,fontWeight:"medium"},children:"Date"}),e.jsx(d,{sx:{py:2,px:3,fontWeight:"medium"},children:"Asset"}),e.jsx(d,{sx:{py:2,px:3,fontWeight:"medium"},children:"Amount"}),e.jsx(d,{sx:{py:2,px:3,fontWeight:"medium"},children:"Counterparty"})]})}),e.jsx(gt,{children:[1,2,3].map(a=>e.jsxs(X,{children:[e.jsx(d,{sx:{py:2.5,px:3},children:e.jsx(G,{variant:"text",width:80})}),e.jsx(d,{sx:{py:2.5,px:3},children:e.jsx(G,{variant:"text",width:120})}),e.jsx(d,{sx:{py:2.5,px:3},children:e.jsx(G,{variant:"text",width:60})}),e.jsx(d,{sx:{py:2.5,px:3},children:e.jsx(G,{variant:"text",width:80})}),e.jsx(d,{sx:{py:2.5,px:3},children:e.jsx(G,{variant:"text",width:150})})]},a))})]})}):e.jsxs(u,{children:[e.jsx(xt,{component:_,variant:"outlined",sx:{borderRadius:1,overflow:"hidden"},children:e.jsxs(mt,{size:"medium",children:[e.jsx(ht,{children:e.jsxs(X,{sx:{backgroundColor:"action.hover"},children:[e.jsx(d,{sx:{py:2,px:3,fontWeight:"medium"},children:"Type"}),e.jsx(d,{sx:{py:2,px:3,fontWeight:"medium"},children:"Date"}),e.jsx(d,{sx:{py:2,px:3,fontWeight:"medium"},children:"Asset"}),e.jsx(d,{sx:{py:2,px:3,fontWeight:"medium"},children:"Amount"}),e.jsx(d,{sx:{py:2,px:3,fontWeight:"medium"},children:"Counterparty"})]})}),e.jsx(gt,{children:l?t.map(a=>{const g=Te(a),C=Ie(a),{amount:x,isOutgoing:j}=Re(a,n),f=Pe(a,n),A=j?"-":"+",p=j?"error.main":"success.main";return e.jsxs(X,{sx:{"&:hover":{backgroundColor:"action.hover"},"&:last-child td":{border:0}},children:[e.jsx(d,{component:"th",scope:"row",sx:{py:2.5,px:3},children:g}),e.jsx(d,{sx:{py:2.5,px:3},children:Ae(a.recordTime)}),e.jsx(d,{sx:{py:2.5,px:3},children:e.jsx(u,{component:"span",sx:{px:1.5,py:.5,backgroundColor:"action.selected",color:"text.primary",borderRadius:1,fontSize:"0.875rem",display:"inline-block"},children:C})}),e.jsx(d,{sx:{py:2.5,px:3,color:p,fontWeight:"medium"},children:x==="-"?"-":`${A}${x}`}),e.jsx(d,{sx:{py:2.5,px:3},children:f==="-"?"-":e.jsx(dt,{value:f})})]},a.updateId)}):e.jsx(X,{children:e.jsx(d,{colSpan:5,sx:{py:4,px:3},children:e.jsx(u,{sx:{textAlign:"center"},children:e.jsx(b,{variant:"body1",color:"text.secondary",children:"There are currently no transactions in this wallet"})})})})})]})}),o&&e.jsx(u,{sx:{mt:2,textAlign:"center"},children:e.jsx(ft,{variant:"outlined",onClick:c,disabled:i,size:"small",children:i?"Loading...":"Load more"})})]})};function De(){const{walletId:t}=qt.useParams(),s=Kt().find(p=>p.partyId===t)?.hint??"Unknown Wallet",{instruments:i,holdings:c,isLoading:l,isError:a}=je(t),{status:g,fetchNextPage:C,isFetchingNextPage:x,hasNextPage:j}=Jt(t),f=Xt(t),A=p=>c.filter(P=>P.instrumentId.admin===p.admin&&P.instrumentId.id===p.id);return e.jsxs(u,{sx:{my:4},children:[e.jsx(ft,{component:Qt,to:"/",startIcon:e.jsx(be,{}),sx:{mb:2},children:"Back to Dashboard"}),e.jsxs(u,{sx:{mb:4},children:[e.jsx(b,{variant:"h4",component:"h1",fontWeight:"bold",children:s}),e.jsx(u,{sx:{mt:1},children:e.jsx(dt,{value:t,maxLength:16})})]}),e.jsx(b,{variant:"h6",sx:{mb:2,textTransform:"uppercase"},fontWeight:"bold",children:"Holdings"}),e.jsx(_,{variant:"outlined",children:l?e.jsxs(u,{sx:{p:2},children:[e.jsx(G,{variant:"rectangular",height:60}),e.jsx(G,{variant:"rectangular",height:60,sx:{mt:1}})]}):a?e.jsx(u,{sx:{p:4,textAlign:"center"},children:e.jsx(b,{color:"error",children:"Failed to load holdings"})}):i.length===0?e.jsx(u,{sx:{p:4,textAlign:"center"},children:e.jsx(b,{color:"textSecondary",children:"No holdings in this wallet"})}):i.map(p=>e.jsx(Ce,{aggregatedHolding:p,holdings:A(p.instrumentId)},`${p.instrumentId.admin}::${p.instrumentId.id}`))}),e.jsx(b,{variant:"h6",sx:{mb:2,mt:4,textTransform:"uppercase"},fontWeight:"bold",children:"Transaction History"}),e.jsx(ke,{transactions:f,walletId:t,hasNextPage:j,isFetching:g==="pending",isFetchingNextPage:x,onLoadMore:C})]})}export{De as component};