omniroute 2.7.5 → 2.7.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (100) hide show
  1. package/app/.next/BUILD_ID +1 -1
  2. package/app/.next/build-manifest.json +2 -2
  3. package/app/.next/prerender-manifest.json +3 -3
  4. package/app/.next/server/app/(dashboard)/dashboard/a2a/page_client-reference-manifest.js +1 -1
  5. package/app/.next/server/app/(dashboard)/dashboard/agents/page_client-reference-manifest.js +1 -1
  6. package/app/.next/server/app/(dashboard)/dashboard/analytics/page_client-reference-manifest.js +1 -1
  7. package/app/.next/server/app/(dashboard)/dashboard/api-manager/page_client-reference-manifest.js +1 -1
  8. package/app/.next/server/app/(dashboard)/dashboard/audit-log/page_client-reference-manifest.js +1 -1
  9. package/app/.next/server/app/(dashboard)/dashboard/auto-combo/page_client-reference-manifest.js +1 -1
  10. package/app/.next/server/app/(dashboard)/dashboard/cli-tools/page_client-reference-manifest.js +1 -1
  11. package/app/.next/server/app/(dashboard)/dashboard/combos/page_client-reference-manifest.js +1 -1
  12. package/app/.next/server/app/(dashboard)/dashboard/costs/page_client-reference-manifest.js +1 -1
  13. package/app/.next/server/app/(dashboard)/dashboard/endpoint/page_client-reference-manifest.js +1 -1
  14. package/app/.next/server/app/(dashboard)/dashboard/health/page_client-reference-manifest.js +1 -1
  15. package/app/.next/server/app/(dashboard)/dashboard/limits/page_client-reference-manifest.js +1 -1
  16. package/app/.next/server/app/(dashboard)/dashboard/logs/page_client-reference-manifest.js +1 -1
  17. package/app/.next/server/app/(dashboard)/dashboard/mcp/page_client-reference-manifest.js +1 -1
  18. package/app/.next/server/app/(dashboard)/dashboard/media/page_client-reference-manifest.js +1 -1
  19. package/app/.next/server/app/(dashboard)/dashboard/onboarding/page_client-reference-manifest.js +1 -1
  20. package/app/.next/server/app/(dashboard)/dashboard/page_client-reference-manifest.js +1 -1
  21. package/app/.next/server/app/(dashboard)/dashboard/playground/page_client-reference-manifest.js +1 -1
  22. package/app/.next/server/app/(dashboard)/dashboard/profile/page_client-reference-manifest.js +1 -1
  23. package/app/.next/server/app/(dashboard)/dashboard/providers/[id]/page_client-reference-manifest.js +1 -1
  24. package/app/.next/server/app/(dashboard)/dashboard/providers/new/page_client-reference-manifest.js +1 -1
  25. package/app/.next/server/app/(dashboard)/dashboard/providers/page_client-reference-manifest.js +1 -1
  26. package/app/.next/server/app/(dashboard)/dashboard/search-tools/page_client-reference-manifest.js +1 -1
  27. package/app/.next/server/app/(dashboard)/dashboard/settings/page_client-reference-manifest.js +1 -1
  28. package/app/.next/server/app/(dashboard)/dashboard/settings/pricing/page_client-reference-manifest.js +1 -1
  29. package/app/.next/server/app/(dashboard)/dashboard/translator/page_client-reference-manifest.js +1 -1
  30. package/app/.next/server/app/(dashboard)/dashboard/usage/page_client-reference-manifest.js +1 -1
  31. package/app/.next/server/app/400/page_client-reference-manifest.js +1 -1
  32. package/app/.next/server/app/401/page_client-reference-manifest.js +1 -1
  33. package/app/.next/server/app/403/page_client-reference-manifest.js +1 -1
  34. package/app/.next/server/app/408/page_client-reference-manifest.js +1 -1
  35. package/app/.next/server/app/429/page_client-reference-manifest.js +1 -1
  36. package/app/.next/server/app/500/page_client-reference-manifest.js +1 -1
  37. package/app/.next/server/app/502/page_client-reference-manifest.js +1 -1
  38. package/app/.next/server/app/503/page_client-reference-manifest.js +1 -1
  39. package/app/.next/server/app/_global-error.html +2 -2
  40. package/app/.next/server/app/_global-error.rsc +1 -1
  41. package/app/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
  42. package/app/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  43. package/app/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  44. package/app/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  45. package/app/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  46. package/app/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  47. package/app/.next/server/app/api/v1/chat/completions/route.js +2 -2
  48. package/app/.next/server/app/api/v1/completions/route.js +2 -2
  49. package/app/.next/server/app/callback/page_client-reference-manifest.js +1 -1
  50. package/app/.next/server/app/docs/page_client-reference-manifest.js +1 -1
  51. package/app/.next/server/app/forbidden/page_client-reference-manifest.js +1 -1
  52. package/app/.next/server/app/forgot-password/page_client-reference-manifest.js +1 -1
  53. package/app/.next/server/app/landing/page_client-reference-manifest.js +1 -1
  54. package/app/.next/server/app/login/page_client-reference-manifest.js +1 -1
  55. package/app/.next/server/app/maintenance/page_client-reference-manifest.js +1 -1
  56. package/app/.next/server/app/offline/page_client-reference-manifest.js +1 -1
  57. package/app/.next/server/app/page_client-reference-manifest.js +1 -1
  58. package/app/.next/server/app/privacy/page_client-reference-manifest.js +1 -1
  59. package/app/.next/server/app/status/page_client-reference-manifest.js +1 -1
  60. package/app/.next/server/app/terms/page_client-reference-manifest.js +1 -1
  61. package/app/.next/server/chunks/[root-of-the-server]__09c944b3._.js +1 -1
  62. package/app/.next/server/chunks/[root-of-the-server]__12e1b68b._.js +1 -1
  63. package/app/.next/server/chunks/[root-of-the-server]__167585da._.js +1 -1
  64. package/app/.next/server/chunks/[root-of-the-server]__7d9b23e7._.js +1 -1
  65. package/app/.next/server/chunks/[root-of-the-server]__80e3bfc3._.js +2 -2
  66. package/app/.next/server/chunks/[root-of-the-server]__84e445b2._.js +1 -1
  67. package/app/.next/server/chunks/[root-of-the-server]__92cb0def._.js +1 -1
  68. package/app/.next/server/chunks/[root-of-the-server]__db2f9fe0._.js +1 -1
  69. package/app/.next/server/chunks/[root-of-the-server]__dc47ee64._.js +1 -1
  70. package/app/.next/server/chunks/_05c48915._.js +1 -1
  71. package/app/.next/server/chunks/_2115d8de._.js +1 -1
  72. package/app/.next/server/chunks/_3ac953eb._.js +1 -1
  73. package/app/.next/server/chunks/_4b8fd853._.js +1 -1
  74. package/app/.next/server/chunks/_68683848._.js +1 -1
  75. package/app/.next/server/chunks/_ee9b677b._.js +1 -1
  76. package/app/.next/server/chunks/open-sse_services_826884e1._.js +2 -2
  77. package/app/.next/server/chunks/ssr/[root-of-the-server]__9affb65e._.js +1 -1
  78. package/app/.next/server/chunks/ssr/[root-of-the-server]__a6942102._.js +1 -1
  79. package/app/.next/server/chunks/ssr/src_55fa8e28._.js +1 -1
  80. package/app/.next/server/chunks/ssr/src_app_(dashboard)_dashboard_cc92bcad._.js +1 -1
  81. package/app/.next/server/pages/500.html +2 -2
  82. package/app/.next/server/server-reference-manifest.js +1 -1
  83. package/app/.next/server/server-reference-manifest.json +1 -1
  84. package/app/.next/static/chunks/{78578600bdb6c280.js → 31d265d1cd5222f3.js} +1 -1
  85. package/app/.next/static/chunks/{cd0b93c0ed63a487.js → 3423ff268c85cc05.js} +1 -1
  86. package/app/.next/static/chunks/8c9234a3ed7f8c07.js +1 -0
  87. package/app/CHANGELOG.md +30 -0
  88. package/app/Dockerfile +4 -0
  89. package/app/docs/openapi.yaml +1 -1
  90. package/app/open-sse/services/comboAgentMiddleware.ts +19 -0
  91. package/app/package-lock.json +2 -2
  92. package/app/package.json +1 -1
  93. package/app/src/app/(dashboard)/dashboard/combos/page.tsx +80 -0
  94. package/app/src/app/(dashboard)/dashboard/usage/components/BudgetTab.tsx +7 -2
  95. package/app/src/app/api/v1/responses/route.ts +9 -12
  96. package/package.json +1 -1
  97. package/app/.next/static/chunks/c089b7e37ffa02b7.js +0 -1
  98. /package/app/.next/static/{sr8mILxXxauNpSSzV2kMh → V_vOqF97lGIlKgf2kSlun}/_buildManifest.js +0 -0
  99. /package/app/.next/static/{sr8mILxXxauNpSSzV2kMh → V_vOqF97lGIlKgf2kSlun}/_clientMiddlewareManifest.json +0 -0
  100. /package/app/.next/static/{sr8mILxXxauNpSSzV2kMh → V_vOqF97lGIlKgf2kSlun}/_ssgManifest.js +0 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "omniroute",
