PageSourceSearch

https://adpilot-489907.web.app/assets/index-D4PTKzH5.js

js adpilot-489907.web.app collected 2026-10-03 12:15:51 UTC 43,209 bytes, 2 lines download raw bytes

1import{r as n,a as y,j as e}from"./index-tNhE6V5Q.js";const se=["L0 Strategic","L1 Intelligence","L2 Creative","L3 Execution","L4 Learning","Unknown"],ae={"L0 Strategic":"border-purple-400 bg-purple-50","L1 Intelligence":"border-blue-400 bg-blue-50","L2 Creative":"border-yellow-400 bg-yellow-50","L3 Execution":"border-green-400 bg-green-50","L4 Learning":"border-orange-400 bg-orange-50",Unknown:"border-gray-300 bg-gray-50"},re={heavy:"bg-red-100 text-red-700",standard:"bg-blue-100 text-blue-700",fast:"bg-green-100 text-green-700"};function ne(){const[i,b]=n.useState([]),[m,I]=n.useState([]),[S,D]=n.useState(null),[T,O]=n.useState(!0),[R,f]=n.useState(""),[_,N]=n.useState(""),[c,C]=n.useState("all"),[k,F]=n.useState({}),[g,$]=n.useState(new Set),[a,w]=n.useState(""),[E,P]=n.useState(""),[L,s]=n.useState(null),o=n.useCallback(async()=>{try{const[r,p,j]=await Promise.all([y.get("/v1/llm/functions"),y.get("/v1/llm/models"),y.get("/v1/llm/stats")]);b(r.functions),I(p.models),D(j)}catch(r){f(r instanceof Error?r.message:"Failed to fetch data")}finally{O(!1)}},[]);n.useEffect(()=>{o()},[o]);const d=async(r,p,j)=>{s(r);try{const x={};x[p==="primary"?"primary_model_id":"backup_model_id"]=j||null,await y.put(`/v1/llm/functions/${r}/assign`,x),await o()}catch(x){f(x instanceof Error?x.message:"Failed to assign model")}finally{s(null)}},M=async()=>{if(g.size!==0){if(!a&&!E){f("Select at least one model for bulk assignment");return}if(a&&E&&a===E){f("Primary and backup cannot be the same");return}s("bulk");try{const r={function_ids:Array.from(g)};a&&(r.primary_model_id=a),E&&(r.backup_model_id=E),await y.put("/v1/llm/functions/bulk-assign",r),$(new Set),w(""),P(""),await o()}catch(r){f(r instanceof Error?r.message:"Failed to bulk assign")}finally{s(null)}}},B=n.useMemo(()=>i.filter(r=>{if(c!=="all"&&r.function_type!==c)return!1;if(_){const p=_.toLowerCase();return r.id.toLowerCase().includes(p)||r.agent_id.toLowerCase().includes(p)||(r.description||"").toLowerCase().includes(p)}return!0}),[i,_,c]),V=n.useMemo(()=>{const r={};for(const p of B){const j=p.layer||"Unknown";r[j]||(r[j]=[]),r[j].push(p)}return r},[B]),K=i.filter(r=>!r.primary_model_id).length,q=r=>{F(p=>({...p,[r]:!p[r]}))},Y=r=>{$(p=>{const j=new Set(p);return j.has(r)?j.delete(r):j.add(r),j})},H=r=>{const p=V[r]||[],j=p.every(x=>g.has(x.id));$(x=>{const v=new Set(x);for(const Q of p)j?v.delete(Q.id):v.add(Q.id);return v})};return T?e.jsx("div",{className:"text-center py-12 text-gray-400",children:"Loading functions..."}):e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[e.jsx("input",{type:"text",value:_,onChange:r=>N(r.target.value),placeholder:"Search functions...",className:"px-3 py-1.5 border border-gray-300 rounded text-sm focus:outline-none focus:ring-1 focus:ring-blue-500 w-64"}),e.jsxs("select",{value:c,onChange:r=>C(r.target.value),className:"px-3 py-1.5 border border-gray-300 rounded text-sm focus:outline-none focus:ring-1 focus:ring-blue-500",children:[e.jsx("option",{value:"all",children:"All types"}),e.jsx("option",{value:"heavy",children:"Heavy"}),e.jsx("option",{value:"standard",children:"Standard"}),e.jsx("option",{value:"fast",children:"Fast"})]}),e.jsxs("span",{className:"text-xs text-gray-400",children:[B.length," of ",i.length," functions"]}),K>0&&e.jsxs("span",{className:"text-xs text-yellow-600 bg-yellow-50 px-2 py-0.5 rounded",children:[K," unassigned"]})]}),R&&e.jsx("div",{className:"bg-red-50 text-red-600 text-sm px-3 py-2 rounded",children:R}),g.size>0&&e.jsxs("div",{className:"bg-blue-50 border border-blue-200 rounded-lg p-3 flex items-center gap-3 flex-wrap",children:[e.jsxs("span",{className:"text-sm font-medium text-blue-700",children:[g.size," selected"]}),e.jsxs("select",{value:a,onChange:r=>w(r.target.value),className:"px-2 py-1 border border-gray-300 rounded text-xs focus:outline-none focus:ring-1 focus:ring-blue-500",children:[e.jsx("option",{value:"",children:"Primary model..."}),m.map(r=>e.jsxs("option",{value:r.id,children:[r.display_name," (",r.provider_display_name,")"]},r.id))]}),e.jsxs("select",{value:E,onChange:r=>P(r.target.value),className:"px-2 py-1 border border-gray-300 rounded text-xs focus:outline-none focus:ring-1 focus:ring-blue-500",children:[e.jsx("option",{value:"",children:"Backup model..."}),m.map(r=>
1e.jsxs("option",{value:r.id,children:[r.display_name," (",r.provider_display_name,")"]},r.id))]}),e.jsx("button",{onClick:M,disabled:L==="bulk",className:"px-3 py-1 text-xs font-medium bg-blue-600 text-white rounded hover:bg-blue-700 disabled:opacity-50",children:L==="bulk"?"Assigning...":"Bulk Assign"}),e.jsx("button",{onClick:()=>$(new Set),className:"px-3 py-1 text-xs font-medium text-gray-600 hover:text-gray-800",children:"Clear"})]}),se.map(r=>{const p=V[r];if(!p||p.length===0)return null;const j=k[r];return e.jsxs("div",{className:`rounded-lg border-l-4 ${ae[r]}`,children:[e.jsxs("button",{onClick:()=>q(r),className:"w-full flex items-center justify-between px-4 py-2.5 text-left",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm font-semibold text-gray-800",children:r}),e.jsx("span",{className:"text-xs text-gray-400 bg-white px-1.5 py-0.5 rounded",children:p.length})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:x=>{x.stopPropagation(),H(r)},className:"text-xs text-blue-600 hover:text-blue-800",children:p.every(x=>g.has(x.id))?"Deselect all":"Select all"}),e.jsx("span",{className:"text-gray-400 text-xs",children:j?"+":"-"})]})]}),!j&&e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-xs",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"text-left text-gray-500 border-t border-gray-200",children:[e.jsx("th",{className:"px-4 py-1.5 w-8"}),e.jsx("th",{className:"px-2 py-1.5",children:"Function"}),e.jsx("th",{className:"px-2 py-1.5 hidden lg:table-cell",children:"Description"}),e.jsx("th",{className:"px-2 py-1.5",children:"Type"}),e.jsx("th",{className:"px-2 py-1.5",children:"Primary Model"}),e.jsx("th",{className:"px-2 py-1.5",children:"Backup Model"}),e.jsx("th",{className:"px-2 py-1.5 text-right",children:"Status"})]})}),e.jsx("tbody",{children:p.map(x=>e.jsxs("tr",{className:`border-t border-gray-100 hover:bg-white/60 ${L===x.id?"opacity-50":""}`,children:[e.jsx("td",{className:"px-4 py-1.5",children:e.jsx("input",{type:"checkbox",checked:g.has(x.id),onChange:()=>Y(x.id),className:"rounded border-gray-300"})}),e.jsx("td",{className:"px-2 py-1.5 font-mono text-gray-800 whitespace-nowrap",children:x.id}),e.jsx("td",{className:"px-2 py-1.5 text-gray-500 hidden lg:table-cell max-w-[240px] truncate",children:x.description||"-"}),e.jsx("td",{className:"px-2 py-1.5",children:e.jsx("span",{className:`px-1.5 py-0.5 rounded text-[10px] font-medium ${re[x.function_type]||"bg-gray-100 text-gray-600"}`,children:x.function_type})}),e.jsx("td",{className:"px-2 py-1.5",children:e.jsxs("select",{value:x.primary_model_id||"",onChange:v=>d(x.id,"primary",v.target.value),className:`w-full px-1.5 py-0.5 border rounded text-xs focus:outline-none focus:ring-1 focus:ring-blue-500 ${x.primary_model_id?"border-green-300 bg-green-50":"border-gray-300"}`,children:[e.jsx("option",{value:"",children:"Default (Tier 2)"}),m.map(v=>e.jsx("option",{value:v.id,children:v.display_name},v.id))]})}),e.jsx("td",{className:"px-2 py-1.5",children:e.jsxs("select",{value:x.backup_model_id||"",onChange:v=>d(x.id,"backup",v.target.value),className:"w-full px-1.5 py-0.5 border border-gray-300 rounded text-xs focus:outline-none focus:ring-1 focus:ring-blue-500",children:[e.jsx("option",{value:"",children:"None"}),m.filter(v=>v.id!==x.primary_model_id).map(v=>e.jsx("option",{value:v.id,children:v.display_name},v.id))]})}),e.jsx("td",{className:"px-2 py-1.5 text-right",children:e.jsx("span",{className:`inline-block w-2 h-2 rounded-full ${x.primary_model_id?"bg-green-400":"bg-yellow-400"}`,title:x.primary_model_id?"Assigned":"Using default"})})]},x.id))})]})})]},r)}),e.jsxs("div",{className:"bg-white rounded-lg border border-gray-200 p-4 flex flex-wrap gap-6 text-xs text-gray-500",children:[e.jsxs("div",{children:[e.jsx("span",{className:"font-medium text-gray-700",children:"Functions:"})," ",i.length," total, ",K," unassigned"]}),S&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("span",{className:"font-medium text-gray-700",children:"Today:"}
1)," ",S.today.calls," calls, INR ",S.today.cost_inr.toFixed(2)]}),e.jsxs("div",{children:[e.jsx("span",{className:"font-medium text-gray-700",children:"7-day:"})," ",S.week.calls," calls, INR ",S.week.cost_inr.toFixed(2),","," ",S.week.fallbacks," fallbacks"]}),e.jsxs("div",{children:[e.jsx("span",{className:"font-medium text-gray-700",children:"30-day:"})," ","INR ",S.month.cost_inr.toFixed(2)]})]})]})]})}const le=[{name:"anthropic",display_name:"Anthropic",base_url:"https://api.anthropic.com",is_openai_compatible:!1},{name:"openai",display_name:"OpenAI",base_url:"https://api.openai.com",is_openai_compatible:!0},{name:"google",display_name:"Google AI",base_url:"https://generativelanguage.googleapis.com",is_openai_compatible:!1},{name:"groq",display_name:"Groq",base_url:"https://api.groq.com/openai",is_openai_compatible:!0},{name:"deepseek",display_name:"DeepSeek",base_url:"https://api.deepseek.com",is_openai_compatible:!0},{name:"mistral",display_name:"Mistral",base_url:"https://api.mistral.ai",is_openai_compatible:!0},{name:"together",display_name:"Together AI",base_url:"https://api.together.xyz",is_openai_compatible:!0},{name:"openrouter",display_name:"OpenRouter",base_url:"https://openrouter.ai/api",is_openai_compatible:!0}];function oe(){const[i,b]=n.useState([]),[m,I]=n.useState(!0),[S,D]=n.useState(!1),[T,O]=n.useState(null),[R,f]=n.useState({}),[_,N]=n.useState(""),[c,C]=n.useState({name:"",display_name:"",base_url:"",auth_type:"bearer",is_openai_compatible:!0,rate_limit_rpm:60}),k=n.useCallback(async()=>{try{const s=await y.get("/v1/llm/providers");b(s.providers)}catch(s){N(s instanceof Error?s.message:"Failed to fetch providers")}finally{I(!1)}},[]);n.useEffect(()=>{k()},[k]);const F=s=>{C({name:s.name,display_name:s.display_name,base_url:s.base_url,auth_type:"bearer",is_openai_compatible:s.is_openai_compatible,rate_limit_rpm:60}),O(null),D(!0)},g=()=>{C({name:"",display_name:"",base_url:"",auth_type:"bearer",is_openai_compatible:!0,rate_limit_rpm:60}),D(!1),O(null),N("")},$=async()=>{N("");try{if(T){const s={};c.display_name&&(s.display_name=c.display_name),c.base_url&&(s.base_url=c.base_url),c.auth_type&&(s.auth_type=c.auth_type),s.is_openai_compatible=c.is_openai_compatible,s.rate_limit_rpm=c.rate_limit_rpm,await y.put(`/v1/llm/providers/${T}`,s)}else{if(!c.name||!c.display_name||!c.base_url){N("All fields are required");return}await y.post("/v1/llm/providers",c)}g(),await k()}catch(s){N(s instanceof Error?s.message:"Failed to save provider")}},a=s=>{C({name:s.name,display_name:s.display_name,base_url:s.base_url,auth_type:s.auth_type,is_openai_compatible:s.is_openai_compatible,rate_limit_rpm:s.rate_limit_rpm}),O(s.id),D(!0)},w=async s=>{if(confirm("Are you sure you want to delete this provider?"))try{await y.delete(`/v1/llm/providers/${s}`),await k()}catch(o){N(o instanceof Error?o.message:"Failed to delete provider")}},E=async s=>{f(o=>({...o,[s]:"loading"}));try{const o=await y.post(`/v1/llm/providers/${s}/test`,{});f(d=>({...d,[s]:o})),await k()}catch(o){f(d=>({...d,[s]:{connectivity:!1,latency_ms:null,error:o instanceof Error?o.message:"Test failed"}}))}},P=s=>{const o={active:"bg-green-100 text-green-700",inactive:"bg-gray-100 text-gray-600",healthy:"bg-green-100 text-green-700",unhealthy:"bg-red-100 text-red-700",unknown:"bg-yellow-100 text-yellow-700"};return e.jsx("span",{className:`px-2 py-0.5 rounded text-xs font-medium ${o[s]||"bg-gray-100 text-gray-600"}`,children:s})},L=s=>{const[o,d]={secret_manager:["Secret Manager","bg-green-100 text-green-700"],legacy_db:["legacy DB fallback","bg-amber-100 text-amber-700"],missing:["missing","bg-red-100 text-red-700"]}[s]??[s,"bg-gray-100 text-gray-600"];return e.jsx("span",{className:`px-1.5 py-0.5 rounded text-[10px] font-medium ${d}`,children:o})};return m?e.jsx("div",{className:"text-center py-12 text-gray-400",children:"Loading providers..."}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-medium text-gray-700 mb-2",children:"Quick Add Provider"}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[le.map(s=>{const o=i.some(d=>d.name===s.name);return e.jsxs("button",{onClick:()=>!o&&F(s),disabled:o,className:`px-3 py-1.5 rounded text-sm font-medium border transition-colors ${o?"bg-gray-50 text-gray-400 border-gray-200 cursor-not-allowed":"bg-white text-gray-700 border-gray-300 hover:border-blue-400 hover:text-blue-600"}`,children:[s.display_name,o&&" ✓"]},s.name)}),e.jsx("button",{onClick:()=>{g(),D(!0)},className:"px-3 py-1.5 rounded text-sm font-medium border border-dashed border-gray-300 text-gray-500 hover:border-blue-400 hover:text-blue-600",children:"+ Custom"})]})]}),S&&e.jsxs("div",{className:"bg-white rounded-lg border border-gray-200 p-4",children:[e.jsx("h3",{className:"text-sm font-semibold text-gray-800 mb
1-3",children:T?"Edit Provider":"Add New Provider"}),_&&e.jsx("div",{className:"bg-red-50 text-red-600 text-sm px-3 py-2 rounded mb-3",children:_}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-gray-500 mb-1",children:"Slug (unique)"}),e.jsx("input",{type:"text",value:c.name,onChange:s=>C({...c,name:s.target.value}),placeholder:"e.g. anthropic",disabled:!!T,className:"w-full px-3 py-1.5 border border-gray-300 rounded text-sm focus:outline-none focus:ring-1 focus:ring-blue-500 disabled:bg-gray-50"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-gray-500 mb-1",children:"Display Name"}),e.jsx("input",{type:"text",value:c.display_name,onChange:s=>C({...c,display_name:s.target.value}),placeholder:"e.g. Anthropic",className:"w-full px-3 py-1.5 border border-gray-300 rounded text-sm focus:outline-none focus:ring-1 focus:ring-blue-500"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-gray-500 mb-1",children:"Base URL"}),e.jsx("input",{type:"text",value:c.base_url,onChange:s=>C({...c,base_url:s.target.value}),placeholder:"https://api.anthropic.com",className:"w-full px-3 py-1.5 border border-gray-300 rounded text-sm focus:outline-none focus:ring-1 focus:ring-blue-500"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-gray-500 mb-1",children:"API Key"}),e.jsxs("p",{className:"text-xs text-gray-600 bg-gray-50 border border-gray-200 rounded px-3 py-2",children:["Not entered here. Keys live in GCP Secret Manager",T?e.jsxs(e.Fragment,{children:[" as ",e.jsx("span",{className:"font-mono",children:i.find(s=>s.id===T)?.secret_id})]}):" — once the provider is added, its card shows the secret to create",". To change a key, add a new secret version, then press Test."]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-gray-500 mb-1",children:"Rate Limit (RPM)"}),e.jsx("input",{type:"number",value:c.rate_limit_rpm,onChange:s=>C({...c,rate_limit_rpm:Number(s.target.value)}),className:"w-full px-3 py-1.5 border border-gray-300 rounded text-sm focus:outline-none focus:ring-1 focus:ring-blue-500"})]}),e.jsx("div",{className:"flex items-center gap-4 pt-4",children:e.jsxs("label",{className:"flex items-center gap-2 text-sm text-gray-700",children:[e.jsx("input",{type:"checkbox",checked:c.is_openai_compatible,onChange:s=>C({...c,is_openai_compatible:s.target.checked}),className:"rounded border-gray-300"}),"OpenAI-compatible API"]})})]}),e.jsxs("div",{className:"flex gap-2 mt-4",children:[e.jsx("button",{onClick:$,className:"px-4 py-1.5 bg-blue-600 text-white rounded text-sm font-medium hover:bg-blue-700",children:T?"Update":"Add Provider"}),e.jsx("button",{onClick:g,className:"px-4 py-1.5 bg-gray-100 text-gray-600 rounded text-sm font-medium hover:bg-gray-200",children:"Cancel"})]})]}),i.length===0?e.jsx("div",{className:"text-center py-8 text-gray-400 text-sm",children:"No providers configured. Click a template above to add one."}):e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:i.map(s=>{const o=R[s.id];return e.jsxs("div",{className:"bg-white rounded-lg border border-gray-200 p-4 flex flex-col gap-2",children:[e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"font-semibold text-gray-800",children:s.display_name}),e.jsx("p",{className:"text-xs text-gray-400 font-mono",children:s.name})]}),e.jsxs("div",{className:"flex gap-1",children:[P(s.status),P(s.health_status)]})]}),e.jsxs("div",{className:"text-xs text-gray-500 space-y-0.5",children:[e.jsxs("p",{children:["URL: ",e.jsx("span",{className:"font-mono",children:s.base_url})]}),e.jsxs("p",{children:["Key: ",e.jsx("span",{className:"font-mono",children:s.secret_id})," ",L(s.key_source)," ",s.key_source!=="missing"&&e.jsx("span",{className:"font-mono",children:s.api_key_masked})]}),s.key_source==="missing"&&e.jsxs("p",{className:"text-red-600",children:["Create it:"," ",e.jsxs("span",{className:"font-mono select-all",children:["gcloud secrets create ",s.secret_id," --data-file=- --project adpilot-489907"]})]}),e.jsxs("p",{children:["Rate: ",s.rate_limit_rpm," RPM | Auth: ",s.auth_type," |"," ",s.is_openai_compatible?"OpenAI-compatible":"Native API"]})]}),o&&o!=="loading"&&e.jsx("div",{className:`text-xs px-2 py-1.5 rounded ${o.connectivity?"bg-green-50 text-green-700":"bg-red-50 text-red-700"}`,children:o.connectivity?`Connected (${o.latency_ms}ms)`:`Failed: ${o.error}`}),e.jsxs("div",{className:"flex gap-2 mt-1",children:[e.jsx("button",{onClick:()=>E(s.id),disabled:o==="loading",className:"px-3 py-1 text-xs font-medium border border-gray-300 rounded hover:bg-gray-50 disabled:opacity-50",children:o==="loading"?"Testing...":"Test"}),e.jsx("button",{onClick:()=>a(s),className:"px-3 py-1 text-xs font-medium border border-gray-300 rounded hover:bg-gray-50",children:"Edit"}),e.jsx("button",{onClick:()=>w(s.id),className:"px-3 py-1 text-xs font-medium border border-red-200 text-red-600 rounded hover:bg-red-50",children:"Delete"})]})]},s.id)})})]})}const ie={fast:"bg-green-100 text-green-700",standard:"bg-blue-100 text-blue-700",thinking:"bg-purple-100 text-purple-700",multimodal:"bg-indigo-100 text-indigo-700",coding:"bg-orange-100 text-orange-700",embedding:"bg-gray-100 text-gray-600"};function de(){const[i,b]=n.useState([]),[m,I]=n.useState([]),[S,D]=n.useState([]),[T,O]=n.useState(!0),[R,f]=n.useState(!1),[_,N]=n.useState({}),[c,C]=n.useState({}),[k,F]=n.useState(""),[g,$]=n.useState("idle"),[a,w]=n.useState(""),[E,P]=n.useState(""),[L,s]=n.useState(!1),o=n.useRef(null),[d,M]=n.useState({provider_id:"",model_id:"",display_name:"",input_cost_per_1k_tokens:.003,output_cost_per_1k_tokens:.015,max_context_tokens:2e5,supports_vision:!1,supports_function_calling:!1,supports_json_mode:!1}),B=n.useCallback(async(t,l)=>{if(!t||t.length<3){$("idle"),w(""),P(""),s(!1);return}$("looking");try{let h=`/v1/llm/catalog/${encodeURIComponent(t)}`;l&&(h+=`?provider_id=${encodeURIComponent(l)}`);const u=await y.get(h);u.found?($("found"),w(u.category||""),P(u.source||"catalog"),s(u.live_verified||!1),M(A=>
1({...A,display_name:u.display_name||A.display_name||"",input_cost_per_1k_tokens:u.input_cost_per_1k_tokens??A.input_cost_per_1k_tokens,output_cost_per_1k_tokens:u.output_cost_per_1k_tokens??A.output_cost_per_1k_tokens,max_context_tokens:u.max_context_tokens??A.max_context_tokens,supports_vision:u.supports_vision??A.supports_vision,supports_function_calling:u.supports_function_calling??A.supports_function_calling,supports_json_mode:u.supports_json_mode??A.supports_json_mode}))):($("not_found"),w(""),P(""),s(!1))}catch{$("not_found"),w(""),P(""),s(!1)}},[]),V=t=>{M(l=>({...l,model_id:t})),o.current&&clearTimeout(o.current),o.current=setTimeout(()=>B(t,d.provider_id),400)},K=t=>{M(l=>({...l,provider_id:t})),d.model_id&&d.model_id.length>=3&&(o.current&&clearTimeout(o.current),o.current=setTimeout(()=>B(d.model_id,t),300))},q=n.useCallback(async()=>{try{const[t,l,h]=await Promise.all([y.get("/v1/llm/models"),y.get("/v1/llm/providers"),y.get("/v1/llm/functions")]);b(t.models),I(l.providers),D(h.functions)}catch(t){F(t instanceof Error?t.message:"Failed to fetch data")}finally{O(!1)}},[]);n.useEffect(()=>{q()},[q]);const Y=()=>{M({provider_id:"",model_id:"",display_name:"",input_cost_per_1k_tokens:.003,output_cost_per_1k_tokens:.015,max_context_tokens:2e5,supports_vision:!1,supports_function_calling:!1,supports_json_mode:!1}),f(!1),F("")},H=async()=>{if(F(""),!d.provider_id||!d.model_id||!d.display_name){F("Provider, Model ID, and Display Name are required");return}try{await y.post("/v1/llm/models",d),Y(),await q()}catch(t){F(t instanceof Error?t.message:"Failed to create model")}},r=async t=>{if(confirm("Are you sure you want to delete this model?"))try{await y.delete(`/v1/llm/models/${t}`),await q()}catch(l){F(l instanceof Error?l.message:"Failed to delete model")}},p=async t=>{N(l=>({...l,[t]:"loading"}));try{const l=await y.post(`/v1/llm/models/${t}/test`,{});N(h=>({...h,[t]:l}))}catch(l){N(h=>({...h,[t]:{connectivity:!1,latency_ms:0,tokens_per_second:0,quality_output:"",input_tokens:0,output_tokens:0,overall_status:"fail",function_id:null,error:l instanceof Error?l.message:"Test failed"}}))}},j=async t=>{const l=c[t];if(!l){F("Select a function for contextual test");return}N(h=>({...h,[t]:"loading"}));try{const h=await y.post(`/v1/llm/models/${t}/test-context`,{function_id:l});N(u=>({...u,[t]:h}))}catch(h){N(u=>({...u,[t]:{connectivity:!1,latency_ms:0,tokens_per_second:0,quality_output:"",input_tokens:0,output_tokens:0,overall_status:"fail",function_id:l,error:h instanceof Error?h.message:"Test failed"}}))}},x=async t=>{try{await y.put(`/v1/llm/models/${t}/qualify`,{}),await q()}catch(l){F(l instanceof Error?l.message:"Failed to qualify model")}},v=async t=>{try{await y.put(`/v1/llm/models/${t}/reject`,{}),await q()}catch(l){F(l instanceof Error?l.message:"Failed to reject model")}},Q=t=>{const l={qualified:"bg-green-100 text-green-700",rejected:"bg-red-100 text-red-700",pending:"bg-yellow-100 text-yellow-700"};return e.jsx("span",{className:`px-2 py-0.5 rounded text-xs font-medium ${l[t]||"bg-gray-100 text-gray-600"}`,children:t})},ee=t=>{if(t===null||t===0)return null;let l="Slow",h="text-red-500";return t>=60?(l="Fast",h="text-green-600"):t>=30?(l="Good",h="text-blue-600"):t>=15&&(l="OK",h="text-yellow-600"),e.jsxs("span",{className:`text-xs font-medium ${h}`,children:[t.toFixed(0)," tok/s (",l,")"]})};return T?e.jsx("div",{className:"text-center py-12 text-gray-400",children:"Loading models..."}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h3",{className:"text-sm font-medium text-gray-700",children:"Models"}),e.jsx("button",{onClick:()=>f(!R),className:"px-3 py-1.5 text-sm font-medium bg-blue-600 text-white rounded hover:bg-blue-700",children:"+ Add Model"})]}),k&&e.jsx("div",{className:"bg-red-50 text-red-600 text-sm px-3 py-2 rounded",children:k}),R&&e.jsxs("div",{className:"bg-white rounded-lg border border-gray-200 p-4",children:[e.jsx("h4",{className:"text-sm font-semibold text-gray-800 mb-3",children:"Register New Model"}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-gray-500 mb-1",children:"Provider"}),e.jsxs("select",{value:d.provider_id,onChange:t=>K(t.target.value),className:"w-full px-3 py-1.5 border border-gray-300 rounded text-sm focus:outline-none focus:ring-1 focus:ring-blue-500",children:[e.jsx("option",{value:"",children:"Select provider..."}),m.map(t=>e.jsx("option",{value:t.id,children:t.display_name},t.id))]})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"block text-xs text-gray-500 mb-1",children:["Model ID",g==="looking"&&e.jsx("span",{className:"ml-2 text-blue-500",children:"verifying with provider..."}),g==="found"&&L&&e.jsxs("span",{className:"ml-2 text-green-600 font-medium",children:["✓ live verified",E==="catalog+live"&&" + catalog pricing"]}),g==="found"&&!L&&e.jsxs("span",{className:"ml-2 text-green-600",children:["auto-filled from catalog",d.provider_id&&e.jsx("span",{className:"text-yellow-600 ml-1",children:"(select provider to verify live)"})]}),g==="not_found"&&e.jsx("span",{className:"ml-2 text-yellow-600",children:"not in catalog — fill manually"})]}),e.jsx("input",{type:"text",value:d.model_id,onChange:t=>V(t.target.value),placeholder:"e.g. claude-sonnet-4-20250514",className:"w-full px-3 py-1.5 border border-gray-300 rounded text-sm focus:outline-none focus:ring-1 focus:ring-blue-500"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-gray-500 mb-1",children:"Display Name"}),e.jsx("input",{type:"text",value:d.display_name,onChange:t=>M({...d,display_name:t.target.value}),placeholder:"e.g. Claude Sonnet 4",className:`w-full px-3 py-1.5 border rounded text-sm focus:outline-none focus:ring-1 focus:ring-blue-500 ${g==="found"?L?"border-blue-400 bg-blue-50":"border-green-300 bg-green-50":"border-gray-300"}`})]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-3 mt-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-gray-500 mb-1",children:"Input Cost ($/1K tokens)"}),e.jsx("input",{type:"number",step:"0.0001",value:d.input_cost_per_1k_tokens,onChange:t=>M({...d,input_cost_per_1k_tokens:Number(t.target.value)}),className:`w-full px-3 py-1.5 border rounded text-sm focus:outline-none focus:ring-1 focus:ring-blue-500 ${g==="found"?L?"border-blue-400 bg-blue-50":"border-green-300 bg-green-50":"border-gray-300"}`})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-gray-500 mb-1",children:"Output C
1ost ($/1K tokens)"}),e.jsx("input",{type:"number",step:"0.0001",value:d.output_cost_per_1k_tokens,onChange:t=>M({...d,output_cost_per_1k_tokens:Number(t.target.value)}),className:`w-full px-3 py-1.5 border rounded text-sm focus:outline-none focus:ring-1 focus:ring-blue-500 ${g==="found"?L?"border-blue-400 bg-blue-50":"border-green-300 bg-green-50":"border-gray-300"}`})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-gray-500 mb-1",children:"Max Context Tokens"}),e.jsx("input",{type:"number",value:d.max_context_tokens,onChange:t=>M({...d,max_context_tokens:Number(t.target.value)}),className:`w-full px-3 py-1.5 border rounded text-sm focus:outline-none focus:ring-1 focus:ring-blue-500 ${g==="found"?L?"border-blue-400 bg-blue-50":"border-green-300 bg-green-50":"border-gray-300"}`})]})]}),e.jsxs("div",{className:"flex items-center gap-4 mt-3 flex-wrap",children:[e.jsxs("label",{className:`flex items-center gap-1.5 text-xs ${g==="found"?L?"text-blue-700 font-medium":"text-green-700 font-medium":"text-gray-600"}`,children:[e.jsx("input",{type:"checkbox",checked:d.supports_vision,onChange:t=>M({...d,supports_vision:t.target.checked}),className:"rounded border-gray-300"}),"Vision"]}),e.jsxs("label",{className:`flex items-center gap-1.5 text-xs ${g==="found"?L?"text-blue-700 font-medium":"text-green-700 font-medium":"text-gray-600"}`,children:[e.jsx("input",{type:"checkbox",checked:d.supports_function_calling,onChange:t=>M({...d,supports_function_calling:t.target.checked}),className:"rounded border-gray-300"}),"Function Calling"]}),e.jsxs("label",{className:`flex items-center gap-1.5 text-xs ${g==="found"?L?"text-blue-700 font-medium":"text-green-700 font-medium":"text-gray-600"}`,children:[e.jsx("input",{type:"checkbox",checked:d.supports_json_mode,onChange:t=>M({...d,supports_json_mode:t.target.checked}),className:"rounded border-gray-300"}),"JSON Mode"]}),a&&e.jsx("span",{className:`px-2 py-0.5 rounded text-xs font-medium ${ie[a]||"bg-gray-100 text-gray-600"}`,children:a})]}),e.jsxs("div",{className:"flex gap-2 mt-4",children:[e.jsx("button",{onClick:H,className:"px-4 py-1.5 bg-blue-600 text-white rounded text-sm font-medium hover:bg-blue-700",children:"Add Model"}),e.jsx("button",{onClick:()=>{Y(),$("idle"),w(""),P(""),s(!1)},className:"px-4 py-1.5 bg-gray-100 text-gray-600 rounded text-sm font-medium hover:bg-gray-200",children:"Cancel"})]})]}),i.length===0?e.jsx("div",{className:"text-center py-8 text-gray-400 text-sm",children:"No models registered. Add a provider first, then register models."}):e.jsx("div",{className:"space-y-3",children:i.map(t=>{const l=_[t.id],h=l==="loading",u=l&&l!=="loading"?l:null;return e.jsxs("div",{className:"bg-white rounded-lg border border-gray-200 p-4",children:[e.jsxs("div",{className:"flex items-start justify-between mb-2",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"font-semibold text-gray-800",children:t.display_name}),e.jsxs("p",{className:"text-xs text-gray-400 font-mono",children:[t.provider_display_name," / ",t.model_id]})]}),e.jsxs("div",{className:"flex gap-1.5 items-center",children:[Q(t.qualification_status),ee(t.tokens_per_second)]})]}),e.jsxs("div",{className:"flex flex-wrap gap-3 text-xs text-gray-500 mb-3",children:[e.jsxs("span",{children:["Input: $",t.input_cost_per_1k_tokens,"/1K"]}),e.jsxs("span",{children:["Output: $",t.output_cost_per_1k_tokens,"/1K"]}),e.jsxs("span",{children:["Context: ",(t.max_context_tokens/1e3).toFixed(0),"K"]}),t.supports_vision&&e.jsx("span",{className:"text-blue-500",children:"Vision"}),t.supports_function_calling&&e.jsx("span",{className:"text-blue-500",children:"Functions"}),t.supports_json_mode&&e.jsx("span",{className:"text-blue-500",children:"JSON"}),t.avg_latency_ms&&e.jsxs("span",{children:["Latency: ",t.avg_latency_ms,"ms"]})]}),u&&e.jsxs("div",{className:`text-xs rounded p-3 mb-3 ${u.connectivity?"bg-green-50":"bg-red-50"}`,children:[e.jsxs("div",{className:"flex gap-3 mb-1.5",children:[e.jsx("span",{className:u.connectivity?"text-green-700":"text-red-700",children:u.connectivity?"PASS":"FAIL"}),e.jsxs("span",{className:"text-gray-500",children:[u.latency_ms,"ms | ",u.tokens_per_second," tok/s |"," ",u.input_tokens,"+",u.output_tokens," tokens"]}),u.function_id&&e.jsxs("span",{className:"text-purple-600",children:["Function: ",u.function_id]})]}),u.quality_output&&e.jsx("pre",{className:"text-gray-600 whitespace-pre-wrap text-xs mt-1 max-h-24 overflow-y-auto",children:u.quality_output}),u.error&&e.jsx("p",{className:"text-red-600 mt-1",children:u.error})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("button",{onClick:()=>p(t.id),disabled:h,className:"px-3 py-1 text-xs font-medium border border-gray-300 rounded hover:bg-gray-50 disabled:opacity-50",children:h?"Testing...":"Universal Test"}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsxs("select",{value:c[t.id]||"",onChange:A=>C(te=>({...te,[t.id]:A.target.value})),className:"px-2 py-1 border border-gray-300 rounded text-xs focus:outline-none focus:ring-1 focus:ring-blue-500 max-w-[200px]",children:[e.jsx("option",{value:"",children:"Select function..."}),S.map(A=>e.jsx("option",{value:A.id,children:A.id},A.id))]}),e.jsx("button",{onClick:()=>j(t.id),disabled:h||!c[t.id],className:"px-3 py-1 text-xs font-medium border border-purple-200 text-purple-600 rounded hover:bg-purple-50 disabled:opacity-50",children:"Test in Context"})]}),e.jsx("div",{className:"flex-1"}),t.qualification_status!=="qualified"&&e.jsx("button",{onClick:()=>x(t.id),className:"px-3 py-1 text-xs font-medium bg-green-50 text-green-700 border border-green-200 rounded hover:bg-green-100",children:"Mark Qualified"}),t.qualification_status!=="rejected"&&e.jsx("button",{onClick:()=>v(t.id),className:"px-3 py-1 text-xs font-medium bg-red-50 text-red-600 border border-red-200 rounded hover:bg-red-100",children:"Reject"}),e.jsx("button",{onClick:()=>r(t.id),className:"px-3 py-1 text-xs font-medium border border-red-200 text-red-600 rounded hover:bg-red-50",children:"Delete"})]})]},t.id)})})]})}const W={anthropic:"bg-orange-100 text-orange-700",google:"bg-blue-100 text-blue-700",openai:"bg-emerald-100 text-emerald-700",unknown:"bg-gray-100 text-gray-500"},ce=[{id:7,label:"7 days"},{id:30,label:"30 days"},{id:90,label:"90 days"}],U=i=>
1"₹"+(i??0).toLocaleString("en-IN",{maximumFractionDigits:2}),z=i=>{const b=i??0;return b>=1e6?(b/1e6).toFixed(2)+"M":b>=1e3?(b/1e3).toFixed(1)+"K":String(b)},G={},X=["bg-blue-100 text-blue-700","bg-purple-100 text-purple-700","bg-green-100 text-green-700","bg-orange-100 text-orange-700","bg-pink-100 text-pink-700","bg-teal-100 text-teal-700","bg-gray-200 text-gray-600"];function xe(i){if(!G[i])if(i==="unknown")G[i]="bg-gray-200 text-gray-500";else{const b=Object.keys(G).length%X.length;G[i]=X[b]}return G[i]}function ue(){const[i,b]=n.useState(30),[m,I]=n.useState(null),[S,D]=n.useState(!0),[T,O]=n.useState(""),R=n.useCallback(async()=>{D(!0),O("");try{const a=await y.get(`/v1/llm/costs?days=${i}`);I(a)}catch(a){O(a instanceof Error?a.message:"Failed to load costs")}finally{D(!1)}},[i]);n.useEffect(()=>{R()},[R]);const f=m?.totals||{},_=f.cost_inr||0,N=m?.by_provider||[],c=m?.by_model||[],C=m?.by_function||[],k=m?.by_day||[],F=Math.max(1,...k.map(a=>a.cost_inr)),g=m?.usd_to_inr||84,$=c.some(a=>a.attributed===!1);return e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-5",children:[e.jsx("div",{className:"flex gap-1.5",children:ce.map(a=>e.jsx("button",{onClick:()=>b(a.id),className:`px-3 py-1.5 text-sm rounded-md border transition-colors ${i===a.id?"bg-blue-600 text-white border-blue-600":"bg-white text-gray-600 border-gray-300 hover:bg-gray-50"}`,children:a.label},a.id))}),e.jsx("button",{onClick:R,className:"text-sm text-gray-500 hover:text-gray-700",disabled:S,children:S?"Loading…":"↻ Refresh"})]}),T&&e.jsx("div",{className:"mb-4 p-3 rounded-md bg-red-50 text-red-700 text-sm border border-red-200",children:T}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4 mb-6",children:[e.jsx(J,{label:`Total spend · ${i}d`,value:U(_),sub:`≈ $${(_/g).toFixed(2)} USD`,accent:!0}),e.jsx(J,{label:"LLM calls",value:(f.calls||0).toLocaleString("en-IN"),sub:`${U(f.calls?_/f.calls:0)}/call`}),e.jsx(J,{label:"Input tokens",value:z(f.input_tokens),sub:"prompt + cache"}),e.jsx(J,{label:"Output tokens",value:z(f.output_tokens),sub:"generated"})]}),S&&!m?e.jsx("div",{className:"text-gray-400 text-sm py-12 text-center",children:"Loading cost data…"}):e.jsxs(e.Fragment,{children:[N.length>0&&e.jsx("div",{className:"mb-6 flex flex-wrap gap-3",children:N.map(a=>{const w=_?a.cost_inr/_*100:0;return e.jsxs("div",{className:"flex-1 min-w-[160px] rounded-lg border border-gray-200 bg-white p-3",children:[e.jsx("span",{className:`inline-block px-2 py-0.5 rounded text-xs font-medium capitalize ${W[a.provider]||W.unknown}`,children:a.provider}),e.jsx("div",{className:"text-lg font-bold text-gray-900 mt-1.5",children:U(a.cost_inr)}),e.jsxs("div",{className:"text-xs text-gray-400",children:[a.calls.toLocaleString("en-IN")," calls · ",w.toFixed(0),"%"]})]},a.provider)})}),k.length>1&&e.jsxs("div",{className:"mb-6 bg-white border border-gray-200 rounded-lg p-4",children:[e.jsx("div",{className:"text-sm font-medium text-gray-700 mb-3",children:"Daily spend (₹)"}),e.jsx("div",{className:"flex items-end gap-0.5 h-28 w-full",children:k.map(a=>e.jsxs("div",{className:"flex-1 h-full flex flex-col justify-end group relative",children:[e.jsx("div",{className:"w-full bg-blue-400 hover:bg-blue-600 rounded-t-sm transition-colors",style:{height:`${Math.max(3,a.cost_inr/F*100)}%`}}),e.jsxs("div",{className:`absolute bottom-full mb-1 left-1/2 -translate-x-1/2 hidden group-hover:block\r
2                                    bg-gray-900 text-white text-[10px] rounded px-1.5 py-0.5 whitespace-nowrap z-10`,children:[a.day,": ",U(a.cost_inr)," · ",a.calls," calls"]})]},a.day))}),e.jsxs("div",{className:"flex justify-between text-[10px] text-gray-400 mt-1",children:[e.jsx("span",{children:k[0]?.day}),e.jsx("span",{children:k[k.length-1]?.day})]})]}),e.jsxs(Z,{title:"Spend by model",subtitle:"Which models are consuming cost",children:[e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"text-left text-gray-400 border-b border-gray-100",children:[e.jsx("th",{className:"py-2 font-medium",children:"Model"}),e.jsx("th",{className:"py-2 font-medium text-right",children:"Calls"}),e.jsx("th",{className:"py-2 font-medium text-right",children:"In / Out tokens"}),e.jsx("th",{className:"py-2 font-medium text-right",children:"Rate $/1M (in/out)"}),e.jsx("th",{className:"py-2 font-medium text-right",children:"Cost"}),e.jsx("th",{className:"py-2 font-medium text-right w-28",children:"Share"})]})}),e.jsxs("tbody",{children:[c.map(a=>{const w=_?a.cost_inr/_*100:0;return e.jsxs("tr",{className:"border-b border-gray-50",children:[e.jsxs("td",{className:"py-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:`inline-block px-1.5 py-0.5 rounded text-[10px] font-medium capitalize ${W[a.provider||"unknown"]||W.unknown}`,children:a.provider||"—"}),e.jsx("span",{className:"font-medium text-gray-800",children:a.display_name||a.model})]}),e.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[e.jsx("span",{className:"text-[11px] text-gray-400 font-mono",children:a.model}),a.attributed===!1&&e.jsx("span",{className:"text-[10px] text-gray-400",title:"No model logged on these (older) calls — attributed via the function's configured model",children:"~derived"}),a.price_known===!1&&e.jsx("span",{className:"text-[10px] text-amber-600",title:"No published price in the price book — billed at a default estimate",children:"est. price"})]})]}),e.jsx("td",{className:"py-2 text-right text-gray-600",children:a.calls.toLocaleStr
2ing("en-IN")}),e.jsxs("td",{className:"py-2 text-right text-gray-500",children:[z(a.input_tokens)," / ",z(a.output_tokens)]}),e.jsx("td",{className:"py-2 text-right text-gray-500",children:`${a.price_in_usd_1m} / ${a.price_out_usd_1m}`}),e.jsx("td",{className:"py-2 text-right font-medium text-gray-900",children:U(a.cost_inr)}),e.jsx("td",{className:"py-2 text-right",children:e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e.jsx("div",{className:"w-12 h-1.5 bg-gray-100 rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full bg-blue-500",style:{width:`${w}%`}})}),e.jsxs("span",{className:"text-gray-400 text-xs w-9 text-right",children:[w.toFixed(0),"%"]})]})})]},a.model)}),c.length===0&&e.jsx("tr",{children:e.jsx("td",{colSpan:6,className:"py-6 text-center text-gray-400",children:"No data for this window."})})]})]}),e.jsxs("p",{className:"text-xs text-gray-400 mt-3",children:["Totals attributed: ",e.jsxs("span",{className:"font-medium",children:[f.attributed_pct??0,"%"]})," logged directly.",$&&e.jsxs(e.Fragment,{children:[" Rows marked ",e.jsx("span",{className:"font-mono",children:"~derived"})," had no model on the call (older rows) and are attributed via each function's configured model."]})]})]}),e.jsx(Z,{title:"Spend by function",subtitle:"The individual functions driving the cost",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"text-left text-gray-400 border-b border-gray-100",children:[e.jsx("th",{className:"py-2 font-medium",children:"Function"}),e.jsx("th",{className:"py-2 font-medium",children:"Model(s)"}),e.jsx("th",{className:"py-2 font-medium text-right",children:"Calls"}),e.jsx("th",{className:"py-2 font-medium text-right",children:"Tokens"}),e.jsx("th",{className:"py-2 font-medium text-right",children:"Avg latency"}),e.jsx("th",{className:"py-2 font-medium text-right",children:"Errors"}),e.jsx("th",{className:"py-2 font-medium text-right",children:"Cost"}),e.jsx("th",{className:"py-2 font-medium text-right w-24",children:"Share"})]})}),e.jsxs("tbody",{children:[C.map(a=>{const w=_?a.cost_inr/_*100:0;return e.jsxs("tr",{className:"border-b border-gray-50 hover:bg-gray-50",children:[e.jsx("td",{className:"py-2 font-mono text-xs text-gray-700",children:a.function_id}),e.jsx("td",{className:"py-2",children:e.jsx("div",{className:"flex flex-wrap gap-1",children:(a.models||[]).map(E=>e.jsx("span",{className:`px-1.5 py-0.5 rounded text-[10px] ${xe(E)}`,children:E},E))})}),e.jsx("td",{className:"py-2 text-right text-gray-600",children:a.calls.toLocaleString("en-IN")}),e.jsx("td",{className:"py-2 text-right text-gray-500",children:z((a.input_tokens||0)+(a.output_tokens||0))}),e.jsxs("td",{className:"py-2 text-right text-gray-500",children:[(a.avg_latency_ms/1e3).toFixed(1),"s"]}),e.jsx("td",{className:"py-2 text-right",children:a.errors>0?e.jsx("span",{className:"text-red-500",children:a.errors}):e.jsx("span",{className:"text-gray-300",children:"0"})}),e.jsx("td",{className:"py-2 text-right font-medium text-gray-900",children:U(a.cost_inr)}),e.jsxs("td",{className:"py-2 text-right text-gray-400 text-xs",children:[w.toFixed(1),"%"]})]},a.function_id)}),C.length===0&&e.jsx("tr",{children:e.jsx("td",{colSpan:8,className:"py-6 text-center text-gray-400",children:"No data for this window."})})]})]})})]})]})}function J({label:i,value:b,sub:m,accent:I}){return e.jsxs("div",{className:`rounded-lg border p-4 ${I?"border-blue-200 bg-blue-50":"border-gray-200 bg-white"}`,children:[e.jsx("div",{className:"text-xs text-gray-500 mb-1",children:i}),e.jsx("div",{className:`text-2xl font-bold ${I?"text-blue-700":"text-gray-900"}`,children:b}),m&&e.jsx("div",{className:"text-xs text-gray-400 mt-0.5",children:m})]})}function Z({title:i,subtitle:b,children:m}){return e.jsxs("div",{className:"mb-6 bg-white border border-gray-200 rounded-lg p-4",children:[e.jsxs("div",{className:"mb-3",children:[e.jsx("div",{className:"text-sm font-semibold text-gray-800",children:i}),b&&e.jsx("div",{className:"text-xs text-gray-400",children:b})]}),e.jsx("div",{className:"overflow-x-auto",children:m})]})}const me=[{id:"costs",label:"Cost & Usage"},{id:"functions",label:"Function-Model Assignment"},{id:"providers",label:"Provider Management"},{id:"models",label:"Model Testing & Qualification"}];function ge(){const[i,b]=n.useState("costs");return e.jsxs("div",{className:"p-6",children:[e.jsx("h1",{className:"text-2xl font-bold text-gray-900 mb-1",children:"LLM 
2Settings"}),e.jsx("p",{className:"text-gray-500 mb-6 text-sm",children:"Manage providers, register & test models, assign models to functions."}),e.jsx("div",{className:"border-b border-gray-200 mb-6",children:e.jsx("nav",{className:"flex gap-6",children:me.map(m=>e.jsx("button",{onClick:()=>b(m.id),className:`pb-2.5 text-sm font-medium transition-colors ${i===m.id?"text-blue-600 border-b-2 border-blue-600":"text-gray-500 hover:text-gray-700"}`,children:m.label},m.id))})}),i==="costs"&&e.jsx(ue,{}),i==="functions"&&e.jsx(ne,{}),i==="providers"&&e.jsx(oe,{}),i==="models"&&e.jsx(de,{})]})}export{ge 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.