PageSourceSearch

https://token4u.ai/static/js/async/5627.6095f76de9.js

js token4u.ai collected 2026-10-05 14:01:54 UTC 15,807 bytes, 2 lines download raw bytes

1/*! LICENSE: 5627.6095f76de9.js.LICENSE.txt */
2"use strict";(self.rspackChunknewapi_web=self.rspackChunknewapi_web||[]).push([[5627],{11635(e,t,a){var s=a(63165);let l="page-size";function n(e){let{search:t,navigate:a,pagination:n,globalFilter:r,columnFilters:i=[]}=e,o=n?.pageKey??"page",c=n?.pageSizeKey??"pageSize",d=n?.defaultPage??1,u=n?.defaultPageSize??20,m=r?.key??"filter",h=r?.enabled??!0,x=r?.trim??!0,p=(0,s.useMemo)(()=>{let e=[];for(let a of i){let s=t[a.searchKey],l=a.deserialize??(e=>e);if("string"===a.type){let t=l(s)??"";"string"==typeof t&&""!==t.trim()&&e.push({id:a.columnId,value:t})}else{let t=l(s)??[];Array.isArray(t)&&t.length>0&&e.push({id:a.columnId,value:t})}}return e},[i,t]),[g,f]=(0,s.useState)(p);(0,s.useEffect)(()=>{f(p)},[t]);let y=(0,s.useMemo)(()=>{let e=t[o],a=t[c];return{pageIndex:Math.max(0,("number"==typeof e?e:d)-1),pageSize:"number"==typeof a?a:function(){try{let e=parseInt(localStorage.getItem(l)??"",10);return e>0?e:void 0}catch{return}}()??u}},[t,o,c,d,u]),[v,j]=(0,s.useState)(()=>{if(!h)return;let e=t[m];return"string"==typeof e?e:""}),b=h?e=>{let t="function"==typeof e?e(v??""):e,s=x?t.trim():t;j(s),a({search:e=>({...e,[o]:void 0,[m]:s||void 0})})}:void 0;return{globalFilter:h?v??"":void 0,onGlobalFilterChange:b,columnFilters:g,onColumnFiltersChange:e=>{let t="function"==typeof e?e(g):e;f(t);let s={};for(let e of i){let a=t.find(t=>t.id===e.columnId),l=e.serialize??(e=>e);if("string"===e.type){let t="string"==typeof a?.value?a.value:"";s[e.searchKey]=""!==t.trim()?l(t):void 0}else{let t=Array.isArray(a?.value)?a.value:[];s[e.searchKey]=t.length>0?l(t):void 0}}a({search:e=>({...e,[o]:void 0,...s})})},pagination:y,onPaginationChange:e=>{let t="function"==typeof e?e(y):e,s=t.pageIndex+1,n=t.pageSize;n!==y.pageSize&&function(e){try{localStorage.setItem(l,String(e))}catch{}}(n),a({search:e=>({...e,[o]:s<=d?void 0:s,[c]:n})})},ensurePageInRange:function(e){let s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{resetTo:"first"},l=t[o],n="number"==typeof l?l:d;e>0&&n>e&&a({replace:!0,search:t=>({...t,[o]:"last"===s.resetTo?e:void 0})})}}}a.d(t,{c:()=>n})},32582(e,t,a){a.r(t),a.d(t,{component:()=>A});var s=a(36745),l=a(53022),n=a(21425),r=a(63165);let i=r.createContext(null);function o(e){let{children:t}=e,[a,l]=(0,r.useState)(0),[n,o]=(0,r.useState)(null);return(0,s.jsx)(i,{value:{refreshTrigger:a,triggerRefresh:()=>l(e=>e+1),currentRow:n,setCurrentRow:o},children:t})}var c=a(31298),d=a(99429),u=a(24144),m=a(40245),h=a(50731),x=a(11635),p=a(16594);async function g(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=new URLSearchParams;e.from&&t.set("from",String(e.from)),e.to&&t.set("to",String(e.to)),e.status&&t.set("status",e.status),e.session_id&&t.set("session_id",e.session_id),e.channel_id&&t.set("channel_id",String(e.channel_id)),e.type&&t.set("type",e.type),e.p&&t.set("p",String(e.p)),e.page_size&&t.set("page_size",String(e.page_size));let a=t.toString();return(await p.FH.get(`/api/admin/reconciliation/${a?`?${a}`:""}`)).data}async function f(){let e=await p.FH.get("/api/admin/reconciliation/channels");return e.data.success&&e.data.data?e.data.data:[]}async function y(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=new URLSearchParams;e.from&&t.set("from",String(e.from)),e.to&&t.set("to",String(e.to)),e.status&&"all"!==e.status&&t.set("status",e.status),e.session_id&&t.set("session_id",e.session_id),e.channel_id&&t.set("channel_id",String(e.channel_id)),e.type&&"all"!==e.type&&t.set("type",e.type);let a=t.toString(),s=(await p.FH.get(`/api/admin/reconciliation/export${a?`?${a}`:""}`,{responseType:"blob"})).data,l=URL.createObjectURL(s),n=document.createElement("a");n.href=l,n.download=`reconciliation-${new Date().toISOString().slice(0,10)}.csv`,document.body.appendChild(n),n.click(),document.body.removeChild(n),URL.revokeObjectURL(l)}function v(e){let t=Number.parseFloat(e);return Number.isNaN(t)?"$0.000000":`$${j(t)}`}function j(e){return parseFloat(e.toFixed(9)).toString()}var b=a(36081),N=a(21684),_=a(11687),S=a(60767);function w(e){let{value:t,maxLen:a=14}=e,l=t.length>a?`${t.slice(0,8)}...${t.slice(-6)}`:t,n=async()=>{try{await navigator.clipboard.writeText(t),u.oR.success("Copied")}catch{let e=document.createElement("textarea");e.value=t,document.body.appendChild(e),e.select(),document.execCommand("copy"),document.body.removeChild(e),u.oR.success("Copied")}};return(0,s.jsxs)("span",{className:"inline-flex items-center gap-1 font-mono text-xs",children:[(0,s.jsx)("span",{title:t,children:l}),(0,s.jsx)(N.$,{variant:"ghost",size:"sm",className:"h-4 w-4 p-0 text-muted-foreground hover:text-foreground",onClick:n,"aria-label":"Copy",children:(0,s.jsx)(S.A,{className:"h-3 w-3"})})]})}var C=a(35962),z=a(29648),k=a(24732),K=a(42583),F=a(14404);let I={from:null,to:null,status:"all",session_id:"",channel_id:null,type:"all"};function R(e){let{filters:t,onApply:a,onExportCsv:n,searchLoading:i}=e,{t:o}=(0,l.Bd)(),[d,u]=(0,r.useState)({...I,...t}),{data:m=[]}=(0,c.I)({queryKey:["reconciliation-channels"],queryFn:f,staleTime:6e4}),h=(0,r.useMemo)(()=>[{value:"all",label:o("All")},{value:"settled",label:o("Settled")},{value:"cancelled",label:o("Cancelled")},{value:"verified",label:o("Verified")}],[o]),x=(0,r.useMemo)(()=>[{value:"all",label:o("All")},{value:"call",label:o("Call")},{value:"revenue",label:o("Revenue")},{value:"chain",label:o("Chain")}],[o]),p=(0,r.useCallback)(()=>{a(d)},[d,a]),g=(0,r.useCallback)(()=>{u({...I}),a({...I})},[a]),y=(0,r.useCallback)(e=>{"Enter"===e.key&&p()},[p]);return(0,s.jsxs)("div",{className:"flex flex-wrap items-end gap-3",onKeyDown:y,children:[(0,s.jsxs)("div",{className:"flex flex-col gap-1 min-w-0",children:[(0,s.jsx)("label",{className:"text-xs text-muted-foreground",children:o("From")}),(0,s.jsx)(C.p,{type:"date",className:"h-8 w-36 text-sm",value:d.from?new Date(1e3*d.from).toISOString().slice(0,10):"",onCh
2ange:e=>{let t=e.target.value?new Date(e.target.value):null;u(e=>({...e,from:t?Math.floor(t.getTime()/1e3):null}))}})]}),(0,s.jsxs)("div",{className:"flex flex-col gap-1 min-w-0",children:[(0,s.jsx)("label",{className:"text-xs text-muted-foreground",children:o("To")}),(0,s.jsx)(C.p,{type:"date",className:"h-8 w-36 text-sm",value:d.to?new Date(1e3*d.to).toISOString().slice(0,10):"",onChange:e=>{let t=e.target.value?new Date(e.target.value+"T23:59:59"):null;u(e=>({...e,to:t?Math.floor(t.getTime()/1e3):null}))}})]}),(0,s.jsxs)("div",{className:"flex flex-col gap-1 min-w-0",children:[(0,s.jsx)("label",{className:"text-xs text-muted-foreground",children:o("Status")}),(0,s.jsxs)(z.l6,{value:d.status,onValueChange:e=>u(t=>({...t,status:e??"all"})),children:[(0,s.jsx)(z.bq,{className:"h-8 w-32",children:(0,s.jsx)(z.yv,{})}),(0,s.jsx)(z.gC,{children:(0,s.jsx)(z.s3,{children:h.map(e=>(0,s.jsx)(z.eb,{value:e.value,children:e.label},e.value))})})]})]}),(0,s.jsxs)("div",{className:"flex flex-col gap-1 min-w-0",children:[(0,s.jsx)("label",{className:"text-xs text-muted-foreground",children:o("Session ID")}),(0,s.jsx)(C.p,{className:"h-8 w-40 text-sm font-mono",value:d.session_id,onChange:e=>u(t=>({...t,session_id:e.target.value})),placeholder:o("Session ID")})]}),(0,s.jsxs)("div",{className:"flex flex-col gap-1 min-w-0",children:[(0,s.jsx)("label",{className:"text-xs text-muted-foreground",children:o("Channel")}),(0,s.jsxs)(z.l6,{value:null!==d.channel_id?String(d.channel_id):"all",onValueChange:e=>u(t=>({...t,channel_id:e&&"all"!==e?Number(e):null})),children:[(0,s.jsx)(z.bq,{className:"h-8 w-40",children:(0,s.jsx)(z.yv,{})}),(0,s.jsx)(z.gC,{children:(0,s.jsxs)(z.s3,{children:[(0,s.jsx)(z.eb,{value:"all",children:o("All")}),m.map(e=>(0,s.jsx)(z.eb,{value:String(e.id),children:e.name},e.id))]})})]})]}),(0,s.jsxs)("div",{className:"flex flex-col gap-1 min-w-0",children:[(0,s.jsx)("label",{className:"text-xs text-muted-foreground",children:o("Type")}),(0,s.jsxs)(z.l6,{value:d.type??"all",onValueChange:e=>u(t=>({...t,type:e??"all"})),children:[(0,s.jsx)(z.bq,{className:"h-8 w-28",children:(0,s.jsx)(z.yv,{})}),(0,s.jsx)(z.gC,{children:(0,s.jsx)(z.s3,{children:x.map(e=>(0,s.jsx)(z.eb,{value:e.value,children:e.label},e.value))})})]})]}),(0,s.jsxs)("div",{className:"flex items-end gap-2",children:[(0,s.jsxs)(N.$,{variant:"default",size:"sm",onClick:p,disabled:i,className:"h-8",children:[(0,s.jsx)(k.A,{className:"mr-1 h-4 w-4"}),o("Search")]}),(0,s.jsxs)(N.$,{variant:"outline",size:"sm",onClick:g,disabled:i,className:"h-8",children:[(0,s.jsx)(K.A,{className:"mr-1 h-4 w-4"}),o("Reset")]}),(0,s.jsxs)(N.$,{variant:"outline",size:"sm",onClick:n,className:"h-8",children:[(0,s.jsx)(F.A,{className:"mr-1 h-4 w-4"}),o("Export CSV")]})]})]})}let T=(0,d.GY)("/_authenticated/reconciliation/");function $(){let{t:e}=(0,l.Bd)(),t=[{accessorKey:"date",header:"Time",cell:e=>{let{row:t}=e;return(0,_.fk)(t.original.date,"seconds")},size:160},{accessorKey:"type",header:"Type",cell:e=>{let{row:t}=e,a=t.original.type;return(0,s.jsx)(b.Wh,{variant:"revenue"===a?"success":"call"===a?"neutral":"warning",children:a})},size:90},{accessorKey:"session_id",header:"Session ID",cell:e=>{let{row:t}=e,a=t.original.session_id;return a?(0,s.jsx)(w,{value:a}):(0,s.jsx)("span",{className:"text-muted-foreground",children:"-"})},size:140},{accessorKey:"model_name",header:"Model",cell:e=>{let{row:t}=e,a=t.original.model_name;return a?(0,s.jsx)("span",{className:"text-sm",children:a}):(0,s.jsx)("span",{className:"text-muted-foreground",children:"-"})},size:130},{accessorKey:"channel_name",header:"Channel",cell:e=>{let{row:t}=e,a=t.original.channel_name;return a?(0,s.jsx)("span",{className:"text-sm",children:a}):(0,s.jsx)("span",{className:"text-muted-foreground",children:"-"})},size:100},{accessorKey:"prompt_tokens",header:"In",cell:e=>{let{row:t}=e,a=t.original.prompt_tokens;return a?a.toLocaleString():(0,s.jsx)("span",{className:"text-muted-foreground",children:"-"})},size:70},{accessorKey:"completion_tokens",header:"Out",cell:e=>{let{row:t}=e,a=t.original.completion_tokens;
2return a?a.toLocaleString():(0,s.jsx)("span",{className:"text-muted-foreground",children:"-"})},size:70},{accessorKey:"cache_tokens",header:"Cache",cell:e=>{let{row:t}=e,a=t.original.cache_tokens;return a?a.toLocaleString():(0,s.jsx)("span",{className:"text-muted-foreground",children:"-"})},size:70},{accessorKey:"tokens",header:"Tokens",cell:e=>{let{row:t}=e,a=t.original.tokens;return a?a.toLocaleString():(0,s.jsx)("span",{className:"text-muted-foreground",children:"-"})},size:80},{accessorKey:"revenue_usd",header:"Revenue",cell:e=>{let{row:t}=e;return(0,s.jsx)("span",{className:"font-mono text-sm tabular-nums",children:v(t.original.revenue_usd)})},size:100},{accessorKey:"cost_usd",header:"Cost",cell:e=>{let{row:t}=e;return(0,s.jsx)("span",{className:"font-mono text-sm tabular-nums",children:v(t.original.cost_usd)})},size:100},{accessorKey:"profit_usd",header:"Profit",cell:e=>{let t,{row:a}=e,l=Number.isNaN(t=Number.parseFloat(a.original.profit_usd))?"$0.000000":`${t>=0?"":"-"}$${j(Math.abs(t))}`,n=l.startsWith("-");return(0,s.jsx)("span",{className:`font-mono text-sm tabular-nums ${n?"text-red-600":"text-green-600"}`,children:l})},size:100},{accessorKey:"status",header:"Status",cell:e=>{let{row:t}=e,a=t.original.status;return a?(0,s.jsx)(b.Wh,{variant:function(e){switch(e){case"settled":case"verified":return"success";case"cancelled":case"failed":return"danger";case"pending":return"warning";default:return"neutral"}}(a),children:a}):(0,s.jsx)("span",{className:"text-muted-foreground",children:"-"})},size:90},{accessorKey:"tx_hash",header:"Tx Hash",cell:e=>{let{row:t}=e,a=t.original.tx_hash;return a?(0,s.jsx)(w,{value:a,maxLen:16}):(0,s.jsx)("span",{className:"text-muted-foreground",children:"-"})},size:130},{accessorKey:"billing_source",header:"Billing Source",cell:e=>{let{row:t}=e,a=t.original.billing_source;return a?(0,s.jsx)(b.Wh,{variant:"neutral",children:a}):(0,s.jsx)("span",{className:"text-muted-foreground",children:"-"})},size:120},{accessorKey:"facilitator",header:"Facilitator",cell:e=>{let{row:t}=e,a=t.original.facilitator;return a?(0,s.jsx)(b.Wh,{variant:"cdp"===a?"success":"payai"===a?"warning":"neutral",children:a}):(0,s.jsx)("span",{className:"text-muted-foreground",children:"-"})},size:100}],{refreshTrigger:a}=(()=>{let e=r.useContext(i);if(!e)throw Error("useReconciliation must be used within <ReconciliationProvider>");return e})(),n=(0,h.Ub)("(max-width: 640px)"),{pagination:o,onPaginationChange:d,ensurePageInRange:p}=(0,x.c)({search:T.useSearch(),navigate:T.useNavigate(),pagination:{defaultPage:1,defaultPageSize:n?10:20},globalFilter:{enabled:!1,key:"filter"}}),[f,N]=(0,r.useState)({from:null,to:null,status:"all",session_id:"",channel_id:null,type:"all"}),[S,C]=(0,r.useState)({total_revenue:"0",total_cost:"0",total_profit:"0"}),{data:z,isLoading:k,isFetching:K}=(0,c.I)({queryKey:["reconciliation",o.pageIndex+1,o.pageSize,f,a],queryFn:async()=>{let t={p:o.pageIndex+1,page_size:o.pageSize};f.from&&(t.from=f.from),f.to&&(t.to=f.to),f.status&&"all"!==f.status&&(t.status=f.status),f.session_id&&(t.session_id=f.session_id),f.channel_id&&(t.channel_id=f.channel_id),f.type&&"all"!==f.type&&(t.type=f.type);let a=await g(t);if(!a.success)return u.oR.error(a.message||e("Failed to load reconciliation data.")),{items:[],total:0,summary:{total_revenue:"0",total_cost:"0",total_profit:"0"}};let s=a.data?.data||[],l=a.data?.total||0,n=a.data?.summary||{total_revenue:"0",total_cost:"0",total_profit:"0"};return C(n),{items:s,total:l,summary:n}},placeholderData:e=>e}),F=z?.items||[],{table:I}=(0,m.uI)({data:F,columns:t,enableRowSelection:!1,pagination:o,onPaginationChange:d,manualPagination:!0,manualFiltering:!0,totalCount:z?.total||0,ensurePageInRange:p}),$=(0,r.useCallback)(e=>{N(e),d({pageIndex:0,pageSize:o.pageSize})},[d,o.pageSize]),A=(0,r.useCallback)(async()=>{try{await y(f),u.oR.success(e("CSV exported successfully."))}catch{u.oR.error(e("Failed to export CSV."))}},[f,e]),L=(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-6 border-t px-4 py-3 text-sm",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsxs)("span",{className:"text-muted-foreground",children:[e("Total Revenue"),":"]}),(0,s.jsx)("span",{className:"font-mono font-semibold tabular-nums text-green-600",children:v(S.total_revenue)})]}),(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsxs)("span",{className:"text-muted-foreground",children:[e("Total Cost"),":"]}),(0,s.jsx)("span",{className:"font-mono font-semibold tabular-nums text-red-600",children:v(S.total_cost)})]}),(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsxs)("span",{className:"text-muted-foreground",children:[e("Total Profit"),":"]}),(0,s.jsx)("span",{className:`font-mono font-semibold tabular-nums ${Number.parseFloat(S.total_profit)>=0?"text-green-600":"text-red-600"}`,children:v(S.total_profit)})]})]});return(0,s.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,s.jsx)(R,{filters:f,onApply:$,onExportCsv:A,searchLoading:K}),(0,s.jsx)(m.cx,{table:I,columns:t,isLoading:k,isFetching:K,emptyTitle:e("No Reconciliation Data Found"),empty
2Description:e("No financial reconciliation data matches your filters. Try adjusting the date range or filters."),skeletonKeyPrefix:"reconciliation-skeleton",applyHeaderSize:!0,afterTable:L})]})}let A=function(){let{t:e}=(0,l.Bd)();return(0,s.jsx)(o,{children:(0,s.jsxs)(n.Ni,{fixedContent:!0,children:[(0,s.jsx)(n.Ni.Title,{children:e("Financial Reconciliation")}),(0,s.jsx)(n.Ni.Content,{children:(0,s.jsx)($,{})})]})})}},14404(e,t,a){let s=(0,a(29105).A)("download",[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]]);a.d(t,{},{A:s})}}]);

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.