PageSourceSearch

https://smritea.ai/assets/UsageBillingPage-C_MO31sY.js

js smritea.ai collected 2026-10-05 15:07:12 UTC 17,081 bytes, 6 lines download raw bytes

1import{c as G,e as F,o as p,b1 as z,b2 as K,r as h,b3 as Q,j as e,B as w,L as W,a0 as X,b4 as Y}from"./index-OkXy-d5Y.js";import{B as v}from"./badge-D70DEMXH.js";import{C as b,b as C,a as k,c as A}from"./card-BOYNs0rn.js";import{P as B}from"./progress-bFXLrkxf.js";import{S as P}from"./skeleton-CTnX7jIE.js";import{T as M,a as D,b as g,c as u,d as E,e as m}from"./table-B-pszi_P.js";import{T as Z,a as J,b as y,c as S}from"./tabs-DOaoAkMM.js";import{U as ee}from"./UsageBar-Bpipzlxn.js";import{f as T}from"./date-utils-BapGj4Cw.js";import{f as U}from"./billing-format-CjDMm46p.js";import{a as se}from"./orgsSlice-mdJJI7Vn.js";import{s as te,b as ae,c as re,d as ie,e as ce,a as ne,f as le,g as de,h as oe,i as me,j as xe}from"./usageSlice-CgepbOY5.js";import{a as ue}from"./subscriptionsSlice-CAeRwGnr.js";/**
2 * @license lucide-react v0.487.0 - ISC
3 *
4 * This source code is licensed under the ISC license.
5 * See the LICENSE file in the root directory of this source tree.
6 */const he=[["path",{d:"M5 12h14",key:"1ays0h"}]],je=G("minus",he);function pe(a){return a===!0?e.jsx(X,{className:"h-4 w-4 text-green-600 mx-auto"}):a===!1?e.jsx(Y,{className:"h-4 w-4 text-muted-foreground mx-auto"}):a==null||a===0?e.jsx(je,{className:"h-4 w-4 text-muted-foreground mx-auto"}):typeof a=="number"?a.toLocaleString():String(a)}function ge({currentPlanKey:a}={}){const c=F(),l=p(z),r=p(K);if(h.useEffect(()=>{c(Q())},[c]),r)return e.jsx(P,{className:"h-96 rounded-lg"});if(l.length===0)return e.jsx(b,{children:e.jsx(C,{className:"py-8 text-center text-muted-foreground text-sm",children:"No plans available for comparison."})});const n=[],i=(s,t,d)=>{const f={};l.forEach(N=>{f[N.id||""]=pe(d(N))}),n.push({label:s,category:t,values:f})};i("Monthly Price","Pricing",s=>{var t,d;return(t=s.pricing)!=null&&t.monthlyPricePerMonth?`${U(s.pricing.monthlyPricePerMonth,((d=s.pricing)==null?void 0:d.currency)??"USD")}/mo`:"Free"}),i("Annual Price","Pricing",s=>{var t,d;return(t=s.pricing)!=null&&t.yearlyPricePerMonth?`${U(s.pricing.yearlyPricePerMonth,((d=s.pricing)==null?void 0:d.currency)??"USD")}/mo`:"-"}),i("Max Apps","Limits",s=>{var t;return(t=s.quotas)==null?void 0:t.maxApps}),i("Max API Keys","Limits",s=>{var t;return(t=s.quotas)==null?void 0:t.maxApiKeys}),i("Max Teams","Limits",s=>{var t;return(t=s.quotas)==null?void 0:t.maxTeams}),i("Max Members","Limits",s=>{var t;return(t=s.quotas)==null?void 0:t.maxMembers}),i("Memory Credits","Quotas",s=>{var t;return(t=s.quotas)==null?void 0:t.memoryCredits}),i("Search Credits","Quotas",s=>{var t;return(t=s.quotas)==null?void 0:t.searchCredits}),i("Memory Create","Credit Costs",s=>{var t;return(t=s.creditCosts)!=null&&t.memoryCreate?`${s.creditCosts.memoryCreate} credits`:"-"}),i("Quick Search","Credit Costs",s=>{var t;return(t=s.creditCosts)!=null&&t.quickSearch?`${s.creditCosts.quickSearch} credits`:"-"}),i("Deep Search","Credit Costs",s=>{var t;return(t=s.creditCosts)!=null&&t.deepSearch?`${s.creditCosts.deepSearch} credits`:"-"}),i("Context-Aware Search","Credit Costs",s=>{var t;return(t=s.creditCosts)!=null&&t.contextAwareSearch?`${s.creditCosts.contextAwareSearch} credits`:"-"}),i("Graph Search","Features",s=>{var t;return(t=s.features)==null?void 0:t.graphSearch}),i("Custom Extraction Config","Features",s=>{var t;return(t=s.features)==null?void 0:t.customExtractionConfig}),i("Advanced Rerankers","Features",s=>{var t;return(t=s.features)==null?void 0:t.advancedRerankers}),i("Priority Support","Features",s=>{var t;return(t=s.features)==null?void 0:t.prioritySupport});const x=[...new Set(n.map(s=>s.category))];return e.jsxs(b,{children:[e.jsx(k,{children:e.jsx(A,{className:"text-base",children:"Plan Comparison"})}),e.jsxs(C,{className:"overflow-auto",children:[e.jsx("div",{className:"space-y-4 md:hidden",children:l.map(s=>e.jsxs("div",{className:"rounded-lg border p-4",children:[e.jsxs("div",{className:"mb-3 flex items-center gap-2",children:[e.jsx("h3",{className:"text-sm font-semibold",children:s.name}),s.slug===a&&e.jsx(v,{variant:"secondary",className:"text-xs",children:"Current"})]}),e.jsx("div",{className:"space-y-3",children:x.map(t=>e.jsxs(h.Fragment,{children:[e.jsx("div",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:t}),n.filter(d=>d.category===t).map(d=>e.jsxs("div",{className:"flex justify-between gap-3 py-1 text-sm",children:[e.jsx("span",{className:"text-muted-foreground",children:d.label}),e.jsx("span",{className:"text-right",children:d.values[s.id||""]}
6)]},`${s.id}-${d.label}`))]},`mobile-${s.id}-${t}`))})]},s.id))}),e.jsxs(M,{className:"hidden md:table",children:[e.jsx(D,{children:e.jsxs(g,{children:[e.jsx(u,{children:"Feature"}),l.map(s=>e.jsx(u,{className:"text-center",children:e.jsxs("div",{className:"flex flex-col items-center gap-1",children:[e.jsx("span",{children:s.name}),s.slug===a&&e.jsx(v,{variant:"secondary",className:"text-xs",children:"Current"})]})},s.id))]})}),e.jsx(E,{children:x.map(s=>e.jsxs(h.Fragment,{children:[e.jsx(g,{children:e.jsx(m,{colSpan:l.length+1,className:"bg-muted/50 text-xs text-muted-foreground py-2",children:s})}),n.filter(t=>t.category===s).map(t=>e.jsxs(g,{children:[e.jsx(m,{className:"text-sm",children:t.label}),l.map(d=>e.jsx(m,{className:"text-center text-sm",children:t.values[d.id||""]},d.id))]},t.label))]},`desktop-${s}`))})]}),e.jsx("div",{className:"mt-4",children:e.jsx(w,{asChild:!0,variant:"outline",children:e.jsx(W,{to:"/dashboard/billing/plans",children:"View plans"})})})]})]})}const $=20;function fe(a){return a>90?"text-destructive":a>70?"text-yellow-600":"text-muted-foreground"}function Ne(a){return a?T(`${a}-01T00:00:00`,"monthYearShort",{fallback:a}):""}function be(a){return T(a,"medium",{fallback:a??""})}function Ce(){return new Date(Date.now()-1440*60*1e3).toISOString().slice(0,16)}function ve(){return new Date().toISOString().slice(0,16)}function ye({entry:a}){const c=a.granted??0,l=a.used??0,r=a.remaining??0,n=c>0?l/c*100:0,i=(a.creditType??"unknown").replace(/_/g," ").replace(/\b\w/g,x=>x.toUpperCase());return e.jsxs(b,{className:"flex-1 w-full",children:[e.jsx(k,{className:"pb-2",children:e.jsxs(A,{className:"text-sm font-medium",children:[i," Credits"]})}),e.jsxs(C,{className:"space-y-3",children:[e.jsxs("div",{className:"grid grid-cols-1 gap-2 text-center sm:grid-cols-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-semibold",children:c.toLocaleString()}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Granted"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-semibold",children:l.toLocaleString()}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Used"})]}),e.jsxs("div",{children:[e.jsx("p",{className:`text-2xl font-semibold ${fe(n)}`,children:r.toLocaleString()}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Remaining"})]})]}),e.jsx(B,{value:Math.min(n,100),className:"h-2"}),e.jsxs("div",{className:"flex items-center justify-between text-xs text-muted-foreground",children:[e.jsx("span",{children:Ne(a.period)}),a.expiresAt&&e.jsxs("span",{children:["Expires ",be(a.expiresAt)]})]})]})]})}function Se({balances:a,currentUsage:c,loading:l}){return l?e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsx(P,{className:"h-48 rounded-lg"}),e.jsx(P,{className:"h-48 rounded-lg"})]}):a.length>0?e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:a.map(r=>e.jsx(ye,{entry:r},`${r.creditType}-${r.period}`))}):c.length>0?e.jsxs(b,{children:[e.jsx(k,{children:e.jsx(A,{className:"text-base",children:"Current Usage"})}),e.jsx(C,{className:"space-y-4",children:c.map(r=>{const n=r.type??"";return e.jsx(ee,{label:n.charAt(0).toUpperCase()+n.slice(1),used:r.used??0,granted:r.granted??0,percentage:r.percentage??0},n)})})]}):e.jsx("p",{className:"text-sm text-muted-foreground text-center py-8",children:"No credit data available."})}function we({entries:a,total:c,limit:l,offset:r,onPageChange:n}){const i=Math.max(1,Math.ceil(c/l)),x=Math.floor(r/l)+1;return a.length===0&&r===0?e.jsx("p",{className:"text-sm text-muted-foreground text-center py-8",children:"No activity entries yet."}):e.jsx(b,{children:e.jsxs(C,{className:"pt-6",children:[e.jsx("ul",{className:"space-y-3 md:hidden",children:a.map(s=>{const t=s.amount??0;return e.jsxs("li",{className:"rounded-lg border p-4 space-y-3",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"Date"}),e.jsx("p",{className:"text-sm font-medium break-words",children:T(s.createdAt,"mediumWithTime",{fallback:"—"})})]}),e.jsx(v,{variant:"outline",children:s.creditType??"-"})]}),e.jsxs("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"Type"}),e.jsx("p",{className:"text-sm font-medium",children:s.creditType??"-"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"Amount"}),e.jsxs("p",{className:t>=0?"text-sm font-medium text-green-600":"text-sm font-medium text-destructive",children:[t>
6=0?"+":"",t.toLocaleString()]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"Balance"}),e.jsx("p",{className:"text-sm font-medium",children:(s.balanceAfter??0).toLocaleString()})]})]})]},s.id)})}),e.jsx("div",{className:"hidden overflow-x-auto md:block",children:e.jsxs(M,{className:"hidden md:table",children:[e.jsx(D,{children:e.jsxs(g,{children:[e.jsx(u,{children:"Date"}),e.jsx(u,{children:"Type"}),e.jsx(u,{children:"Amount"}),e.jsx(u,{children:"Balance"}),e.jsx(u,{children:"Source"}),e.jsx(u,{children:"Reason"})]})}),e.jsx(E,{children:a.map(s=>{const t=s.amount??0;return e.jsxs(g,{children:[e.jsx(m,{className:"text-sm text-muted-foreground whitespace-nowrap",children:T(s.createdAt,"mediumWithTime",{fallback:"—"})}),e.jsx(m,{children:e.jsx(v,{variant:"outline",children:s.creditType??"-"})}),e.jsxs(m,{className:t>=0?"text-green-600 font-medium":"text-destructive font-medium",children:[t>=0?"+":"",t.toLocaleString()]}),e.jsx(m,{className:"text-sm",children:(s.balanceAfter??0).toLocaleString()}),e.jsx(m,{children:e.jsx(v,{variant:"secondary",children:s.source??"-"})}),e.jsx(m,{className:"text-sm max-w-[200px] truncate",children:s.reason??"-"})]},s.id)})})]})}),c>l&&e.jsxs("div",{className:"flex items-center justify-between pt-4 border-t mt-4",children:[e.jsx(w,{variant:"outline",size:"sm",disabled:r===0,onClick:()=>n(Math.max(0,r-l)),children:"Previous"}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:["Page ",x," of ",i]}),e.jsx(w,{variant:"outline",size:"sm",disabled:r+l>=c,onClick:()=>n(r+l),children:"Next"})]})]})})}function Te({entries:a,orgId:c,onLoad:l}){const[r,n]=h.useState(Ce),[i,x]=h.useState(ve),[s,t]=h.useState(!1),d=h.useCallback(()=>{if(!c||!r||!i)return;const o=new Date(r).toISOString(),j=new Date(i).toISOString();l(o,j),t(!0)},[c,r,i,l]),f=a.reduce((o,j)=>o+(j.creditsConsumed??0),0),N=a.reduce((o,j)=>o+(j.count??0),0);return e.jsx(b,{children:e.jsxs(C,{className:"pt-6 space-y-4",children:[e.jsxs("div",{className:"flex flex-wrap items-end gap-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-xs text-muted-foreground",htmlFor:"analytics-from",children:"From"}),e.jsx("input",{id:"analytics-from",type:"datetime-local",className:"w-full rounded border px-3 py-1.5 text-sm sm:w-auto",value:r,onChange:o=>n(o.target.value)})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-xs text-muted-foreground",htmlFor:"analytics-to",children:"To"}),e.jsx("input",{id:"analytics-to",type:"datetime-local",className:"w-full rounded border px-3 py-1.5 text-sm sm:w-auto",value:i,onChange:o=>x(o.target.value)})]}),e.jsx(w,{size:"sm",onClick:d,children:"Load"})]}),s?a.length===0?e.jsx("p",{className:"text-sm text-muted-foreground text-center py-8",children:"No usage data found for the selected range."}):e.jsxs(e.Fragment,{children:[e.jsxs("ul",{className:"space-y-3 md:hidden",children:[a.map((o,j)=>e.jsxs("li",{className:"rounded-lg border p-4 space-y-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"Hour"}),e.jsx("p",{className:"text-sm font-medium break-words",children:o.periodHour??"-"})]}),e.jsxs("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"Operation"}),e.jsx("p",{className:"text-sm font-medium",children:o.operationType??"-"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"Count"}),e.jsx("p",{className:"text-sm font-medium",children:(o.count??0).toLocaleString()})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"Credits"}),e.jsx("p",{className:"text-sm font-medium",children:(o.creditsConsumed??0).toLocaleString()})]})]})]},j)),e.jsxs("li",{className:"rounded-lg border border-t-2 p-4 space-y-2 font-medium",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"Total Count"}
6),e.jsx("p",{className:"text-sm",children:N.toLocaleString()})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"Total Credits"}),e.jsx("p",{className:"text-sm",children:f.toLocaleString()})]})]})]}),e.jsx("div",{className:"overflow-x-auto",children:e.jsxs(M,{className:"hidden md:table",children:[e.jsx(D,{children:e.jsxs(g,{children:[e.jsx(u,{children:"Hour"}),e.jsx(u,{children:"Operation"}),e.jsx(u,{children:"Subtype"}),e.jsx(u,{className:"text-right",children:"Count"}),e.jsx(u,{className:"text-right",children:"Credits"})]})}),e.jsxs(E,{children:[a.map((o,j)=>e.jsxs(g,{children:[e.jsx(m,{className:"text-sm text-muted-foreground whitespace-nowrap",children:o.periodHour??"-"}),e.jsx(m,{className:"text-sm",children:o.operationType??"-"}),e.jsx(m,{className:"text-sm",children:o.operationSubtype??"-"}),e.jsx(m,{className:"text-sm text-right",children:(o.count??0).toLocaleString()}),e.jsx(m,{className:"text-sm text-right",children:(o.creditsConsumed??0).toLocaleString()})]},j)),e.jsxs(g,{className:"border-t-2 font-medium",children:[e.jsx(m,{colSpan:3,className:"text-sm",children:"Total"}),e.jsx(m,{className:"text-sm text-right",children:N.toLocaleString()}),e.jsx(m,{className:"text-sm text-right",children:f.toLocaleString()})]})]})]})})]}):e.jsx("p",{className:"text-sm text-muted-foreground text-center py-8",children:"Select a date range and click Load to view hourly analytics."})]})})}function Le({operations:a}){return a.length===0?e.jsx("p",{className:"text-sm text-muted-foreground text-center py-8",children:"No rate limit data available."}):e.jsx(b,{children:e.jsx(C,{className:"pt-6 space-y-6",children:a.map(c=>{const l=c.operation??"";return e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium mb-2",children:l.replace(/_/g," ").replace(/\b\w/g,r=>r.toUpperCase())}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-3",children:(c.windows??[]).map(r=>{const n=r.window??"",i=r.limit??0,x=r.current??0;return e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-between text-xs text-muted-foreground",children:[e.jsx("span",{children:n.replace(/_/g," ")}),e.jsxs("span",{children:[x," / ",i]})]}),e.jsx(B,{value:i>0?x/i*100:0,className:"h-1.5"})]},n)})})]},l)})})})}function Pe(){const a=F(),c=p(se),l=p(te),r=p(ae),n=p(re),i=p(ie),x=p(ce),s=p(ne),t=p(ue),[d,f]=h.useState(0);h.useEffect(()=>{c&&(a(le(c)),a(de(c)),a(oe(c)))},[a,c]),h.useEffect(()=>{c&&a(me({orgId:c,limit:$,offset:d}))},[a,c,d]);const N=h.useCallback(L=>{f(L)},[]),o=h.useCallback((L,_)=>{c&&a(xe({orgId:c,from:L,to:_}))},[a,c]),j=(r==null?void 0:r.balances)??[],R=(l==null?void 0:l.usages)??[],H=(n==null?void 0:n.entries)??[],I=(n==null?void 0:n.total)??0,O=(n==null?void 0:n.limit)??$,q=(i==null?void 0:i.entries)??[],V=(x==null?void 0:x.operations)??[];return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-semibold",children:"Usage & Billing"}),e.jsx("p",{className:"text-muted-foreground",children:"Monitor your credit consumption, activity, and rate limits"})]}),e.jsxs(Z,{defaultValue:"credits",children:[e.jsxs(J,{children:[e.jsx(y,{value:"credits",children:"Credits"}),e.jsx(y,{value:"activity",children:"Activity"}),e.jsx(y,{value:"analytics",children:"Analytics"}),e.jsx(y,{value:"rate-limits",children:"Rate Limits"})]}),e.jsx(S,{value:"credits",children:e.jsx(Se,{balances:j,currentUsage:R,loading:s})}),e.jsx(S,{value:"activity",children:e.jsx(we,{entries:H,total:I,limit:O,offset:d,onPageChange:N})}),e.jsx(S,{value:"analytics",children:e.jsx(Te,{entries:q,orgId:c??"",onLoad:o})}),e.jsx(S,{value:"rate-limits",children:e.jsx(Le,{operations:V})})]}),e.jsx(ge,{currentPlanKey:t==null?void 0:t.planKey})]})}function qe(){return e.jsx(Pe,{})}export{qe as UsageBillingPage};

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.