PageSourceSearch

https://stellar.expert/billing-admin.0c792aeab3068c564eafa585b55b3f5d.js

js stellar.expert collected 2026-10-02 03:51:12 UTC 24,120 bytes, 1 lines download raw bytes

1"use strict";(globalThis.webpackChunkui_stellar_expert||=[]).push([[678],{33942(e,s,t){t.r(s),t.d(s,{default:()=>Pe});var n=t(9007),a=t(63905),i=t(82448),c=t(63613),l=t(6451),r=t(59910),o=t(95218),d=t(66268),m=t(66324),u=t(50284),h=t(31479);function x({accountId:e,allAccounts:s}){const{summary:t,usage:n}=(0,o.a)(e,s);return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(d.A,{summary:t}),(0,h.jsx)(m.A,{stats:n}),(0,h.jsx)(u.A,{endpoints:t?.month?.endpoints})]})}function p(){return(0,h.jsx)(r.A,{title:"Dashboard",children:(0,h.jsx)(x,{allAccounts:!0})})}var j=t(15685),g=t(45423),b=t(13757),f=t(76844),N=t(18100),v=t(90770),y=t(64870);const C={charge:"Charge",rejected:"Rejected",payment:"Payment",deposit:"Added deposit",burn:"Burned balance","subscription-renewed":"Subscription renewed","subscription-changed":"Subscription changed","subscription-renewal-cancelled":"Renewal cancelled","subscription-renewal-resumed":"Renewal resumed","subscription-cancelled":"Subscription cancelled","subscription-expired":"Subscription ended"},k={rejected:"log-alert",payment:"log-success",deposit:"log-success",burn:"log-warning","subscription-renewal-cancelled":"log-warning","subscription-cancelled":"log-warning","subscription-expired":"log-warning"},A={"rate-limit":"rate limit exceeded","insufficient-credits":"not enough credits","invalid-key":"invalid API key"};function S({entry:{requestType:e,data:s}}){return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)("span",{className:"request-type",children:C[e]||e}),!!s?.reason&&(0,h.jsxs)("span",{className:"dimmed text-small",children:[" ",A[s.reason]||s.reason]}),"payment"===e&&(0,h.jsxs)("span",{className:"dimmed text-small",children:[" $",s.amount.toFixed(2)," · ",s.method]})]})}var w=t(56011),$=t(78965),q=t(56539);function F(e=0,s=20,t={}){return(0,q.A)(`logs${(0,$._)({...t,page:e,limit:s})}`)}var P=t(60523),T=t(84899);const O=Object.entries(C).map(([e,s])=>({value:e,title:s}));const R={email:{title:"Account email",description:"Account email",icon:"email",multi:!1,editor:P.tp},type:{title:"Request type",description:"Request type",icon:"puzzle",editor:function({value:e,setValue:s}){return s?(0,h.jsx)(T.m,{title:"Choose request type",expanded:!0,onChange:s,options:O}):(0,h.jsx)("span",{children:C[e]||"Unknown request type"})}},from:{title:"After",description:"After date",icon:"angle-right",multi:!1},to:{title:"Before",description:"Before date",icon:"angle-left",multi:!1}};function E({presetFilter:e,onChange:s}){return(0,h.jsx)(g.Y,{presetFilter:e,fields:R,onChange:s})}function M(){const[e,s]=(0,n.useState)(),[t,a]=(0,n.useState)(0),[i,c]=(0,n.useState)(!1),[l,r]=(0,n.useState)(()=>({page:0,filters:(0,g.z)()||{}})),o=(0,n.useCallback)(e=>r({page:0,filters:e}),[]),d=(0,n.useCallback)(e=>r(s=>({...s,page:s.page+e})),[]);(0,n.useEffect)(()=>{c(!0),F(l.page,20,l.filters).then(e=>{s(e.items),a(e.total)}).catch(e=>notify({type:"error",message:"Failed to load logs. "+e?.message})).finally(()=>c(!1))},[l]);const m=l.page>0,u=20*(l.page+1)<t;return!e&&i?(0,h.jsx)(w.A,{inside:!0}):(0,h.jsxs)("div",{className:"relative",children:[(0,h.jsx)(E,{onChange:o}),(0,h.jsxs)("table",{className:"billing-table exportable billing-log micro-space",children:[(0,h.jsx)("thead",{children:(0,h.jsxs)("tr",{children:[(0,h.jsx)("th",{children:"Account"}),(0,h.jsx)("th",{children:"Request type"}),(0,h.jsx)("th",{className:"text-right",children:"Credits"}),(0,h.jsx)("th",{className:"collapsing text-right",children:"Timestamp"})]})}),(0,h.jsx)("tbody",{className:"condensed",children:e?.map(e=>(0,h.jsxs)("tr",{className:k[e.requestType],children:[(0,h.jsx)("td",{"data-header":"Account: ",children:e.email||(0,j.l)(e.account)}),(0,h.jsx)("td",{"data-header":"Request type: ",children:(0,h.jsx)(S,{entry:e})}),(0,h.jsx)("td",{"data-header":"Credits: ",className:"text-right",children:(0,h.jsx)(b.J,{amount:e.data.credits})}),(0,h.jsxs)("td",{className:"nowrap text-right","data-header":"Timestamp: ",children:[(0,h.jsx)(f.j,{date:e.timestamp}),(0,h.jsx)("div",{className:"dimmed text-tiny",children:(0,h.jsx)(N.Y,{ts:e.timestamp,suffix:" ago"})})]})]},e.id))})]}),!!i&&(0,h.jsx)("div",{className:"loader"}),!i&&!t&&(0,h.jsx)("div",{className:"dimmed text-center text-small",children:"(No log entries)"}),(0,h.jsx)("div",{className:"text-center space",children:(0,h.jsxs)(v.e,{children:[(0,h.jsx)(y.$,{disabled:i||!m,onClick:()=>d(-1),children:"Prev Page"}),(0,h.jsx)(y.$,{disabled:i||!u,onClick:()=>d(1),children:"Next Page"})]})})]})}function I(){return(0,h.jsx)(r.A,{title:"Logs",children:(0,h.jsx)(M,{})})}var U=t(64611);const L={from:{title:"After",description:"After date",icon:"angle-right",multi:!1},to:{title:"Before",description:"Before date",icon:"angle-left",multi:!1}},z=n.memo(function({onChange:e}){return(0,h.jsx)(g.Y,{fields:L,onChange:e})});function B(){const{id:e}
1=(0,a.g)(),[s,t]=(0,n.useState)(),[i,c]=(0,n.useState)((0,$.m)());(0,n.useEffect)(()=>{(0,q.A)(`account/${e}`).then(e=>t(e.email)).catch(()=>t(void 0))},[e]);const l=(0,h.jsxs)("span",{className:"dimmed text-small",children:[(0,h.jsxs)("code",{className:"text-small billing-account-ref",children:["account #",(0,j.l)(e,8)]}),!!s&&(0,h.jsxs)(h.Fragment,{children:[" · Billed to ",s]})]});return(0,h.jsxs)(r.A,{title:"User billing history",action:l,children:[(0,h.jsx)(z,{onChange:c}),(0,h.jsx)("div",{className:"micro-space",children:(0,h.jsx)(U.A,{account:e,filters:i})})]})}var D=t(19742),K=t.n(D),Y=t(7795),J=t(23299),Z=t(17808),_=t(72217);const G=[{months:1,title:"+1 month"},{months:6,title:"+6 months"},{months:12,title:"+1 year"}],Q=[{name:"photons",title:"Photons/month"},{name:"requestsPerMinute",title:"Requests/minute"},{name:"batchSize",title:"Items/batch response"},{name:"priceOverride",title:"Price override, USD/month"}];function V(){const{id:e}=(0,a.g)(),[s,t]=(0,n.useState)(),[i,c]=(0,n.useState)(!0),[l,o]=(0,n.useState)(!1),[d,m]=(0,n.use
1State)();(0,n.useEffect)(()=>{e&&(c(!0),(0,q.A)(`account/${e}`).then(e=>{t(e),m(function(e){const s=e?.limits||{};return{plan:e?.plan||Z.e4[0].key,photons:te(s.photons),requestsPerMinute:te(s.requestsPerMinute),batchSize:te(s.batchSize),priceOverride:e?.custom?te(e.price):"",internalNote:e?.internalNote||"",notifyOwner:!1,extendMonths:void 0}}(e.subscription))}).catch(e=>notify({type:"error",message:"Failed to retrieve account data. "+e?.message})).finally(()=>c(!1)))},[e]);const u=`/admin/user/${e}`,x=(0,n.useCallback)(e=>{const{plan:s}=e.currentTarget.dataset;m(e=>({...e,plan:s}))},[]),p=(0,n.useCallback)(e=>{const{name:s,value:t}=e.target;m(e=>({...e,[s]:t.replace(/\D/g,"")}))},[]),g=(0,n.useCallback)(e=>m(s=>({...s,internalNote:e.target.value})),[]),b=(0,n.useCallback)(e=>{const{checked:s}=e.target;m(e=>({...e,notifyOwner:s}))},[]),f=(0,n.useCallback)(e=>{const s=Number(e.currentTarget.dataset.months);m(e=>({...e,extendMonths:e.extendMonths===s?void 0:s}))},[]),N=(0,n.useCallback)(()=>{o(!0),(0,q.A)(`account/${e}/subscription`,{method:"POST",params:X(d)}).then(()=>{notify({type:"success",message:"Subscription has been updated"}),Y.L.navigate(u)}).catch(e=>notify({type:"error",message:"Failed to update subscription. "+e?.message})).finally(()=>o(!1))},[e,d,u]),v="Edit subscription",C=(0,h.jsxs)("span",{className:"dimmed text-small",children:[(0,h.jsxs)("code",{className:"text-small billing-account-ref",children:["account #",(0,j.l)(e,8)]}),!!s?.email&&(0,h.jsxs)(h.Fragment,{children:[" · ",s.email]})]});if(i||!d)return(0,h.jsx)(r.A,{title:v,action:C,children:(0,h.jsx)(w.A,{inside:!0})});const k=(0,Z.L9)(d.plan),{subscription:A}=s,S=!!A||!!d.extendMonths;return(0,h.jsx)(r.A,{title:v,action:C,children:(0,h.jsxs)("div",{className:"row",children:[(0,h.jsx)("div",{className:"column column-50",children:(0,h.jsxs)("div",{className:"card card-blank billing-card billing-plan-picker",children:[(0,h.jsx)("div",{className:"dimmed text-small",children:"PLAN"}),Z.e4.map(e=>(0,h.jsx)(W,{plan:e,selected:e.key===d.plan,onSelect:x},e.key)),!!k?.custom&&(0,h.jsx)("div",{className:"row space",children:Q.map(({name:e,title:s})=>(0,h.jsxs)("div",{className:"column column-50",children:[(0,h.jsx)("label",{className:"dimmed text-small",children:s}),(0,h.jsx)("input",{name:e,value:d[e]??"",onChange:p})]},e))})]})}),(0,h.jsx)("div",{className:"column column-50",children:(0,h.jsxs)("div",{className:"card card-blank billing-card billing-subscription-terms",children:[(0,h.jsx)("div",{className:"dimmed text-small",children:"TERM"}),(0,h.jsx)(H,{subscription:A,extendMonths:d.extendMonths}),(0,h.jsxs)("div",{className:"micro-space",children:[(0,h.jsx)("span",{className:"dimmed",children:"Extend"})," ",G.map(({months:e,title:s})=>(0,h.jsxs)(n.Fragment,{children:[(0,h.jsx)("a",{href:"#","data-months":e,onClick:f,className:K()({dimmed:d.extendMonths&&d.extendMonths!==e}),children:s})," "]},e))]}),(0,h.jsxs)("div",{className:"space",children:[(0,h.jsx)("label",{className:"dimmed text-small",children:"Internal note"}),(0,h.jsx)("textarea",{value:d.internalNote,onChange:g,rows:4})]}),(0,h.jsxs)("label",{className:"billing-checkbox micro-space",children:[(0,h.jsx)("input",{type:"checkbox",checked:d.notifyOwner,onChange:b}),"Notify account owner by email"]}),(0,h.jsxs)("div",{className:"row space",children:[(0,h.jsx)("div",{className:"column column-33",children:(0,h.jsx)(y.$,{block:!0,disabled:l||!S,onClick:N,children:"Confirm"})}),(0,h.jsx)("div",{className:"column column-33",children:(0,h.jsx)(y.$,{block:!0,outline:!0,href:u,children:"Cancel"})})]}),!S&&(0,h.jsx)("div",{className:"dimmed text-tiny micro-space",children:"This account has no subscription yet - choose a term to start one."})]})})]})})}function W({plan:e,selected:s,onSelect:t}){const{photons:n,requestsPerMinute:a}=e.limits;return(0,h.jsxs)("div",{className:K()("billing-plan-option-row",{selected:s}),children:[(0,h.jsxs)("div",{children:[(0,h.jsx)("strong",{children:e.name}),(0,h.jsx)("div",{className:"dimmed text-tiny",children:ee(e,n,a)})]}),s?(0,h.jsx)("i",{className:"icon-ok",title:"Selected"}):(0,h.jsx)("a",{href:"#","data-plan":e.key,onClick:t,className:"text-small",children:"Select"})]})}function H({subscription:e,extendMonths:s}){if(!e)return(0,h.jsxs)("div",{className:"micro-space",children:[(0,h.jsx)("span",{className:"dimmed",children:"Not subscribed"}),!!s&&(0,h.jsxs)(h.Fragment,{children:[" → ",(0,h.jsxs)("strong",{children:[se(s)," from today"]})]})]});const{from:t,to:n}=e,a=s?(0,_.PS)(n,s):void 0;return(0,h.jsxs)("div",{className:"micro-space",children:[(0,h.jsx)(f.j,{date:t,dateOnly:!0})," → ",(0,h.jsx)(f.j,{date:a||n,dateOnly:!0}),(0,h.jsxs)("span",{className:"dimmed",children:[" (",(0,_.tz)((0,_.le)(a||n))," left)"]}),!!a&&(0,h.jsxs)("div",{className:"dimmed text-tiny",children:["currently ends ",(0,h.jsx)(f.j,{date:n,dateOnly:!0})]})]})}function X(e){const s={plan:e.plan,internalNote:e.internalNote.trim(),notifyOwner:e.notifyOwner};return(0,Z.L9)(e.plan)?.custom&&(s.photons=e.photons,s.requestsPerMinute=e.requestsPerMinute,s.batchSize=e.batchSize,s.priceOverride=e.priceOverride),e.extendMonths&&(s.extendMonths=e.extendMonths),s}function ee(e,s,t){if(e.custom)return"Custom limits";return`${s?`${(0,J.LE)(s)} photons/month`:"Free"} · ${(0,J.LE)(t)} req/min`}function se(e){return 12===e?"1 year":`${e} ${1===e?"month":"months"}`}function te(e){return"number"==typeof e?String(e):""}var ne=t(27554),ae=t(7489),ie=t(77682),ce=t(25747),le=t(41998),re=t(70031);function oe({account:e}){const{subscription:s,enterpriseRequest:t}=e||{},n=(0,ae.Q)(e)?(0,h.jsx)(de,{request:t}):null;if(!s)return(0,h.jsxs)("div",{className:"micro-space",children:[(0,h.jsx)("div",{className:"dimmed",children:"No active subscription"}),!!n&&(0,h.jsx)("div",{className:"nano-space",children:n})]});const{plan:a,from:i,to:c}=s,l=(0,Z.L9)(a);return(0,h.jsxs)("div",{className:"card card-blank billing-card billing-subscription micro-space",children:[(0,h.jsxs)("div",{className:"dual-layout",children:[(0,h.jsx)("strong",{className:"nowrap",children:l?.name||a}),(0,h.jsx)("span",{className:"dimmed text-small nano-space nowrap",children:(0,Z.Rq)(s)||(l?.custom?"Custom options":null)})]}),(0,h.jsx)(re.A,{from:i,to:c}),(0,h.jsxs)("div",{className:"dual-layout",children:[(0,h.jsx)("div",{children:n}),(0,h.jsxs)("span",{className:"dimmed text-tiny text-right",children:[(0,h.jsx)(f.j,{date:c,dateOnly:!0})," · ",me(c)]})]})]})}function de({request:e}){const s=["Custom plan requested",e?.company,e?.monthlyRequests&&`${(0,J.LE)(Number(e.monthlyRequests))} requests/month`,e?.requested&&`asked ${(0,le.WU)(e.requested)}
1`].filter(Boolean).join(" · ");return(0,h.jsx)("code",{className:"text-tiny nowrap billing-badge pending",title:s,children:"custom tariff required"})}function me(e){if(e<Date.now())return"expired";const s=(0,_.le)(e);return s?`${(0,_.tz)(s)} left`:"last day"}var ue=t(87217),he=t(13695),xe=t(68979);const pe=[{value:100,name:(0,h.jsx)(b.J,{amount:100})},{value:1e3,name:(0,h.jsx)(b.J,{amount:1e3})},{value:1e4,name:(0,h.jsx)(b.J,{amount:1e4})}];function je({values:e=pe,onClick:s,className:t}){const a=(0,n.useCallback)(e=>{e.preventDefault(),s(e)},[s]);return(0,h.jsx)("div",{className:`${t} text-small`,children:e.map(e=>(0,h.jsxs)("span",{children:[" ",(0,h.jsx)("a",{href:"#","data-amount":e.value,onClick:a,children:e.name})]},e.value))})}function ge({account:e,onUpdate:s}){const[t,a]=(0,n.useState)(""),[i,c]=(0,he.m)(),[l,r]=(0,n.useState)(!1),o=e.email||(0,h.jsxs)(h.Fragment,{children:["#",(0,j.l)(e.id)]}),d=(0,n.useCallback)(e=>a(e.target.value.trim().replace(/[^\d.]/g,"")),[]),m=(0,n.useCallback)(e=>a(e.currentTarget.dataset.amount),[]),u=(0,n.useCallback)(()=>{r(!0),(0,q.A)(`account/${e.id}/deposit`,{method:"POST",params:{amount:t}}).then(()=>{s(),notify({type:"success",message:"Credits have been added to the balance"}),c()}).catch(e=>notify({type:"error",message:"Failed to update balance. "+e.message})).finally(()=>r(!1))},[e,t,s]);return(0,h.jsxs)("div",{className:"inline",children:[(0,h.jsx)(y.$,{stackable:!0,small:!0,disabled:e.inactive,onClick:c,children:"Add credits"}),(0,h.jsxs)(xe.A,{title:(0,h.jsxs)(h.Fragment,{children:["Add credits to ",o]}),dialogOpen:i,disabled:l||!Number(t),onConfirm:u,onCancel:c,children:[(0,h.jsx)("div",{className:"space",children:"The credits entered will be added to the user's current balance."}),(0,h.jsxs)("div",{className:"space",children:[(0,h.jsx)("label",{className:"dimmed text-small",children:"Credits to add"}),(0,h.jsx)("input",{value:t,placeholder:`${e.balance} credits`,onChange:d})]}),(0,h.jsx)(je,{onClick:m,className:"text-right"})]})]})}function be({account:e,onUpdate:s}){const t=e.id,a=(0,n.useCallback)(async()=>{await(0,ce.f)((e.inactive?"Restore":"Delete")+" this account?")&&(0,q.A)(`account/${t}`,{method:"DELETE"}).then(s).catch(e=>notify({type:"warning",message:e.message}))},[t,e.inactive,s]);return(0,h.jsx)("div",{className:"space",children:(0,h.jsxs)("div",{className:"card billing-card billing-user-card",children:[(0,h.jsxs)("div",{className:"row",children:[(0,h.jsxs)("div",{className:"column column-33 billing-user-identity",children:[(0,h.jsxs)("div",{children:[(0,h.jsx)("strong",{children:e.email||(0,h.jsxs)(h.Fragment,{children:["#",(0,j.l)(t)]})})," ",(0,h.jsx)(ie.$,{text:e.email||t})]}),(0,h.jsx)("div",{className:"micro-space",children:(0,h.jsx)("a",{href:`/admin/user/${t}/billing-history`,className:"text-small",children:"billing history →"})}),(0,h.jsxs)("div",{className:"billing-user-balance",children:[(0,h.jsx)("div",{className:K()("billing-stat-value",{"color-warning":!e.balance}),children:(0,J.LE)(e.balance)}),(0,h.jsx)("div",{className:"dimmed text-small",children:"CREDIT BALANCE"})]})]}),(0,h.jsxs)("div",{className:"column column-66 billing-user-details",children:[(0,h.jsxs)("div",{className:"row",children:[(0,h.jsxs)("div",{className:"column column-50",children:[(0,h.jsx)("div",{className:"mobile-only micro-space"}),(0,h.jsx)(ue.A,{caption:(0,h.jsxs)(h.Fragment,{children:["API KEYS · ",e.apiKeys.length]}),tokens:e.apiKeys,shorten:16,placeholder:"(No API keys)"})]}),(0,h.jsxs)("div",{className:"column column-50",children:[(0,h.jsx)("div",{className:"mobile-only micro-space"}),(0,h.jsx)(ue.A,{caption:(0,h.jsxs)(h.Fragment,{children:["ORIGINS · ",e.origins.length]}),tokens:e.origins,placeholder:"(No origins)"})]})]}),(0,h.jsx)("div",{className:"row micro-space",children:(0,h.jsxs)("div",{className:"column",children:[(0,h.jsx)("div",{className:"dimmed text-small",children:"SUBSCRIPTION"}),(0,h.jsx)(oe,{account:e})]})})]})]}),(0,h.jsx)("hr",{}),(0,h.jsxs)("div",{className:"dual-layout billing-user-actions",children:[(0,h.jsxs)("div",{children:[(0,h.jsx)(y.$,{href:`/admin/user/${t}`,stackable:!0,small:!0,children:"Settings"}),(0,h.jsx)(ge,{account:e,onUpdate:s}),(0,h.jsx)(y.$,{stackable:!0,small:!0,outline:!0,disabled:e.inactive,"data-id":t,onClick:fe,children:"Log in as"})]}),(0,h.jsx)("div",{className:"text-small",children:(0,h.jsx)("a",{href:"#",onClick:a,"data-id":t,children:e.inactive?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)("i",{className:"icon-undo-circle"})," Restore"]}):(0,h.jsxs)("span",{className:"color-danger",children:[(0,h.jsx)("i",{className:"icon-delete-circle"})," Delete"]})})})]})]})})}function fe(e){const s=e.target.dataset.id;(0,q.A)("auth/login-as",{method:"POST",params:{userId:s}}).then(e=>{localStorage.setItem("loginAsToken",e.accessToken),location.href="/account"}).catch(e=>notify({type:"warning",message:e.message}))}function Ne(e){return function(){return(0,h.jsx)("span",{children:e})}}const ve={email:{title:"Email",description:"Account email",icon:"email",multi:!1,editor:P.tp},zeroBalance:{title:"Zero balance",description:"Zero balance",icon:"coins",multi:!1,flag:!0,editor:Ne("Zero balance")},customTariff:{title:"Custom tariff required",description:"Custom tariff required",icon:"warning",multi:!1,flag:!0,editor:Ne("Custom tariff required")}},ye=n.memo(function({onChange:e}){return(0,h.jsx)(g.Y,{fields:ve,onChange:e})});function Ce({accounts:e=[],onUpdate:s}
1){const[t,a]=(0,n.useState)({}),i=(0,n.useMemo)(()=>function(e,{email:s,zeroBalance:t,customTariff:n}){const a=s?.trim().toLowerCase();return a||t||n?e.filter(e=>!(a&&!e.email?.toLowerCase().includes(a))&&(!(t&&e.balance>0)&&!(n&&!(0,ae.Q)(e)))):e}(e,t),[e,t]);return(0,h.jsxs)("div",{children:[(0,h.jsx)(ye,{onChange:a}),i.map(e=>(0,h.jsx)(be,{account:e,onUpdate:s},e.id)),!i.length&&(0,h.jsx)("div",{className:"double-space text-center dimmed",children:e.length?"No users match the filter":"No user accounts yet"})]})}function ke({onCreate:e}){const[s,t]=(0,n.useState)(""),[a,i]=(0,n.useState)(""),[c,l]=(0,he.m)(),[r,o]=(0,n.useState)(!1),d=(0,n.useCallback)(e=>t(e.target.value.trim()),[]),m=(0,n.useCallback)(e=>i(e.target.value.trim().replace(/[^\d.]/g,"")),[]),u=(0,n.useCallback)(e=>i(e.currentTarget.dataset.amount),[]),x=(0,n.useCallback)(()=>{o(!0),(0,q.A)("account",{method:"POST",params:{email:s,balance:a}}).then(s=>{e(),notify({type:"success",message:`Account ${s.email} has been created`}),l()}).catch(e=>notify({type:"error",message:"Failed to create account. "+e.message})).finally(()=>o(!1))},[s,a]);return(0,h.jsxs)("div",{children:[(0,h.jsx)(y.$,{block:!0,small:!0,onClick:l,children:"Add new user"}),(0,h.jsxs)(xe.A,{title:"Create new account",dialogOpen:c,confirmTitle:"Create",disabled:r||!s,onConfirm:x,onCancel:l,children:[(0,h.jsxs)("div",{className:"space",children:[(0,h.jsx)("label",{className:"dimmed text-small",children:"User email"}),(0,h.jsx)("input",{value:s,onChange:d})]}),(0,h.jsxs)("div",{className:"micro-space",children:[(0,h.jsx)("label",{className:"dimmed text-small",children:"Start balance"}),(0,h.jsx)("input",{value:a,onChange:m})]}),(0,h.jsx)(je,{onClick:u,className:"text-right"})]})]})}function Ae(){const{userId:e,synced:s}=(0,ne.wV)(),[t,a]=(0,n.useState)(),[i,c]=(0,n.useState)(!1),[l,o]=(0,n.useState)(0),d=(0,n.useCallback)(()=>o(e=>++e),[]);(0,n.useEffect)(()=>{e&&(c(!0),(0,q.A)("account?limit=500").then(s=>a(s.filter(s=>s.id!==e))).catch(e=>notify({type:"error",message:"Failed to retrieve accounts data. "+e?.message})).finally(()=>c(!1)))},[e,l]);const m=(0,h.jsxs)(h.Fragment,{children:["Users",!!t&&(0,h.jsxs)("span",{className:"dimmed text-small",children:["  ",t.length," total"]})]}),u=!s||i;return(0,h.jsx)(r.A,{title:m,action:(0,h.jsx)(ke,{onCreate:d}),children:u?(0,h.jsx)(w.A,{inside:!0}):(0,h.jsx)(Ce,{accounts:t,onUpdate:d})})}function Se({title:e,description:s,children:t}){return(0,h.jsxs)("div",{className:"row space",children:[(0,h.jsxs)("div",{className:"column column-33",children:[(0,h.jsx)("strong",{children:e}),(0,h.jsx)("div",{className:"dimmed text-small",children:s}),(0,h.jsx)("div",{className:"mobile-only micro-space"})]}),(0,h.jsx)("div",{className:"column column-66",children:t})]})}var we=t(83158);function $e({account:e,onUpdate:s,disabled:t}
1){const a=e?.subscription,i=!1===a?.autoRenew,[c,l]=(0,n.useState)(!1),r=(0,n.useCallback)(()=>{l(!0),(0,q.A)(`account/${e.id}/subscription/renewal`,{method:"POST",params:{autoRenew:i}}).then(e=>{s(s=>({...s,subscription:e.subscription})),notify({type:"success",message:"Automatic renewal has been "+(i?"resumed":"cancelled")})}).catch(e=>notify({type:"error",message:"Failed to update renewal. "+e?.message})).finally(()=>l(!1))},[e,i,s]);return(0,h.jsxs)("div",{children:[(0,h.jsx)(oe,{account:e}),(0,h.jsxs)("div",{className:"billing-subscription-actions space",children:[(0,h.jsx)(y.$,{stackable:!0,small:!0,href:`/admin/user/${e?.id}/subscription`,children:a?"Change subscription":"Subscribe user"}),!!a&&(0,h.jsx)(y.$,{stackable:!0,small:!0,outline:!0,disabled:t||c,onClick:r,children:i?"Resume renewal":"Cancel renewal"})]})]})}function qe({settings:e,onUpdate:s}){const[t,i]=(0,n.useState)(!1),{id:c}=(0,a.g)(),l=(0,n.useCallback)((t,n)=>{const{origins:a,subscription:l}={...e,[t]:n};return i(!0),(0,q.A)(`account/${c}`,{method:"POST",params:{origins:a,subscription:l}}).then(()=>{s(e=>({...e,[t]:n})),notify({type:"success",message:"User settings has been updated"})}).catch(e=>notify({type:"error",message:"Failed to save user settings. "+e?.message})).finally(()=>i(!1))},[e,c,s]),{apiKeys:r=[],origins:o=[]}=e;return(0,h.jsxs)("div",{children:[(0,h.jsx)(Se,{title:"Plan",description:"Tariff, limits and renewal.",children:(0,h.jsx)($e,{account:e,onUpdate:s,disabled:t})}),(0,h.jsx)("div",{className:"space"}),(0,h.jsx)("hr",{}),(0,h.jsx)(Se,{title:"Credentials",description:"Keys are issued by the account owner. Origins are accepted for every API key on this account.",children:(0,h.jsxs)("div",{className:"row",children:[(0,h.jsx)("div",{className:"column column-50",children:(0,h.jsx)(ue.A,{caption:(0,h.jsxs)(h.Fragment,{children:["API KEYS · ",r.length]}),tokens:r,shorten:16,placeholder:"(No API keys)"})}),(0,h.jsxs)("div",{className:"column column-50",children:[(0,h.jsx)("div",{className:"mobile-only micro-space"}),(0,h.jsx)(we.A,{caption:(0,h.jsxs)(h.Fragment,{children:["ORIGINS · ",o.length]}),origins:o,onUpdate:l,disabled:t})]})]})})]})}function Fe(){const[e,s]=(0,n.useState)({}),[t,i]=(0,n.useState)(!1),{id:c}=(0,a.g)();(0,n.useEffect)(()=>{if(!c)return null;i(!0),(0,q.A)(`account/${c}`).then(s).catch(e=>notify({type:"error",message:"Failed to retrieve account data. "+e?.message})).finally(()=>i(!1))},[c]);const l=(0,h.jsxs)("span",{className:"dimmed text-small",children:[(0,h.jsxs)("code",{className:"text-small billing-account-ref",children:["account #",(0,j.l)(c,8)]}),!!e.email&&(0,h.jsxs)(h.Fragment,{children:[" · ",e.email]})]});return(0,h.jsx)(r.A,{title:"Account settings",action:l,children:t?(0,h.jsx)(w.A,{inside:!0}):(0,h.jsx)(qe,{settings:e,onUpdate:s})})}function Pe(){const{path:e}=(0,a.W5)();return(0,h.jsx)(c.A,{role:"admin",children:(0,h.jsxs)(i.oR,{children:[(0,h.jsx)(i.qh,{path:`${e}/user/:id/billing-history`,component:B}),(0,h.jsx)(i.qh,{path:`${e}/user/:id/subscription`,component:V}),(0,h.jsx)(i.qh,{path:`${e}/user/:id`,component:Fe}),(0,h.jsx)(i.qh,{path:`${e}/user`,component:Ae}),(0,h.jsx)(i.qh,{path:`${e}/logs`,component:I}),(0,h.jsx)(i.qh,{path:`${e}/`,component:p}),(0,h.jsx)(i.qh,{component:l.A})]})})}}}]);

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.