3
- "version": "2.7.5",
3
+ "version": "2.7.8",
4
4
  "description": "Smart AI Router with auto fallback — route to FREE & cheap models, zero downtime. Works with Cursor, Cline, Claude Desktop, Codex, and any OpenAI-compatible tool.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -1 +0,0 @@
1
- (globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,474078,e=>{"use strict";var t=e.i(342923);e.s(["Button",()=>t.default])},565650,e=>{"use strict";e.i(342923),e.i(80173),e.i(907714),e.i(393718),e.i(703166),e.i(454149),e.i(822124),e.i(969353),e.i(635055),e.i(897844),e.i(450222),e.i(647829),e.i(6998),e.i(982131),e.i(116016),e.i(279743),e.i(193464),e.i(548036),e.i(566770),e.i(953789),e.i(8839),e.i(227404),e.i(621745),e.i(567955),e.i(17517),e.i(419947),e.i(323060),e.i(642440),e.i(629342),e.i(816062),e.i(690777),e.i(563201),e.i(115243),e.i(165149),e.i(359505),e.s([],565650)},11477,e=>{"use strict";var t=e.i(393718);e.s(["Card",()=>t.default])},339971,e=>{"use strict";var t=e.i(80173);e.s(["Input",()=>t.default])},643953,e=>{"use strict";var t=e.i(323060);e.s(["SegmentedControl",()=>t.default])},11131,e=>{"use strict";var t=e.i(629342);e.s(["EmptyState",()=>t.default])},979765,e=>{"use strict";var t=e.i(843476),s=e.i(271645);e.i(565650);var a=e.i(643953),i=e.i(861745),l=e.i(948148),r=e.i(11477),n=e.i(474078),d=e.i(339971),o=e.i(11131),c=e.i(627949);function m({value:e,max:s,warningAt:a=.8,formatCurrency:i}){let l=s>0?Math.min(e/s*100,100):0,r=s>0?e/s:0;return(0,t.jsxs)("div",{className:"w-full",children:[(0,t.jsxs)("div",{className:"flex justify-between text-xs mb-1",children:[(0,t.jsx)("span",{className:"text-text-muted",children:i(e)}),(0,t.jsx)("span",{className:"text-text-muted",children:i(s)})]}),(0,t.jsx)("div",{className:"w-full h-2 rounded-full bg-surface/50 overflow-hidden",children:(0,t.jsx)("div",{className:"h-full rounded-full transition-all duration-500",style:{width:`${l}%`,backgroundColor:r>=1?"#ef4444":r>=a?"#f59e0b":"#22c55e"}})})]})}function u(){let e=(0,l.useTranslations)("usage"),a=(0,i.useLocale)(),[u,x]=(0,s.useState)([]),[p,h]=(0,s.useState)(null),[g,b]=(0,s.useState)(null),[y,f]=(0,s.useState)(!0),[j,v]=(0,s.useState)(!1),[N,w]=(0,s.useState)({dailyLimitUsd:"",monthlyLimitUsd:"",warningThreshold:"80"}),C=(0,c.useNotificationStore)(),S=e=>new Intl.NumberFormat(a,{style:"currency",currency:"USD",minimumFractionDigits:2,maximumFractionDigits:2}).format(Number(e||0));(0,s.useEffect)(()=>{fetch("/api/keys").then(e=>e.json()).then(e=>{let t=Array.isArray(e)?e:e.keys||[];x(t),t.length>0&&h(t[0].id),f(!1)}).catch(()=>f(!1))},[]);let L=(0,s.useCallback)(async()=>{if(p)try{let e=await fetch(`/api/usage/budget?apiKeyId=${p}`);if(e.ok){let t=await e.json();b(t),t.dailyLimitUsd&&w(e=>({...e,dailyLimitUsd:String(t.dailyLimitUsd)})),t.monthlyLimitUsd&&w(e=>({...e,monthlyLimitUsd:String(t.monthlyLimitUsd)})),t.warningThreshold&&w(e=>({...e,warningThreshold:String(t.warningThreshold)}))}}catch{}},[p]);(0,s.useEffect)(()=>{L()},[L]);let k=async()=>{v(!0);try{(await fetch("/api/usage/budget",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({apiKeyId:p,dailyLimitUsd:N.dailyLimitUsd?parseFloat(N.dailyLimitUsd):null,monthlyLimitUsd:N.monthlyLimitUsd?parseFloat(N.monthlyLimitUsd):null,warningThreshold:parseInt(N.warningThreshold)||80})})).ok?(C.success(e("budgetSaved")),await L()):C.error(e("budgetSaveFailed"))}catch{C.error(e("budgetSaveFailed"))}finally{v(!1)}};if(y)return(0,t.jsxs)("div",{className:"flex items-center gap-2 text-text-muted p-8 animate-pulse",children:[(0,t.jsx)("span",{className:"material-symbols-outlined text-[20px]","aria-hidden":"true",children:"account_balance_wallet"}),e("loadingBudgetData")]});if(0===u.length)return(0,t.jsx)(o.EmptyState,{icon:"vpn_key",title:e("noApiKeysTitle"),description:e("noApiKeysDescription")});let T=g?.dailyLimitUsd||parseFloat(N.dailyLimitUsd)||0,U=g?.monthlyLimitUsd||parseFloat(N.monthlyLimitUsd)||0,P=g?.totalCostToday||0,$=g?.totalCostMonth||0,D=(parseInt(N.warningThreshold)||80)/100;return(0,t.jsxs)("div",{className:"flex flex-col gap-6",children:[(0,t.jsxs)(r.Card,{className:"p-6",children:[(0,t.jsxs)("div",{className:"flex items-center gap-3 mb-4",children:[(0,t.jsx)("div",{className:"p-2 rounded-lg bg-emerald-500/10 text-emerald-500",children:(0,t.jsx)("span",{className:"material-symbols-outlined text-[20px]","aria-hidden":"true",children:"account_balance_wallet"})}),(0,t.jsx)("h3",{className:"text-lg font-semibold",children:e("budgetManagement")})]}),(0,t.jsxs)("div",{className:"mb-4",children:[(0,t.jsx)("label",{className:"text-sm text-text-muted mb-1 block",children:e("apiKey")}),(0,t.jsx)("select",{value:p||"",onChange:e=>h(e.target.value),className:"w-full md:w-auto px-3 py-2 rounded-lg border border-border/50 bg-surface/30 text-text-main text-sm focus:outline-none focus:ring-1 focus:ring-primary",children:u.map(e=>(0,t.jsxs)("option",{value:e.id,children:[e.name||e.id," ",e.provider?`(${e.provider})`:""]},e.id))})]}),(0,t.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4 mb-6",children:[(0,t.jsxs)("div",{className:"p-4 rounded-lg border border-border/30 bg-surface/20",children:[(0,t.jsx)("p",{className:"text-sm text-text-muted mb-2",children:e("todaysSpend")}),(0,t.jsx)("p",{className:"text-2xl font-bold text-text-main",children:S(P)}),T>0&&(0,t.jsx)(m,{value:P,max:T,warningAt:D,formatCurrency:S})]}),(0,t.jsxs)("div",{className:"p-4 rounded-lg border border-border/30 bg-surface/20",children:[(0,t.jsx)("p",{className:"text-sm text-text-muted mb-2",children:e("thisMonth")}),(0,t.jsx)("p",{className:"text-2xl font-bold text-text-main",children:S($)}),U>0&&(0,t.jsx)(m,{value:$,max:U,warningAt:D,formatCurrency:S})]})]}),(0,t.jsxs)("div",{className:"border-t border-border/30 pt-4",children:[(0,t.jsx)("p",{className:"text-sm font-medium mb-3",children:e("setLimits")}),(0,t.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4 mb-4",children:[(0,t.jsx)(d.Input,{label:e("dailyLimitUsd"),type:"number",step:"0.01",min:"0",placeholder:e("dailyLimitPlaceholder"),value:N.dailyLimitUsd,onChange:e=>w({...N,dailyLimitUsd:e.target.value})}),(0,t.jsx)(d.Input,{label:e("monthlyLimitUsd"),type:"number",step:"0.01",min:"0",placeholder:e("monthlyLimitPlaceholder"),value:N.monthlyLimitUsd,onChange:e=>w({...N,monthlyLimitUsd:e.target.value})}),(0,t.jsx)(d.Input,{label:e("warningThresholdPercent"),type:"number",min:"1",max:"100",placeholder:e("warningThresholdPlaceholder"),value:N.warningThreshold,onChange:e=>w({...N,warningThreshold:e.target.value})})]}),(0,t.jsx)(n.Button,{variant:"primary",onClick:k,loading:j,children:e("saveLimits")})]})]}),g?.budgetCheck&&(0,t.jsx)(r.Card,{className:"p-4",children:(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("span",{className:"material-symbols-outlined text-[20px]","aria-hidden":"true",style:{color:g.budgetCheck.allowed?"#22c55e":"#ef4444"},children:g.budgetCheck.allowed?"check_circle":"block"}),(0,t.jsx)("span",{className:"text-sm",children:g.budgetCheck.allowed?e("budgetOk",{remaining:S(g.budgetCheck.remaining||0)}):e("budgetExceeded")})]})})]})}let x=["input","output","cached","reasoning","cache_creation"],p={input:"input",output:"output",cached:"cached",reasoning:"reasoning",cache_creation:"cacheCreation"};function h(){let[e,a]=(0,s.useState)({}),[i,n]=(0,s.useState)({}),[d,o]=(0,s.useState)(!0),[c,m]=(0,s.useState)(!1),[u,x]=(0,s.useState)(""),[p,h]=(0,s.useState)(null),[b,y]=(0,s.useState)(new Set),[f,j]=(0,s.useState)(""),[v,N]=(0,s.useState)(new Set),w=(0,l.useTranslations)("settings");(0,s.useEffect)(()=>{C()},[]);let C=async()=>{o(!0);try{let[e,t]=await Promise.all([fetch("/api/pricing/models"),fetch("/api/pricing")]);e.ok&&a(await e.json()),t.ok&&n(await t.json())}catch(e){console.error("Failed to load pricing data:",e)}finally{o(!1)}},S=(0,s.useMemo)(()=>Object.entries(e).map(([e,t])=>({alias:e,...t,pricedModels:i[e]?Object.keys(i[e]).length:0})).sort((e,t)=>t.modelCount-e.modelCount),[e,i]),L=(0,s.useMemo)(()=>{if(!f.trim())return S;let e=f.toLowerCase();return S.filter(t=>t.alias.toLowerCase().includes(e)||t.id.toLowerCase().includes(e)||t.models.some(t=>t.id.toLowerCase().includes(e)||t.name.toLowerCase().includes(e)))},[S,f]),k=(0,s.useMemo)(()=>{let e=S.reduce((e,t)=>e+t.modelCount,0),t=Object.values(i).reduce((e,t)=>e+Object.keys(t).length,0);return{providers:S.length,totalModels:e,pricedCount:t}},[S,i]),T=(0,s.useCallback)(e=>{y(t=>{let s=new Set(t);return s.has(e)?s.delete(e):s.add(e),s})},[]),U=(0,s.useCallback)((e,t,s,a)=>{let i=parseFloat(a);isNaN(i)||i<0||(n(a=>{let l={...a};return l[e]||(l[e]={}),l[e][t]||(l[e][t]={input:0,output:0,cached:0,reasoning:0,cache_creation:0}),l[e][t]={...l[e][t],[s]:i},l}),N(t=>new Set(t).add(e)))},[]),P=(0,s.useCallback)(async e=>{m(!0),x("");try{let t=i[e]||{},s=await fetch("/api/pricing",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({[e]:t})});if(s.ok)x(`✅ ${e.toUpperCase()} ${w("saved")}`),N(t=>{let s=new Set(t);return s.delete(e),s}),setTimeout(()=>x(""),3e3);else{let e=await s.json();x(`❌ ${w("errorOccurred")}: ${e.error}`)}}catch(e){x(`❌ ${w("saveFailed")}: ${e.message}`)}finally{m(!1)}},[i,w]),$=(0,s.useCallback)(async e=>{if(confirm(w("resetPricingConfirm",{provider:e.toUpperCase()})))try{let t=await fetch(`/api/pricing?provider=${e}`,{method:"DELETE"});if(t.ok){let s=await t.json();n(s),x(`🔄 ${e.toUpperCase()} ${w("resetDefaults")}`),N(t=>{let s=new Set(t);return s.delete(e),s}),setTimeout(()=>x(""),3e3)}}catch(e){x(`❌ ${w("resetFailed")}: ${e.message}`)}},[w]),D=(0,s.useCallback)(e=>{h(t=>t===e?null:e)},[]),F=(0,s.useMemo)(()=>p?L.filter(e=>e.alias===p):L,[L,p]);return d?(0,t.jsx)("div",{className:"flex items-center justify-center py-16",children:(0,t.jsx)("div",{className:"text-text-muted animate-pulse",children:w("loadingPricing")})}):(0,t.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,t.jsxs)("div",{className:"flex items-start justify-between flex-wrap gap-4",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("h2",{className:"text-xl font-bold",children:w("modelPricing")}),(0,t.jsx)("p",{className:"text-text-muted text-sm mt-1",children:w("modelPricingDesc")})]}),(0,t.jsxs)("div",{className:"flex gap-3 text-sm",children:[(0,t.jsxs)("div",{className:"bg-bg-subtle rounded-lg px-3 py-2 text-center",children:[(0,t.jsx)("div",{className:"text-text-muted text-xs font-semibold",children:w("providers")}),(0,t.jsx)("div",{className:"text-lg font-bold",children:k.providers})]}),(0,t.jsxs)("div",{className:"bg-bg-subtle rounded-lg px-3 py-2 text-center",children:[(0,t.jsx)("div",{className:"text-text-muted text-xs font-semibold",children:w("registry")}),(0,t.jsx)("div",{className:"text-lg font-bold",children:k.totalModels})]}),(0,t.jsxs)("div",{className:"bg-bg-subtle rounded-lg px-3 py-2 text-center",children:[(0,t.jsx)("div",{className:"text-text-muted text-xs font-semibold",children:w("priced")}),(0,t.jsx)("div",{className:"text-lg font-bold text-success",children:k.pricedCount})]})]})]}),u&&(0,t.jsx)("div",{className:"px-3 py-2 rounded-lg bg-bg-subtle border border-border text-sm",children:u}),(0,t.jsxs)("div",{className:"flex gap-3 items-center flex-wrap",children:[(0,t.jsxs)("div",{className:"relative flex-1 min-w-[200px]",children:[(0,t.jsx)("span",{className:"material-symbols-outlined absolute left-3 top-1/2 -translate-y-1/2 text-text-muted text-lg",children:"search"}),(0,t.jsx)("input",{type:"text",placeholder:w("searchProvidersModels"),value:f,onChange:e=>j(e.target.value),className:"w-full pl-10 pr-3 py-2 bg-bg-base border border-border rounded-lg focus:outline-none focus:border-primary text-sm"})]}),p&&(0,t.jsxs)("button",{onClick:()=>h(null),className:"px-3 py-2 text-xs bg-primary/10 text-primary border border-primary/20 rounded-lg hover:bg-primary/20 transition-colors flex items-center gap-1",children:[(0,t.jsx)("span",{className:"material-symbols-outlined text-sm",children:"close"}),p.toUpperCase()," — ",w("showAll")]})]}),(0,t.jsx)("div",{className:"flex flex-wrap gap-1.5",children:S.map(e=>(0,t.jsxs)("button",{onClick:()=>D(e.alias),className:`px-2.5 py-1 rounded-md text-xs font-medium transition-all ${p===e.alias?"bg-primary text-white shadow-sm":v.has(e.alias)?"bg-yellow-500/15 text-yellow-400 border border-yellow-500/30":"bg-bg-subtle text-text-muted hover:bg-bg-hover border border-transparent"}`,children:[e.alias.toUpperCase()," ",(0,t.jsxs)("span",{className:"opacity-60",children:["(",e.modelCount,")"]})]},e.alias))}),(0,t.jsxs)("div",{className:"flex flex-col gap-2",children:[F.map(e=>(0,t.jsx)(g,{provider:e,pricingData:i[e.alias]||{},isExpanded:b.has(e.alias),isEdited:v.has(e.alias),onToggle:()=>T(e.alias),onPricingChange:(t,s,a)=>U(e.alias,t,s,a),onSave:()=>P(e.alias),onReset:()=>$(e.alias),saving:c},e.alias)),0===F.length&&(0,t.jsx)("div",{className:"text-center py-12 text-text-muted",children:w("noProvidersMatch")})]}),(0,t.jsxs)(r.Card,{className:"p-4 mt-2",children:[(0,t.jsxs)("h3",{className:"text-sm font-semibold mb-2",children:[(0,t.jsx)("span",{className:"material-symbols-outlined text-sm align-middle mr-1",children:"info"}),w("howPricingWorks")]}),(0,t.jsxs)("div",{className:"text-xs text-text-muted space-y-1",children:[(0,t.jsxs)("p",{children:[w("pricingDescInput")," • ",w("pricingDescOutput")," • ",w("pricingDescCached")," •"," ",w("pricingDescReasoning")," • ",w("pricingDescCacheWrite")]}),(0,t.jsx)("p",{children:w("pricingDescFormula")})]})]})]})}function g({provider:e,pricingData:s,isExpanded:a,isEdited:i,onToggle:r,onPricingChange:n,onSave:d,onReset:o,saving:c}){let m=(0,l.useTranslations)("settings"),u=(0,l.useTranslations)(),h=Object.keys(s).length,g="oauth"===e.authType?u("providers.oauthLabel"):"apikey"===e.authType?u("providers.apiKeyLabel"):e.authType;return(0,t.jsxs)("div",{className:`border rounded-lg overflow-hidden transition-colors ${i?"border-yellow-500/40 bg-yellow-500/5":"border-border"}`,children:[(0,t.jsxs)("button",{onClick:r,className:"w-full flex items-center justify-between px-4 py-3 hover:bg-bg-hover/50 transition-colors text-left",children:[(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[(0,t.jsx)("span",{className:`material-symbols-outlined text-lg transition-transform ${a?"rotate-90":""}`,children:"chevron_right"}),(0,t.jsxs)("div",{children:[(0,t.jsx)("span",{className:"font-semibold text-sm",children:e.id.charAt(0).toUpperCase()+e.id.slice(1)}),(0,t.jsxs)("span",{className:"text-text-muted text-xs ml-2",children:["(",e.alias.toUpperCase(),")"]})]}),(0,t.jsx)("span",{className:"px-1.5 py-0.5 bg-bg-subtle text-text-muted text-[10px] rounded uppercase font-semibold",children:g}),(0,t.jsx)("span",{className:"px-1.5 py-0.5 bg-bg-subtle text-text-muted text-[10px] rounded uppercase font-semibold",children:e.format})]}),(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[i&&(0,t.jsx)("span",{className:"text-yellow-500 text-xs font-medium",children:m("unsaved")}),(0,t.jsxs)("span",{className:"text-text-muted text-xs",children:[h,"/",e.modelCount," ",m("withPricing")]}),(0,t.jsx)("div",{className:"w-16 h-1.5 bg-bg-subtle rounded-full overflow-hidden",children:(0,t.jsx)("div",{className:"h-full bg-primary rounded-full transition-all",style:{width:`${e.modelCount>0?Math.round(h/e.modelCount*100):0}%`}})})]})]}),a&&(0,t.jsxs)("div",{className:"border-t border-border",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between px-4 py-2 bg-bg-subtle/50",children:[(0,t.jsxs)("span",{className:"text-xs text-text-muted",children:[e.modelCount," ",m("models")," • ",h," ",m("withPricing")]}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("button",{onClick:e=>{e.stopPropagation(),o()},className:"px-2.5 py-1 text-[11px] text-red-400 hover:bg-red-500/10 rounded border border-red-500/20 transition-colors",children:m("resetDefaults")}),(0,t.jsx)("button",{onClick:e=>{e.stopPropagation(),d()},disabled:c||!i,className:"px-2.5 py-1 text-[11px] bg-primary text-white rounded hover:bg-primary/90 transition-colors disabled:opacity-40",children:c?m("saving"):m("saveProvider")})]})]}),(0,t.jsx)("div",{className:"overflow-x-auto",children:(0,t.jsxs)("table",{className:"w-full text-sm",children:[(0,t.jsx)("thead",{className:"text-[11px] text-text-muted uppercase bg-bg-subtle/30",children:(0,t.jsxs)("tr",{children:[(0,t.jsx)("th",{className:"px-4 py-2 text-left font-semibold",children:m("model")}),x.map(e=>(0,t.jsx)("th",{className:"px-2 py-2 text-right font-semibold w-24",children:m(p[e])},e))]})}),(0,t.jsx)("tbody",{className:"divide-y divide-border/50",children:e.models.map(e=>(0,t.jsx)(b,{model:e,pricing:s[e.id],onPricingChange:(t,s)=>n(e.id,t,s)},e.id))})]})})]})]})}function b({model:e,pricing:s,onPricingChange:a}){let i=(0,l.useTranslations)("settings"),r=s&&Object.values(s).some(e=>e>0);return(0,t.jsxs)("tr",{className:"hover:bg-bg-hover/30 group",children:[(0,t.jsx)("td",{className:"px-4 py-1.5",children:(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("span",{className:`w-1.5 h-1.5 rounded-full ${r?"bg-success":"bg-text-muted/30"}`}),(0,t.jsx)("span",{className:"font-medium text-xs",children:e.name}),e.custom&&(0,t.jsx)("span",{className:"px-1 py-0.5 text-[8px] font-bold bg-blue-500/15 text-blue-400 border border-blue-500/20 rounded uppercase",children:i("custom")}),(0,t.jsx)("span",{className:"text-text-muted text-[10px] opacity-0 group-hover:opacity-100 transition-opacity",children:e.id})]})}),x.map(e=>(0,t.jsx)("td",{className:"px-2 py-1.5",children:(0,t.jsx)("input",{type:"number",step:"0.01",min:"0",value:s?.[e]||0,onChange:t=>a(e,t.target.value),className:"w-full px-2 py-1 text-right text-xs bg-transparent border border-transparent hover:border-border focus:border-primary focus:bg-bg-base rounded transition-colors outline-none tabular-nums"})},e))]})}function y(){let[e,i]=(0,s.useState)("budget"),r=(0,l.useTranslations)("costs"),n=(0,l.useTranslations)("settings");return(0,t.jsxs)("div",{className:"flex flex-col gap-6",children:[(0,t.jsx)(a.SegmentedControl,{options:[{value:"budget",label:r("budget")},{value:"pricing",label:n("pricing")}],value:e,onChange:i}),"budget"===e&&(0,t.jsx)(u,{}),"pricing"===e&&(0,t.jsx)(h,{})]})}e.s(["default",()=>y],979765)}]);