PageSourceSearch

https://www.carbonarc.co/assets/MyWallet-DcaXroXS.js

js carbonarc.co collected 2026-09-29 15:59:45 UTC 47,707 bytes, 1 lines download raw bytes

1import{j as e,r as m,R as B}from"./vendor-react-CF2OuAXi.js";import{M as st}from"./MyPageCommonLayout-Dixd6BF8.js";import{e as St,T as qe,L as Ae,b as at,a as wt}from"./vendor-flowbite-BOOFXkYC.js";import{B as _e}from"./Button-_45-WKGL.js";import{h as ot,b as it,k as Y,I as ct,al as Et,T as Pt,bB as Mt,a6 as At,bq as H,S as Ie,d2 as It,cs as Lt,d3 as Ft}from"./index-CQwFLP6K.js";import{b as G,u as dt,a as je}from"./vendor-query-Dru8Ryjt.js";import{M as $t}from"./McpInfoModal-DvHLLu-A.js";import{l as qt,E as Ot,a as Dt}from"./react-stripe.esm-DOe7QG62.js";import{e as Kt,m as ut}from"./plans-ChZtfKgx.js";import{T as Ce}from"./Table-B0Ps1mIS.js";import{a as zt}from"./Pagination-BozuNft5.js";import{u as Bt}from"./usePagination-DShFhoaH.js";import{h as ae,g as ne}from"./formatters-CRHT1J-5.js";import{C as Q,S as Rt}from"./CarbonArcTokenIcon-CS15NI2n.js";import{v as Wt}from"./useOntology-Bk5UttVe.js";import{e as Vt}from"./index-CfAhHpCo.js";import{a as Ht,b as Ut}from"./vendor-router-1lxCfBys.js";import{u as Qt}from"./useIsWholesaleClient-CLY9Su7l.js";import{W as nt}from"./wallet-DM9wIKY_.js";import{P as rt}from"./plus-DpBfwChR.js";import{I as Gt}from"./info-CxKaq-GJ.js";import"./PageLayout-Dn-HLfwH.js";import"./Footer-D8kWJ2zc.js";import"./lensesPersonas-BGT1pqma.js";import"./sparkles-DF-Pm669.js";import"./trending-up-DsPXVq4Q.js";import"./users-CKZYegGP.js";import"./blockRoles-1ohB_X78.js";import"./dataLibraryNavAccess-CadgK9a3.js";import"./index-q_BE_MGP.js";import"./index-Uzg96WYX.js";import"./index-CpPMGrZs.js";import"./index-DIqXhkv4.js";import"./index-C14J_qoS.js";import"./shopping-cart-CmfQhR2G.js";import"./file-text-Cttx8El0.js";import"./useMcpOnlyView-BryYLQJE.js";import"./useDistributorExperience-DzH_jpX1.js";import"./x-lJhSzwDa.js";import"./vendor-datadog-tM0hMiRH.js";import"./vendor-okta-DqkOGBPB.js";import"./index-DZUZnGf6.js";import"./PageHeader-LPx84FIP.js";import"./BuilderPageContext-Dp3P4cEt.js";import"./BuilderContext-B-sXr9OJ.js";import"./usePersistState-DM4zi0sk.js";import"./insights-BEUhr2Y9.js";import"./pollableJob-RdahJHuS.js";import"./frameworks-DHD0uULy.js";import"./ontology-Fx5ovBX_.js";import"./omit-BHhHUIbG.js";import"./startCase-0GqYf9AX.js";import"./browser-BczVn0qP.js";import"./date-CGz-Bi04.js";import"./dayjs.min-CcXI944o.js";import"./compact-DeU34Yoy.js";import"./castArray-BQszfGim.js";import"./usePortalSidebarRoutes-zTDH_OEk.js";import"./useActiveTickers-DCW8E6sI.js";import"./constants-DdUlFUkc.js";import"./vendor-i18n-D8V0Brmg.js";import"./index-Crq8TqMI.js";import"./Skeleton-BRGF7VwU.js";import"./NoDataDisplay-CXnnx2lc.js";import"./chevron-right-nK9qNL-G.js";import"./chevron-down-BMfo5y9F.js";import"./file-P8XoWhti.js";const O=({children:t,className:s,iconClassName:a,tokenIconColor:o="orange"})=>e.jsxs("div",{className:["flex items-center gap-1",s].filter(Boolean).join(" "),children:[e.jsx("span",{children:t}),e.jsx("div",{className:"flex items-center justify-center size-3",children:e.jsx(Q,{alt:"Token",color:o,className:ot("size-full",a)})})]}),Oe=({dataKey:t,queryKeyBase:s,fetchEvents:a,noDataMessage:o,errorMessage:n,hideBalanceColumns:l=!1,tokenIconColor:r,rowKey:p,expandedRowKeys:g,expandedRowRender:u,onRowClick:b,methodColumnTitle:S="Method",dateFormatOptions:I})=>{var h;const{page:_,pageSize:v}=Bt(1,10,t),M=(_-1)*v,{data:k,isLoading:Z,isError:c}=G({queryKey:[s,_,v],queryFn:()=>a(M,v)}),x=m.useMemo(()=>!(k!=null&&k.total)||!v?1:Math.ceil(k.total/v),[k==null?void 0:k.total,v]);return e.jsxs("div",{className:"flex flex-col gap-4 w-full",children:[c&&n?e.jsx("div",{className:"text-sm text-red-600 dark:text-red-400",children:n}):null,e.jsx(Ce,{columns:[...u?[{title:"",key:"expander",className:"w-[4%]"}]:[],{title:"Date",key:"date",className:"w-[13%]"},{title:"Type",key:"type",className:"w-[20%]"},{title:S,key:"method",className:"w-[13%]"},{title:"Amount",key:"amount",className:"w-[14%]"},...l?[]:[{title:"Balance Before",key:"balance_before",className:"w-[20%]"},{title:"Balance After",key:"balance_after",className:"w-[20%]"}]],data:((h=k==null?void 0:k.items)==null?void 0:h.map(f=>{var A,w;const C={date:ae(f.created_at,I),type:f.name,method:f.method,amount:e.jsx(O,{tokenIconColor:r,children:ne(f.amount,2)})};if(l||(C.balance_before=e.jsx(O,{tokenIconColor:r,children:ne(f.balance_before,2)}),C.balance_after=e.jsx(O,{tokenIconColor:r,children:ne(f.balance_after,2)})),f.transaction_id&&(C.transaction_id=f.transaction_id),(A=f.lines)!=null&&A.length&&(C.lines=f.lines),u){const q=f.transaction_id??"",L=!!(q&&(g!=null&&g.has(q)));C.expander=(w=f.lines)!=null&&w.length?e.jsx("span",{"aria-hidden":!0,
1className:"inline-block text-foreground/50 transition-transform",style:{transform:L?"rotate(90deg)":void 0},children:"›"}):null}return C}))||[],rowKey:p,expandedRowKeys:g,expandedRowRender:u,onRowClick:b,isBodyLoading:Z,cellClassName:"p-2 align-middle",headCellClassName:"px-2",className:"table-fixed w-full",showNoData:!0,noDataMessage:o}),k&&(k.total||0)>v&&e.jsx("div",{className:"flex justify-center",children:e.jsx(zt,{loading:Z,totalPages:x,showSizeChanger:!0,pageSize:v,pageSizeOptions:[10,20,50,100],dataKey:t})})]})},Yt=()=>e.jsx(Oe,{dataKey:"platform-transactions",queryKeyBase:"creditEvents",fetchEvents:Kt,noDataMessage:"No credit history available",errorMessage:"Failed to load transactions."}),Jt=({scheduledTransactionData:t,isScheduledTransactionLoading:s,isScheduledTransactionError:a})=>{const o=[...t??[]].sort((n,l)=>{const r=u=>{if(!u)return Number.POSITIVE_INFINITY;const b=Date.parse(u);return Number.isFinite(b)?b:Number.POSITIVE_INFINITY},p=r(n.schedule_type==="one_time"?n.scheduled_at:n.next_due_at??n.start_at),g=r(l.schedule_type==="one_time"?l.scheduled_at:l.next_due_at??l.start_at);return p-g});return e.jsx("div",{children:a?e.jsx("div",{className:"text-sm text-red-600 dark:text-red-400",children:"Failed to load scheduled transactions."}):e.jsx(Ce,{columns:[{title:"Amount",key:"amount",className:"w-[14%]"},{title:"Token Type",key:"token_name",className:"w-[14%]"},{title:"Token Validity",key:"validity",className:"w-[12%]"},{title:"Recurrence",key:"recurrence",className:"w-[15%]"},{title:"Last issued",key:"last_issued",className:"w-[15%]"},{title:"Next Due",key:"next_due_at",className:"w-[15%]"},{title:"Start / Scheduled",key:"start_or_scheduled_at",className:"w-[15%]"}],data:o.map(n=>{const l=n.schedule_type,r=(n.recurrence_unit??"").trim(),p=l==="one_time"?"One-time":typeof n.interval=="number"&&n.recurrence_unit?n.interval===1?`Every 1 ${r}`:`Every ${n.interval} ${r}${r.endsWith("s")?"":"s"}`:"--",g=l==="one_time"?n.scheduled_at:n.next_due_at,u=l==="one_time"?n.scheduled_at:n.start_at;return{amount:e.jsx(O,{children:ne(n.amount,2,"0.00")}),token_name:n.token_name||"--",validity:typeof n.token_expires_days=="number"&&n.token_expires_days>0?`${n.token_expires_days}d`:"--",recurrence:p||"--",last_issued:n.last_issued_at?ae(n.last_issued_at):"--",next_due_at:g?ae(g):"--",start_or_scheduled_at:u?ae(u):"--"}}),isBodyLoading:s,cellClassName:"p-2 align-middle",headCellClassName:"px-2",className:"table-fixed w-full",showNoData:!0,noDataMessage:"No scheduled transactions"})})},Zt=()=>e.jsx(Oe,{dataKey:"mcp-transactions",queryKeyBase:"mcpCreditEvents",fetchEvents:ut,noDataMessage:"No MCP transactions to display",errorMessage:"Failed to load MCP transactions.",hideBalanceColumns:!0,tokenIconColor:"blue"}),Xt="awaiting_contract",j=t=>{if(t==null)return 0;const s=typeof t=="number"?t:Number(t);return Number.isFinite(s)?s:0},T=t=>j(t).toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:2}),Se=t=>t.status!==Xt&&t.periods_total>0,es=t=>!Se(t)&&t.status!=="cancelled"?"Vesting starts when your contract begins":`${t.periods_issued} of ${t.periods_total} months · ${t.progress_pct}%`,ts={month:"2-digit",day:"2-digit",year:"numeric",timeZone:"UTC"},De=t=>{if(!t)return"—";const s=new Date(t);return Number.isNaN(s.getTime())?"—":s.toLocaleDateString(void 0,{month:"short",day:"numeric",year:"numeric",timeZone:"UTC"})},ss=t=>{if(!t.next_vest_at)return t.status!=="cancelled"&&!Se(t)?{date:"Not scheduled yet",amount:null}:{date:t.status==="cancelled"?"Cancelled":"Fully vested",amount:null};const s=De(t.next_vest_at),a=t.next_vest_amount==null?null:`+${T(t.next_vest_amount)}`;return{date:s,amount:a}},mt=t=>t.status==="cancelled"?"Cancelled":Se(t)?t.periods_issued>=t.periods_total?"Fully vested":t.periods_issued===0?"Scheduled":"Vesting":"Awaiting contract",as=t=>{switch(mt(t)){case"Vesting":return"bg-amber-100 text-amber-900 dark:bg-amber-950/40 dark:text-amber-300";case"Fully vested":return"bg-emerald-100 text-emerald-800 dark:bg-emerald-950/40 dark:text-emerald-300";case"Cancelled":return"bg-red-100 text-red-800 dark:bg-red-950/40 dark:text-red-300";
1case"Awaiting contract":return"bg-sky-100 text-sky-800 dark:bg-sky-950/40 dark:text-sky-300";default:return"bg-gray-100 text-gray-700 dark:bg-gray-800 dark:text-gray-300"}},ns={accrued:"Accrued",consumed:"Applied to invoice",adjusted:"Adjustment"},rs=(t,s,a)=>{const o=(t==null?void 0:t.events)??[],n=o.slice(s,s+a).map(l=>({name:ns[l.event_type]??l.event_type,method:l.period,amount:l.event_type==="accrued"?j(l.amount):-j(l.amount),balance_before:0,balance_after:0,created_at:l.occurred_at,updated_at:l.occurred_at,status:"completed",transaction_id:l.transaction_id,lines:(l.lines??[]).map(r=>({block_contract_id:r.block_contract_id,period_seq:r.period_seq,amount:j(r.amount)}))}));return{total:o.length,items:n,pages:a>0?Math.ceil(o.length/a):1,page:a>0?Math.floor(s/a)+1:1,size:a}},ke={noLongerEditable:"invoice_no_longer_editable",periodTaken:"period_already_applied",periodNotUpcoming:"period_not_upcoming"},ls=(t,s)=>{const a=j(t.applied_tokens),o=j(s==null?void 0:s.remaining)+a,n=t.max_applicable_tokens==null?j(t.invoice_amount):j(t.max_applicable_tokens);return Math.max(0,Math.floor(Math.min(n,o)))},os=(t,s)=>{const a=t.max_applicable_tokens;if(a==null)return null;const o=Math.floor(j(t.invoice_amount));return s!==j(a)||s>=o?null:"applying more would leave under $0.50 on the invoice, which cannot be charged"},is=(t,s,a)=>{const o=t.trim();if(o==="")return{tokens:0,error:null};const n=Number(o);if(!Number.isFinite(n))return{tokens:0,error:"Enter a number"};if(n<0)return{tokens:n,error:"Enter a positive amount"};if(!Number.isInteger(n))return{tokens:n,error:"Whole tokens only"};if(!/^\d+$/.test(o))return{tokens:n,error:"Enter a whole number"};if(n>s){if(s<=0)return{tokens:n,error:a?`No tokens can be applied to this invoice — ${a}`:"You have no tokens available for this invoice"};const l=`You can apply at most ${s.toLocaleString()}`;return{tokens:n,error:a?`${l} — ${a}`:l}}return{tokens:n,error:null}},cs=(t,s)=>Math.max(0,j(t.invoice_amount)-s),ds=t=>{const s=t.days_until_send;return s==null?{label:"Date not set",urgent:!1}:s<0?{label:"Send date passed",urgent:!0}:s===0?{label:"Sends today",urgent:!0}:s===1?{label:"Sends tomorrow",urgent:!0}:{label:`Sends in ${s} days`,urgent:s<=3}},Le=t=>{const s=typeof t=="object"&&t!==null&&"message"in t?String(t.message):"";return s.includes(ke.noLongerEditable)?"This invoice has been finalized, so tokens can no longer be applied to it.":s.includes(ke.periodTaken)?"Another request updated this invoice first. The amount shown is now current.":s.includes(ke.periodNotUpcoming)?"That invoice has already been billed. This row now shows your next one — apply again if you still want to.":s||"Could not apply your tokens. Please try again."},ue=t=>`${t.block_contract_id}:${t.period_seq}`,U=t=>t.block_contract_id,us=(t,s,a,o)=>{const n=t[s];if(n!==void 0)return n;const l=xt(a,o);return l>0?String(l):""},pt=t=>{const s=j(t.applied_tokens);return s>0||me(t)?s:t.auto_apply_enabled===!1?0:j(t.auto_default_tokens)},xt=(t,s)=>Math.max(0,Math.min(pt(t),Math.floor(s))),ms=t=>{const s=typeof t=="object"&&t!==null&&"message"in t?String(t.message):"";return Object.values(ke).some(a=>s.includes(a))},me=t=>!t.editable,ps=(t,s,a)=>{const o=j(t.applied_tokens),n=j(t.auto_default_tokens),l=s.trim(),r=l===""?null:Number(l),p=r!==null&&Number.isFinite(r)&&Number.isInteger(r)&&r>0;if(me(t))return{resetTo:null,resetLabel:null,previewTokens:o,appliedNote:null,shortfallNote:null};const g=p?r:o,u=r??xt(t,a),S=o>0&&(r===null||r===0)?`${T(o)} still applied — use Remove to clear it`:o>0&&p&&r!==o?`${T(o)} applied now`:null,I=ft(t,a),_=t.auto_apply_enabled!==!1&&I>0&&Number.isFinite(u)&&u!==I,v=t.auto_apply_enabled!==!1&&n>0&&a<n,M=t.max_applicable_tokens==null?null:Math.floor(j(t.max_applicable_tokens)),k=v?M!==null&&a>=M?`This invoice can take ${T(a)} of the ${T(n)} automatic amount`:a<=o?`${T(a)} of the ${T(n)} automatic amount can be applied here now`:`Your wallet covers ${T(a)} of the ${T(n)} automatic amount`:null;return{resetTo:_?bs(t,a):null,resetLabel:_?`Reset to ${T(I)}`:null,previewTokens:g,appliedNote:S,shortfallNote:k}},xs=(t,s)=>{const a=t.auto_apply_enabled!==!1,o=j(t.auto_default_tokens);if(me(t))return{on:a,caption:"Locked for this invoice",adopt:null};if(!a)return{on:a,caption:o>0?`${T(o)} when on`:null,adopt:null};const n=s.trim(),l=n===""?pt(t):Number(n),r=Number.isFinite(l)&&Number.isInteger(l)&&l>0&&l!==o;return{on:a,caption:o>0?`${r?"Now ":""}${T(o)} each cycle`:"Nothing vested yet",adopt:r?{tokens:l,label:`Use ${T(l)} instead`}:null}},fs=t=>{const s=t.length,a=t.filter(o=>o.auto_apply_enabled!==!1).length;return s===0?{mode:"none",on:0,total:0,label:"No upcoming invoices"}:a===s?{mode:"all",on:a,total:s,label:s===1?"Automatic for your contract":`Automatic for all ${s} contracts`}:a===0?{mode:"none",on:a,total:s,label:s===1?"Manual for your contract":`Manual for all ${s} contracts`}:{mode:"mixed",on:a,total:s,label:`Automatic for ${a} of ${s} contracts`}},hs="Automatically apply vested S3 tokens from this contract to its invoice each billing cycle. Turn off to manage token application manually.",ft=(t,s)=>Math.min(Math.floor(j(t.auto_default_tokens)),Math.floor(s)),bs=(t,s)=>{const a=ft(t,s);return a>0?String(a):""},J=`${it.carcAuth.url}/ledger`,ys=async()=>Y(`${J}/s3/summary`),gs=async()=>Y(`${J}/s3/vesting-schedule`),Ns=async(t=500)=>Y(`${J}/transactions/s3?limit=${t}`),vs=async(t=0,s=20)=>{const a=await Ns();return rs(a,t,s)},_s=async()=>Y(`${J}/s3/upcoming-invoices`),js=async t=>Y(`${J}/s3/apply`,{method:"POST",body:JSON.stringify(t)}),ks=async t=>Y(`${J}
1/s3/apply/${t}`,{method:"DELETE"}),Ts=async t=>Y(`${J}/s3/auto-apply`,{method:"PUT",body:JSON.stringify(t)}),Cs={root:{label:"ms-2 text-xs text-muted-foreground whitespace-nowrap font-normal"},toggle:{base:"relative rounded-full border after:absolute after:rounded-full after:bg-white after:transition-all group-focus:ring-4 group-focus:ring-ca-signalOrange/25",checked:{color:{info:"border-ca-signalOrange bg-ca-signalOrange"}}}},Fe=({label:t,value:s,emphasis:a})=>e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx("span",{className:"text-sm text-gray-600 dark:text-gray-300",children:t}),e.jsx(O,{tokenIconColor:"s3",className:a==="warn"?"font-semibold text-amber-600 dark:text-amber-400":"font-semibold",children:T(s)})]}),Ss=()=>{const t=dt(),[s,a]=m.useState({}),[o,n]=m.useState({}),{data:l,isLoading:r,isError:p}=G({queryKey:["s3UpcomingInvoices"],queryFn:_s}),g=c=>n(x=>{if(!x[c])return x;const h={...x};return delete h[c],h}),u=m.useMemo(()=>(l==null?void 0:l.invoices)??[],[l]),b=()=>{t.invalidateQueries({queryKey:["s3UpcomingInvoices"]}),t.invalidateQueries({queryKey:["s3Summary"]}),t.invalidateQueries({queryKey:["s3VestingSchedule"]})},S=je({meta:{suppressGlobalErrorHandler:!0},mutationFn:c=>js({block_contract_id:c.row.block_contract_id,period_seq:c.row.period_seq,amount:c.tokens,idempotency_key:Wt()}),onSuccess:(c,x)=>{g(U(x.row)),a(h=>{const f={...h};return delete f[ue(x.row)],f}),b()},onError:(c,x)=>{n(h=>({...h,[U(x.row)]:Le(c)})),ms(c)&&a(h=>{const f={...h};return delete f[ue(x.row)],f}),b()}}),I=je({meta:{suppressGlobalErrorHandler:!0},mutationFn:c=>ks(c.reservationId),onSuccess:(c,x)=>{g(U(x.row)),a(h=>{const f={...h};return delete f[ue(x.row)],f}),b()},onError:(c,x)=>{n(h=>({...h,[U(x.row)]:Le(c)})),b()}}),_=je({meta:{suppressGlobalErrorHandler:!0},mutationFn:c=>Ts({block_contract_id:c.row.block_contract_id,...c.enabled===void 0?{}:{enabled:c.enabled},...c.recurringTokens===void 0?{}:{recurring_tokens:c.recurringTokens},...c.clearRecurring?{clear_recurring_tokens:!0}:{}}),onSuccess:(c,x)=>{g(U(x.row)),a(h=>{const f={...h};return delete f[ue(x.row)],f}),b()},onError:(c,x)=>{n(h=>({...h,[U(x.row)]:Le(c)})),b()}}),v=S.isPending||I.isPending||_.isPending,M=fs(u),k=u.map(c=>{const x=ue(c),h=U(c),f=j(c.applied_tokens),C=me(c),A=ls(c,l),w=us(s,x,c,A),{tokens:q,error:L}=is(w,A,os(c,A)),pe=ds(c),re=o[h],P=ps(c,w,A),X=P.previewTokens,N=xs(c,w);return{invoice:e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"font-medium",children:c.dataset_label||c.dataset_id}),e.jsxs("span",{className:"text-xs text-gray-600 dark:text-gray-300",children:[c.cut||"Entire dataset"," · period ",c.period_seq]})]}),period:e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{children:De(c.period_start)}),e.jsx("span",{className:pe.urgent?"text-xs font-medium text-amber-600 dark:text-amber-400":"text-xs text-gray-600 dark:text-gray-300",children:pe.label})]}),invoice_amount:e.jsx(O,{tokenIconColor:"s3",children:T(c.invoice_amount)}),tokens:C?e.jsx(O,{tokenIconColor:"s3",children:T(f)}):e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"number",min:0,max:A,step:1,value:w,placeholder:"0","aria-label":`S3 tokens to apply to ${c.dataset_label||c.dataset_id}`,disabled:v,onChange:F=>{a(R=>({...R,[x]:F.target.value})),g(h)},className:"w-20 rounded border border-border bg-background px-2 py-1 text-sm disabled:opacity-50"}),e.jsx("button",{type:"button",disabled:v||!!L||w.trim()===""||q<=0||q===f,onClick:()=>S.mutate({row:c,tokens:q}),className:"rounded bg-primary px-2.5 py-1 text-sm text-white disabled:opacity-50",children:f?"Update":"Apply"}),f>0&&c.reservation_id&&e.jsx("button",{type:"button",disabled:v,onClick:()=>I.mutate({row:c,reservationId:String(c.reservation_id)}),className:"rounded border border-border px-2.5 py-1 text-sm disabled:opacity-50",children:"Remove"})]}),e.jsxs("span",{className:"flex min-h-8 flex-col gap-0.5",children:[(L||re)&&e.jsx("span",{className:"text-xs leading-4 text-red-600 dark:text-red-400",children:L||re}),P.shortfallNote&&e.jsx("span",{className:"text-xs leading-4 text-gray-600 dark:text-gray-300",children:P.shortfallNote}),P.resetTo!==null&&e.jsx("button",{type:"button",disabled:v,onClick:()=>{a(F=>({...F,[x]:P.resetTo})),g(h)},className:"self-start text-xs leading-4 text-gray-600 underline disabled:opacity-50 dark:text-gray-300",children:P.resetLabel}),P.appliedNote&&e.jsx("span",{className:"text-xs leading-4 text-gray-600 dark:text-gray-300",children:P.appliedNote})]})]}),automatic:e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx(St,{checked:N.on,onChange:F=>_.mutate({row:c,enabled:F}),disabled:v||C,label:"",sizing:"sm",color:"info",theme:Cs,"aria-label":`Apply tokens automatically for ${c.dataset_label||c.dataset_id}`}),e.jsxs("span",{className:"flex min-h-8 flex-col gap-0.5",children:[N.caption&&e.jsx("span",{className:"text-xs leading-4 text-gray-600 dark:text-gray-300",children:N.caption}),N.adopt&&e.jsx("button",{type:"button",disabled:v,onClick:()=>{var F;return _.mutate({row:c,recurringTokens:(F=N.adopt)==null?void 0:F.tokens})},className:"self-start text-xs leading-4 text-gray-600 underline disabled:opacity-50 dark:text-gray-300",children:N.adopt.label})]})]}),net_due:e.jsx(O,{tokenIconColor:"s3",className:"text-base font-semibold",children:T(cs(c,X))})}}),Z=j(l==null?void 0:l.remaining);return e.jsxs("div",{className:"flex flex-col gap-4 w-full",children:[p&&e.jsx("div",{className:"text-sm text-red-600 dark:text-red-400",children:"Failed to load your upcoming invoices."}),u.length>0&&e.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-lg border border-border bg-card px-3 py-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm font-semibold",children:"Automatic Application of S3 Tokens"}),e.jsx("span",{className:M.mode==="none"?"rounded-full bg-gray-100 px-2 py-0.5 text-xs font-medium text-gray-700 dark:bg-gray-800 dark:text-gray-300":"rounded-full bg-emerald-100 px-2 py-0.5 text-xs font-medium text-emerald-800 dark:bg-emerald-950/40 dark:text-emerald-300",children:M.label})]}),e.jsx("button",{type:"button",disabled:v,onClick:()=>{const c=M.mode!=="all";u.filter(x=>!me(x)).filter(x=>
1x.auto_apply_enabled!==!1!==c).forEach(x=>_.mutate({row:x,enabled:c}))},className:"shrink-0 rounded border border-border px-3 py-1 text-sm disabled:opacity-50",children:M.mode==="all"?"Turn all off":"Turn all on"})]}),e.jsxs("div",{className:"grid grid-cols-1 gap-3 rounded-lg border border-border bg-card p-3 sm:grid-cols-3",children:[e.jsx(Fe,{label:"Available now",value:l==null?void 0:l.available}),e.jsx(Fe,{label:"Applied to upcoming invoices",value:l==null?void 0:l.reserved}),e.jsx(Fe,{label:"Remaining",value:l==null?void 0:l.remaining,emphasis:Z<0?"warn":void 0})]}),e.jsx(Ce,{columns:[{title:"Invoice",key:"invoice",className:"w-[22%]"},{title:"Period",key:"period",className:"w-[13%]"},{title:"Invoice amount",key:"invoice_amount",className:"w-[13%]"},{title:"S3 tokens",key:"tokens",className:"w-[22%]"},{title:e.jsxs("span",{className:"inline-flex items-center gap-1",children:["Automatic",e.jsx(ct,{infoText:hs,iconClassName:"size-4",placement:"bottom",tooltipClassName:"max-w-xs whitespace-normal text-left font-normal"})]}),key:"automatic",className:"w-[15%]"},{title:"Net due",key:"net_due",className:"w-[15%]"}],data:k,isBodyLoading:r,cellClassName:"p-2 align-top",headCellClassName:"px-2",className:"table-fixed w-full",showNoData:!0,noDataMessage:"No upcoming invoices to apply tokens to"})]})},ws=()=>{const[t,s]=m.useState(new Set),a=o=>s(n=>{const l=new Set(n);return l.delete(o)||l.add(o),l});return e.jsx(Oe,{dataKey:"s3-transactions",queryKeyBase:"s3CreditEvents",fetchEvents:vs,noDataMessage:"No S3 token activity to display",errorMessage:"Failed to load S3 token activity.",hideBalanceColumns:!0,methodColumnTitle:"Period",dateFormatOptions:ts,tokenIconColor:"s3",rowKey:"transaction_id",expandedRowKeys:t,onRowClick:o=>{const n=o.lines,l=o.transaction_id;l&&(n!=null&&n.length)&&a(l)},expandedRowRender:o=>{const n=o.lines;return n!=null&&n.length?e.jsx("div",{className:"px-6 py-2",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"text-left text-xs uppercase tracking-wide text-gray-500 dark:text-gray-400",children:[e.jsx("th",{className:"py-1 font-medium",children:"Invoice"}),e.jsx("th",{className:"py-1 text-right font-medium",children:"S3 tokens"})]})}),e.jsx("tbody",{children:n.map((l,r)=>e.jsxs("tr",{className:"border-t border-gray-200 dark:border-gray-700",children:[e.jsx("td",{className:"py-1",children:l.period_seq!=null?`Period ${l.period_seq}`:"Unattributed"}),e.jsx("td",{className:"py-1 text-right tabular-nums",children:ne(l.amount,2)})]},r))})]})}):null}})},Es=({percent:t})=>{const s=Math.max(0,Math.min(100,t));return e.jsx("div",{className:"h-1.5 w-full rounded-full bg-gray-200 dark:bg-gray-700",role:"progressbar","aria-valuenow":s,"aria-valuemin":0,"aria-valuemax":100,children:e.jsx("div",{className:"h-full rounded-full",style:{width:`${s}%`,backgroundColor:Rt}})})},Ps=()=>{const{data:t,isLoading:s,isError:a}=G({queryKey:["s3VestingSchedule"],queryFn:gs}),o=m.useMemo(()=>t??[],[t]),n=(r,p=!1)=>e.jsx(O,{tokenIconColor:"s3",className:p?"font-semibold":void 0,children:T(r)}),l=o.map(r=>{const p=ss(r);return{award_date:De(r.award_date),status:e.jsx("span",{className:`inline-flex rounded-full px-2 py-0.5 text-xs font-medium ${as(r)}`,children:mt(r)}),allocated:n(r.allocated),progress:e.jsxs("div",{className:"flex flex-col gap-1",children:[Se(r)&&e.jsx(Es,{percent:r.progress_pct}),e.jsx("span",{className:"text-xs text-gray-600 dark:text-gray-300",children:es(r)})]}),accrued:n(r.accrued),consumed:n(r.consumed),available:n(r.available,!0),next_vest:e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{children:p.date}),p.amount&&e.jsx("span",{className:"text-xs text-gray-600 dark:text-gray-300",children:p.amount})]})}});return e.jsxs("div",{className:"flex flex-col gap-4 w-full",children:[a&&e.jsx("div",{className:"text-sm text-red-600 dark:text-red-400",children:"Failed to load the S3 vesting schedule."}),e.jsx(Ce,{columns:[{title:"Award Date",key:"award_date",className:"w-[12%]"},{title:"Status",key:"status",className:"w-[10%]"},{title:"Allocated",key:"allocated",className:"w-[12%]"},{title:"Vesting Progress",key:"progress",className:"w-[20%]"},{title:"Accrued",key:"accrued",className:"w-[12%]"},{title:"Consumed",key:"consumed",className:"w-[12%]"},{title:"Available",key:"available",className:"w-[12%]"},{title:"Next Vest",key:"next_vest",className:"w-[10%]"}],data:l,isBodyLoading:s,cellClassName:"p-2 align-middle",headCellClassName:"px-2",className:"table-fixed w-full",showNoData:!0,noDataMessage:"No S3 token grants to display"})]})},$e=({label:t,value:s})=>e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-gray-600 dark:text-gray-300",children:t}),e.jsx("div",{children:s})]}),lt=({token:t})=>e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"font-medium",children:t!==void 0?t.toLocaleStr
1ing(void 0,{minimumFractionDigits:2,maximumFractionDigits:2}):"N/A"}),t!==void 0&&e.jsx("div",{className:"flex items-center justify-center size-3",children:e.jsx(Q,{alt:"Token",className:"size-full"})})]}),Ms=({wallet:t,expiry_schedule:s,fallbackWalletName:a="Wallet",asSection:o=!1})=>{var n,l;return Et(t==null?void 0:t.balance)||(t==null?void 0:t.balance)<=0?null:e.jsxs("div",{className:o?"border-t border-border p-4":"border border-border rounded-lg p-4 bg-card",children:[e.jsx("h4",{className:"text-lg font-semibold mb-3 text-foreground",children:(t==null?void 0:t.token_name)||a}),e.jsxs("div",{className:"space-y-2",children:[e.jsx($e,{label:"Balance",value:e.jsx(lt,{token:t==null?void 0:t.balance})}),(t==null?void 0:t.max_balance)!==void 0&&(t.max_balance??0)>0&&e.jsx($e,{label:"Maximum Balance",value:t.max_balance}),((t==null?void 0:t.earliest_expiry_at)||(t==null?void 0:t.latest_expiry_at))&&e.jsx($e,{label:"Tokens Expire",value:e.jsxs("div",{className:"flex items-center gap-1",children:[ae((t==null?void 0:t.earliest_expiry_at)||(t==null?void 0:t.latest_expiry_at)),(((n=s==null?void 0:s.filter(r=>{var p;return(t==null?void 0:t.wallet_type)===((p=r==null?void 0:r.wallet_type)==null?void 0:p.toLowerCase())}))==null?void 0:n.length)??0)>1&&e.jsx(qe,{style:"light",trigger:"click",content:e.jsxs("div",{className:"min-w-[20rem] p-4",children:[e.jsx(Pt.Title,{level:6,className:"text-center",children:"Token Expiry Schedule"}),e.jsx("div",{className:"flex flex-col w-full mt-4 border rounded-lg max-h-64 overflow-y-auto",children:(l=s==null?void 0:s.filter(r=>{var p;return(t==null?void 0:t.wallet_type)===((p=r==null?void 0:r.wallet_type)==null?void 0:p.toLowerCase())}))==null?void 0:l.map(r=>e.jsxs("div",{className:"flex flex-row border-b last:border-b-0",children:[e.jsx("span",{className:"flex-1 p-4 border-r",children:e.jsx(lt,{token:r==null?void 0:r.amount})}),e.jsx("span",{className:"flex-1 p-4",children:ae(r==null?void 0:r.expires_at)})]},r==null?void 0:r.expires_at))})]}),placement:"bottom",children:e.jsx(Vt,{className:"cursor-pointer"})})]})})]})]})},As=["platform","mcp","s3"],ht=t=>As.filter(s=>s==="platform"?t.showPlatformCard:s==="mcp"?t.showMcpCard:t.showS3Card),Is=(t,s)=>{switch(t){case"platform":return[...s.showPlatformTransactions?["platform"]:[],...s.showScheduledTransactions?["scheduled"]:[]];case"mcp":return s.showMcpTransactions?["mcp"]:[];case"s3":return["s3-vesting","s3-next-billing","s3-activity"]}},Ls=(t,s)=>{const a=ht(s);return t&&a.includes(t)?t:a[0]??null},Fs={ArrowDown:1,ArrowRight:1,ArrowUp:-1,ArrowLeft:-1},$s=(t,s,a)=>{if(!a.length)return null;if(t==="Home")return a[0];if(t==="End")return a[a.length-1];const o=Fs[t];if(!o)return null;const n=s?a.indexOf(s):-1;return n<0?a[0]:a[(n+o+a.length)%a.length]},qs=qt(it.stripeApiKey),se=1,Os=[{value:"primary",label:"Primary"},{value:"mcp_primary",label:"Primary MCP"}],Ds={platform:"Platform",mcp:"MCP",s3:"S3 Tokens"},Ks=({title:t,tabs:s,defaultTabId:a,showTitle:o=!0,sectionClassName:n="w-full col-span-1 lg:col-span-2",contentWrapperClassName:l="w-full max-h-[calc(100vh-260px)] overflow-y-auto"})=>{var u;const[r,p]=m.useState(a??((u=s[0])==null?void 0:u.id)??""),g=m.useMemo(()=>s.find(b=>b.id===r)??s[0],[r,s]);return m.useEffect(()=>{if(!s.length)return;s.some(S=>S.id===r)||p(a??s[0].id)},[r,a,s]),e.jsxs("section",{className:n,children:[e.jsxs("div",{className:"flex flex-col gap-3 mb-4 sm:flex-row sm:items-end sm:justify-between",children:[o&&e.jsx("h2",{className:"text-2xl font-semibold text-foreground",children:t}),e.jsx("div",{className:"flex items-end gap-8",role:"tablist","aria-label":t,children:s.map(b=>{const S=b.id===r;return e.jsx("button",{type:"button",role:"tab","aria-selected":S,tabIndex:S?0:-1,disabled:b.disabled,onClick:()=>p(b.id),className:["pb-2 text-xl border-b-2 transition-colors",b.disabled?"opacity-50 cursor-not-allowed":"",S?"font-bold border-foreground text-foreground":"font-semibold border-transparent text-ca-300 dark:text-ca-400 hover:text-foreground"].join(" "),children:b.label},b.id)})})]}),e.jsx("div",{className:l,children:g==null?void 0:g.content})]})},Te=B.forwardRef(({label:t,selected:s,onSelect:a,onNavigate:o,className:n,children:l},r)=>e.jsx("div",{ref:r,role:"radio","aria-checked":s,"aria-label":t,tabIndex:s?0:-1,onClick:a,onKeyDown:p=>{if(p.key==="Enter"||p.key===" "){p.preventDefault(),a();return}o(p.key)&&p.preventDefault()},className:ot("relative rounded-lg border bg-card cursor-pointer transition-colors",s?"border-primary bg-primary/5 ring-1 ring-primary":"border-border hover:border-primary/50",n),children:l}));Te.displayName="WalletSelectCard";const en=()=>{var Ye,Je,Ze,Xe,et,tt;const{isWholesaleClient:t,isLoading:s}=Qt(),{planData:a,userBalanceData:o,isUserBalanceLoading:n,reFetchUserBalance:l}=Mt({enabled:!s&&!t}),r=dt(),[p]=Ht(),g=Ut(),{profileData:u}=At(),[b,S]=m.useState(se),[I]=m.useState({startDate:new Date,endD
1ate:new Date}),[_,v]=m.useState(""),[M,k]=m.useState(!1),[Z,c]=m.useState(!1),[x,h]=m.useState(!1),[f,C]=m.useState(!1),[A,w]=m.useState(null),[q,L]=m.useState(!1),[pe,re]=m.useState(!1),[P,X]=m.useState("primary"),N=m.useMemo(()=>{var i;return(i=o==null?void 0:o.wallets)==null?void 0:i.find(d=>d.wallet_type==="purchased"&&d.token_key.trim().toLowerCase()==="primary")},[o]),F=m.useMemo(()=>{var i;return(i=o==null?void 0:o.wallets)==null?void 0:i.filter(d=>d.wallet_type==="promotional"&&d.token_key.trim().toLowerCase()==="promotional")},[o]),R=m.useMemo(()=>{var i;return(i=o==null?void 0:o.wallets)==null?void 0:i.find(d=>d.wallet_type==="purchased"&&(d.token_key.trim().toLowerCase()==="mcp primary"||d.token_key.trim().toLowerCase()==="mcp_primary"))},[o]),xe=m.useMemo(()=>{var i,d;return((i=u==null?void 0:u.client)==null?void 0:i.plan_tier)==="enterprise"&&!!((d=u==null?void 0:u.client)!=null&&d.id)},[(Ye=u==null?void 0:u.client)==null?void 0:Ye.id,(Je=u==null?void 0:u.client)==null?void 0:Je.plan_tier]),le=m.useMemo(()=>{var d;const i=(d=u==null?void 0:u.client)==null?void 0:d.payment_method;return i!=null?i==="invoice":!!(a!=null&&a.invoice_payment)},[(Ze=u==null?void 0:u.client)==null?void 0:Ze.payment_method,a==null?void 0:a.invoice_payment]),W=m.useMemo(()=>!le||!xe,[le,xe]),bt=m.useMemo(()=>{const d=[{value:"",label:"Select Payment Method"},{value:"card_ach",label:xe?"Card / ACH":"Card"},{value:"invoice",label:"Invoice"}];return W?d.filter(E=>E.value!=="invoice"):d},[xe,W]),[oe,Ke]=m.useState(null),[ie,ze]=m.useState(null),[ee,Be]=m.useState(!1),[te,Re]=m.useState(null),We=B.useRef(null),ce=B.useRef(null),de=B.useRef(null),V=B.useCallback(()=>{ce.current!==null&&(window.clearInterval(ce.current),ce.current=null),de.current!==null&&(window.clearTimeout(de.current),de.current=null)},[]),fe=B.useCallback(()=>{!s&&!t&&(l==null||l()),r.invalidateQueries({queryKey:["mcpSubscription"]})},[t,s,r,l]);m.useEffect(()=>{if(s)return;const i=p.get("showWalletModal"),d=p.get("tokenType");i==="true"&&(t||(c(!0),(d==="primary"||d==="mcp_primary")&&X(d)),g("/my/wallet",{replace:!0}))},[t,s,g,p]),m.useEffect(()=>{W&&_==="invoice"&&(v(""),H(le?"Invoice payment method is only available for Enterprise clients. Please select another method.":"Invoice payment method is currently unavailable based on your plan. Please select another method.",{duration:6e3}))},[le,_,W]),m.useEffect(()=>{W&&_===""&&v("card_ach")},[_,W]),m.useEffect(()=>{if(f&&A){h(!1);const i=setTimeout(()=>{h(!0)},100);return()=>clearTimeout(i)}},[f,A]);const{mutateAsync:yt}=je({mutationFn:It,onSuccess:()=>{r.invalidateQueries({queryKey:["user-balance"]}),r.invalidateQueries({queryKey:["creditEvents"]}),r.invalidateQueries({queryKey:["mcpCreditEvents"]}),r.invalidateQueries({queryKey:["mcpCreditEventsPreview"]}),r.invalidateQueries({queryKey:["s3Summary"]}),r.invalidateQueries({queryKey:["s3CreditEvents"]}),r.invalidateQueries({queryKey:["s3VestingSchedule"]}),r.invalidateQueries({queryKey:["s3UpcomingInvoices"]})}}),{data:D,isLoading:gt}=G({queryKey:["mcpSubscription"],queryFn:()=>Lt()}),he=B.useCallback(()=>{V(),Re(null)},[V]),K=typeof((et=(Xe=o==null?void 0:o.scope_balances)==null?void 0:Xe.platform)==null?void 0:et.total_balance)=="number"?o.scope_balances.platform.total_balance:null,z=typeof(R==null?void 0:R.balance)=="number"&&!Number.isNaN(R.balance)?R.balance:null,be=B.useCallback(i=>{V(),Be(!1),Ke(K),ze(z),We.current=i,Re(Date.now()),fe()},[z,K,fe,V]);m.useEffect(()=>{if(s)return;const i=p.get("payment_success"),d=p.get("session_id");i==="true"&&d&&(L(!0),be(null),g("/my/wallet",{replace:!0}))},[be,s,g,p]),m.useEffect(()=>{if(!(te!==null&&!ee)){V();return}return ce.current===null&&(ce.current=window.setInterval(()=>{fe()},5e3)),de.current===null&&(de.current=window.setTimeout(()=>{he()},18e4)),()=>{V()}},[ee,he,te,fe,V]),m.useEffect(()=>{te===null||ee||(oe===null&&K!==null&&Ke(K),ie===null&&z!==null&&ze(z))},[ee,z,K,ie,oe,te]),m.useEffect(()=>{if(te===null||ee)return;const i=We.current,d=oe!==null&&K!==null&&Math.abs(K-oe)>1e-4,E=ie!==null&&z!==null&&Math.abs(z-ie)>1e-4;(i==="mcp_primary"?E:i==="primary"?d:d||E)&&(Be(!0),he())},[ee,z,K,he,ie,oe,te]);const{data:ye,isLoading:Ve,isError:He}=G({queryKey:["scheduledTransactionData"],queryFn:()=>Ft()}),Nt=Ve||He||((ye==null?void 0:ye.length)??0)>0,{data:we,isLoading:vt,isError:_t}=G({queryKey:["mcpCreditEventsPreview"],queryFn:()=>ut(0,1)}),jt=vt||_t||((we==null?void 0:we.total)??0)>0,{data:y}=G({queryKey:["s3Summary"],queryFn:ys,enabled:!s&&!t}),Ue=(((tt=y==null?void 0:y.grants)==null?void 0:tt.length)??0)>
10||Number((y==null?void 0:y.allocated)??0)>0||Number((y==null?void 0:y.available)??0)>0||Number((y==null?void 0:y.accrued)??0)>0||Number((y==null?void 0:y.consumed)??0)>0,Qe=!!D&&(t||D.daily_issuance_limit!=null||(D.mcp_balance??0)>0),[kt,ge]=m.useState(null),Ee={showPlatformCard:!t,showMcpCard:Qe,showS3Card:Ue,showPlatformTransactions:!t,showScheduledTransactions:Nt,showMcpTransactions:jt},$=Ls(kt,Ee),Ne=m.useRef({}),Pe=i=>{var E;const d=$s(i,$,ht(Ee));return d?(ge(d),(E=Ne.current[d])==null||E.focus(),!0):!1},Tt={platform:{label:"Platform Transactions",content:e.jsx(Yt,{})},scheduled:{label:"Scheduled Transactions",content:e.jsx(Jt,{scheduledTransactionData:ye,isScheduledTransactionLoading:Ve,isScheduledTransactionError:He})},mcp:{label:"MCP Transactions",content:e.jsx(Zt,{})},"s3-vesting":{label:"Vesting Schedule",content:e.jsx(Ps,{})},"s3-next-billing":{label:"Next Billing",content:e.jsx(Ss,{})},"s3-activity":{label:"Activity History",content:e.jsx(ws,{})}},Ge=$?Is($,Ee).map(i=>({id:i,...Tt[i]})):[],Ct=async()=>{var i,d;if(b===""||b<se||!_||!P){H.error("Please enter a valid token amount (greater than 0) and select a payment method.");return}if(W&&_==="invoice"){H.error(le?"Invoice payment method is only available for Enterprise clients. Please select another method.":"Invoice payment method is currently unavailable based on your plan. Please select another method.");return}k(!0);try{const E=(i=u==null?void 0:u.client)==null?void 0:i.id;if(!E){H.error("Client ID is not found");return}const Me=_==="card_ach"?"credit_card":_,ve=await yt({token_amount:b,payment_method:Me,token_purchase_type:P,success_url:`${window.location.origin}/my/wallet?payment_success=true&session_id={CHECKOUT_SESSION_ID}`,cancel_url:window.location.href,client_id:E});if(Me==="invoice")H.success(e.jsxs("div",{children:["Invoice created!"," ",ve.checkout_url&&e.jsx("a",{href:ve.checkout_url,target:"_blank",rel:"noopener noreferrer",className:"underline text-blue-500",children:"View Invoice"})]}),{duration:8e3}),S(se),v(""),c(!1),be(P);else if((d=ve.payment)!=null&&d.client_secret)w(ve.payment.client_secret),C(!0);else return H.error("Purchase initiated, but no payment details received. Please check your email or contact support.")}catch(E){console.error("Purchase failed",E),H.error(`Purchase failed: ${(E==null?void 0:E.message)||"Please try again later."}`)}finally{k(!1)}};return f&&A&&x?e.jsxs(st,{showHeaderLine:!0,children:[e.jsxs("div",{className:"min-h-[calc(100vh-200px)] py-8",children:[e.jsx("div",{className:"max-w-4xl mx-auto min-h-[624px]",children:e.jsx(Ot,{stripe:qs,options:{clientSecret:A,onComplete:()=>{L(!0),be(P)}},children:e.jsx(Dt,{})})}),e.jsx("div",{className:"mt-8 flex justify-center",children:e.jsx(_e,{color:"light",onClick:()=>{C(!1),w(null),h(!1)},className:"px-6",children:"Cancel Payment"})})]}),e.jsx(Ie,{show:q,onClose:()=>{L(!1),C(!1),w(null),h(!1),setTimeout(()=>{document.activeElement instanceof HTMLElement&&document.activeElement.blur()},0)},size:"md",title:"Transaction Complete",dismissible:!1,children:e.jsxs("div",{className:"space-y-4",children:[e.jsx("p",{className:"text-ca-700 dark:text-ca-300",children:"Please allow up to 2-3 minutes for tokens to appear in your wallet as the payment is processed."}),e.jsx("div",{className:"flex justify-end",children:e.jsx(_e,{onClick:()=>{L(!1),C(!1),w(null),h(!1),setTimeout(()=>{document.activeElement instanceof HTMLElement&&document.activeElement.blur()},0)},children:"Close"})})]})})]}):e.jsxs(st,{showHeaderLine:!0,children:[!t&&e.jsx(Ie,{title:"Purchase Tokens",show:Z,onClose:()=>c(!1),size:"md",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx(Ae,{htmlFor:"modal-token-type",value:"Token Type",className:"mb-2 block text-sm font-medium"}),e.jsx(at,{id:"modal-token-type",value:P,onChange:i=>{const d=i.target.value;(d==="primary"||d==="mcp_primary")&&X(d)},required:!0,className:"w-full focus:ring-0 focus:border-gray-300 dark:focus:border-gray-600",children:Os.map(i=>e.jsx("option",{value:i.value,disabled:i.value==="",children:i.label},i.value))})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-1 mb-2",children:[e.jsx(Ae,{htmlFor:"modal-token-number",value:"Number of Tokens",className:"mb-0 block text-sm font-medium"}),e.jsx(ct,{infoText:"Tokens are $1 each and never expire."})]}),e.jsx(wt,{id:"modal-token-number",placeholder:`Minimum: ${se} token`,value:b===""?"":b.toString(),onChange:i=>{const d=i.target.value;S(d===""?"":Number(d))},type:"number",min:se,className:"w-full"})]}),e.jsxs("div",{children:[e.jsx(Ae,{htmlFor:"modal-payment-method",value:"Payment Method",className:"mb-2 block text-sm font-medium"}
1),e.jsx(at,{id:"modal-payment-method",value:_,onChange:i=>v(i.target.value),required:!0,className:"w-full focus:ring-0 focus:border-gray-300 dark:focus:border-gray-600",children:bt.map(i=>e.jsx("option",{value:i.value,disabled:i.value==="",children:i.label},i.value))})]}),e.jsx("div",{className:"flex justify-end",children:e.jsx(_e,{onClick:Ct,disabled:M||b===""||b<se||!_||!(I!=null&&I.startDate),isProcessing:M,className:"bg-black hover:bg-gray-800 text-white px-8",children:M?"Processing...":"Next"})})]})}),e.jsx("div",{className:"relative p-4 space-y-8",children:n||s||t&&gt?e.jsx("div",{className:"flex justify-center items-center py-12",children:e.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-gray-900"})}):e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[e.jsx("section",{children:e.jsxs("div",{role:"radiogroup","aria-label":"Wallets",className:"flex flex-col gap-4",children:[!t&&e.jsxs(Te,{ref:i=>{i&&(Ne.current.platform=i)},label:"Platform wallet",selected:$==="platform",onSelect:()=>ge("platform"),onNavigate:Pe,children:[e.jsxs("div",{className:"p-4",children:[e.jsxs("div",{className:"flex justify-between gap-2",children:[e.jsx("h4",{className:"text-lg font-semibold mb-3 text-foreground",children:(N==null?void 0:N.token_name)||"Primary"}),e.jsx(qe,{content:"Fund Wallet",className:"w-28 text-center",children:e.jsxs("button",{onClick:i=>{i.stopPropagation(),X("primary"),c(!0)},className:"relative rounded-full transition-colors duration-200","aria-label":"Open wallet",children:[e.jsx(nt,{className:"size-5 text-primary"}),e.jsx("div",{className:"absolute top-2 right-3 bg-card rounded-full p-1",children:e.jsx(rt,{className:"size-2 text-primary"})})]})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-gray-600 dark:text-gray-300",children:"Balance:"}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"font-medium",children:ne(N==null?void 0:N.balance,2,"0.00")}),(N==null?void 0:N.balance)!==void 0&&e.jsx("div",{className:"flex items-center justify-center size-3",children:e.jsx(Q,{alt:"Token",className:"size-full"})})]})]}),(N==null?void 0:N.min_balance)!==void 0&&N.min_balance>0&&e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-gray-600 dark:text-gray-300",children:"Minimum Balance:"}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{children:N.min_balance}),e.jsx("div",{className:"flex items-center justify-center size-3",children:e.jsx(Q,{alt:"Token",className:"size-full"})})]})]}),(N==null?void 0:N.max_balance)!==void 0&&(N.max_balance??0)>0&&e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-gray-600 dark:text-gray-300",children:"Maximum Balance:"}),e.jsx("span",{children:N.max_balance})]})]})]}),e.jsx(Ms,{wallet:F==null?void 0:F[0],fallbackWalletName:"Promotional Wallet",expiry_schedule:o==null?void 0:o.expiry_schedule,asSection:!0})]}),D&&Qe&&e.jsxs(Te,{ref:i=>{i&&(Ne.current.mcp=i)},label:"MCP wallet",selected:$==="mcp",onSelect:()=>ge("mcp"),onNavigate:Pe,className:"p-4",children:[e.jsxs("div",{className:"flex justify-between gap-2 mb-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h4",{className:"text-lg font-semibold text-foreground",children:"MCP"}),e.jsx("button",{onClick:i=>{i.stopPropagation(),re(!0)},className:"hover:opacity-70 transition-opacity","aria-label":"MCP Information",children:e.jsx(Gt,{className:"size-5 text-neutral-500"})})]}),!t&&e.jsx(qe,{content:"Purchase MCP Tokens",className:"w-28 text-center",children:e.jsxs("button",{onClick:i=>{i.stopPropagation(),X("mcp_primary"),c(!0)},className:"relative rounded-full transition-colors duration-200","aria-label":"Open wallet",children:[e.jsx(nt,{className:"size-5 text-primary"}),e.jsx("div",{className:"absolute top-2 right-3 bg-card rounded-full p-1",children:e.jsx(rt,{className:"size-2 text-primary"})})]})})]}),e.jsx("div",{className:"space-y-2",children:e.jsxs("div",{className:"grid grid-cols-1 gap-2 lg:grid-cols-[minmax(0,1fr)_auto] lg:items-center",children:[e.jsx("div",{className:"min-w-0",children:e.jsx("span",{className:"text-gray-600 dark:text-gray-300",children:"Daily token consumption"})}),e.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-1 lg:justify-end",children:[e.jsx("span",{className:"font-medium",children:D.consumption_today.toLocaleStr
1ing(void 0,{minimumFractionDigits:2,maximumFractionDigits:2})}),e.jsx("span",{className:"text-gray-600 dark:text-gray-300",children:"/"}),e.jsx("span",{className:"font-medium",children:D.daily_issuance_limit!=null?D.daily_issuance_limit.toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:2}):"—"}),e.jsx("div",{className:"flex items-center justify-center size-3 shrink-0",children:e.jsx(Q,{color:"blue",alt:"Token",className:"size-full"})})]})]})}),e.jsx("div",{className:"space-y-2 mt-4",children:e.jsxs("div",{className:"grid grid-cols-1 gap-2 sm:grid-cols-[minmax(0,1fr)_auto] sm:items-center",children:[e.jsx("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:e.jsx("span",{className:"min-w-0 text-gray-600 dark:text-gray-300",children:"MCP balance"})}),e.jsxs("div",{className:"flex items-center gap-1 sm:justify-end",children:[e.jsx("span",{className:"font-medium",children:D.mcp_balance.toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:2})}),e.jsx("div",{className:"flex items-center justify-center size-3",children:e.jsx(Q,{color:"blue",alt:"Token",className:"size-full"})})]})]})})]}),Ue&&e.jsxs(Te,{ref:i=>{i&&(Ne.current.s3=i)},label:"S3 Tokens wallet",selected:$==="s3",onSelect:()=>ge("s3"),onNavigate:Pe,className:"p-4",children:[e.jsx("div",{className:"flex justify-between gap-2 mb-3",children:e.jsx("h4",{className:"text-lg font-semibold text-foreground",children:"S3 Tokens"})}),e.jsx("div",{className:"space-y-2",children:[["Allocated",y==null?void 0:y.allocated],["Accrued",y==null?void 0:y.accrued],["Consumed",y==null?void 0:y.consumed],["Available",y==null?void 0:y.available]].map(([i,d])=>e.jsxs("div",{className:"grid grid-cols-1 gap-2 sm:grid-cols-[minmax(0,1fr)_auto] sm:items-center",children:[e.jsx("span",{className:"min-w-0 text-gray-600 dark:text-gray-300",children:i}),e.jsxs("div",{className:"flex items-center gap-1 sm:justify-end",children:[e.jsx("span",{className:i==="Available"?"font-semibold":"font-medium",children:T(d)}),e.jsx("div",{className:"flex items-center justify-center size-3",children:e.jsx(Q,{color:"s3",alt:"S3 token",className:"size-full"})})]})]},i))})]})]})}),$&&Ge.length>0?e.jsx(Ks,{title:`${Ds[$]} transactions`,showTitle:!1,tabs:Ge},$):e.jsx("section",{className:"w-full col-span-1 lg:col-span-2",children:e.jsxs("div",{className:"rounded-lg border border-border bg-card p-6",children:[e.jsx("h3",{className:"text-lg font-semibold text-foreground",children:$?"No transactions yet":"No wallets"}),e.jsx("p",{className:"mt-1 text-sm text-gray-600 dark:text-gray-300",children:$?"This wallet has no transactions to display.":"Your account does not have any wallets."})]})})]})}),e.jsx(Ie,{show:q,onClose:()=>{L(!1),C(!1),w(null),h(!1),setTimeout(()=>{document.activeElement instanceof HTMLElement&&document.activeElement.blur()},0)},size:"md",title:"Transaction Complete",dismissible:!1,children:e.jsxs("div",{className:"space-y-4",children:[e.jsx("p",{className:"text-ca-700 dark:text-ca-300",children:"Please allow up to 2-3 minutes for tokens to appear in your wallet as the payment is processed."}),e.jsx("div",{className:"flex justify-end",children:e.jsx(_e,{onClick:()=>{L(!1),C(!1),w(null),h(!1),setTimeout(()=>{document.activeElement instanceof HTMLElement&&document.activeElement.blur()},0)},children:"Close"})})]})}),e.jsx($t,{show:pe,onClose:()=>re(!1)})]})};export{en as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.