@yina-npm/openrouterx 0.4.52 → 0.4.53
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.
- package/README.md +93 -1245
- package/app/.next/BUILD_ID +1 -1
- package/app/.next/app-path-routes-manifest.json +2 -2
- package/app/.next/build-manifest.json +2 -2
- package/app/.next/server/app/(dashboard)/dashboard/admin/keys/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/admin/users/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/basic-chat/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/cli-tools/[toolId]/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/cli-tools/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/combos/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/console-log/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/endpoint/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/focus-ui/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/media-providers/[kind]/[id]/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/media-providers/[kind]/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/media-providers/combo/[id]/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/media-providers/web/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/mitm/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/network-analysis/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/profile/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/providers/[id]/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/providers/new/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/providers/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/proxy-pools/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/quota/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/skills/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/translator/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/usage/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/user/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/_global-error.html +1 -1
- package/app/.next/server/app/_global-error.rsc +1 -1
- package/app/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/app/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
- package/app/.next/server/app/_global-error.segments/_global-error.segment.rsc +1 -1
- package/app/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
- package/app/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
- package/app/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/app/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/_not-found.html +1 -1
- package/app/.next/server/app/_not-found.rsc +4 -4
- package/app/.next/server/app/_not-found.segments/_full.segment.rsc +4 -4
- package/app/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
- package/app/.next/server/app/_not-found.segments/_index.segment.rsc +4 -4
- package/app/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
- package/app/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
- package/app/.next/server/app/_not-found.segments/_tree.segment.rsc +2 -2
- package/app/.next/server/app/api/keys/[id]/route.js +1 -1
- package/app/.next/server/app/api/models/route.js +1 -1
- package/app/.next/server/app/api/models/test/route.js +1 -1
- package/app/.next/server/app/api/providers/[id]/test-models/route.js +1 -1
- package/app/.next/server/app/api/providers/route.js +1 -1
- package/app/.next/server/app/api/translator/console-logs/route.js +1 -1
- package/app/.next/server/app/api/translator/console-logs/stream/route.js +1 -1
- package/app/.next/server/app/api/users/[id]/route.js +1 -1
- package/app/.next/server/app/api/users/route.js +1 -1
- package/app/.next/server/app/api/version/route.js +1 -1
- package/app/.next/server/app/api/version/shutdown/route.js +1 -1
- package/app/.next/server/app/api/version/update/route.js +1 -1
- package/app/.next/server/app/callback/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/callback.html +1 -1
- package/app/.next/server/app/callback.rsc +4 -4
- package/app/.next/server/app/callback.segments/_full.segment.rsc +4 -4
- package/app/.next/server/app/callback.segments/_head.segment.rsc +1 -1
- package/app/.next/server/app/callback.segments/_index.segment.rsc +4 -4
- package/app/.next/server/app/callback.segments/_tree.segment.rsc +2 -2
- package/app/.next/server/app/callback.segments/callback/__PAGE__.segment.rsc +1 -1
- package/app/.next/server/app/callback.segments/callback.segment.rsc +1 -1
- package/app/.next/server/app/dashboard/settings/pricing/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/dashboard/settings/pricing.html +1 -1
- package/app/.next/server/app/dashboard/settings/pricing.rsc +4 -4
- package/app/.next/server/app/dashboard/settings/pricing.segments/_full.segment.rsc +4 -4
- package/app/.next/server/app/dashboard/settings/pricing.segments/_head.segment.rsc +1 -1
- package/app/.next/server/app/dashboard/settings/pricing.segments/_index.segment.rsc +4 -4
- package/app/.next/server/app/dashboard/settings/pricing.segments/_tree.segment.rsc +2 -2
- package/app/.next/server/app/dashboard/settings/pricing.segments/dashboard/settings/pricing/__PAGE__.segment.rsc +1 -1
- package/app/.next/server/app/dashboard/settings/pricing.segments/dashboard/settings/pricing.segment.rsc +1 -1
- package/app/.next/server/app/dashboard/settings/pricing.segments/dashboard/settings.segment.rsc +1 -1
- package/app/.next/server/app/dashboard/settings/pricing.segments/dashboard.segment.rsc +1 -1
- package/app/.next/server/app/index.html +1 -1
- package/app/.next/server/app/index.rsc +4 -4
- package/app/.next/server/app/index.segments/__PAGE__.segment.rsc +1 -1
- package/app/.next/server/app/index.segments/_full.segment.rsc +4 -4
- package/app/.next/server/app/index.segments/_head.segment.rsc +1 -1
- package/app/.next/server/app/index.segments/_index.segment.rsc +4 -4
- package/app/.next/server/app/index.segments/_tree.segment.rsc +2 -2
- package/app/.next/server/app/landing/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/landing.html +1 -1
- package/app/.next/server/app/landing.rsc +4 -4
- package/app/.next/server/app/landing.segments/_full.segment.rsc +4 -4
- package/app/.next/server/app/landing.segments/_head.segment.rsc +1 -1
- package/app/.next/server/app/landing.segments/_index.segment.rsc +4 -4
- package/app/.next/server/app/landing.segments/_tree.segment.rsc +2 -2
- package/app/.next/server/app/landing.segments/landing/__PAGE__.segment.rsc +1 -1
- package/app/.next/server/app/landing.segments/landing.segment.rsc +1 -1
- package/app/.next/server/app/login/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/login.html +1 -1
- package/app/.next/server/app/login.rsc +5 -5
- package/app/.next/server/app/login.segments/_full.segment.rsc +5 -5
- package/app/.next/server/app/login.segments/_head.segment.rsc +1 -1
- package/app/.next/server/app/login.segments/_index.segment.rsc +4 -4
- package/app/.next/server/app/login.segments/_tree.segment.rsc +2 -2
- package/app/.next/server/app/login.segments/login/__PAGE__.segment.rsc +2 -2
- package/app/.next/server/app/login.segments/login.segment.rsc +1 -1
- package/app/.next/server/app/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app-paths-manifest.json +2 -2
- package/app/.next/server/chunks/1350.js +1 -1
- package/app/.next/server/chunks/3110.js +1 -1
- package/app/.next/server/chunks/3493.js +1 -1
- package/app/.next/server/chunks/412.js +1 -1
- package/app/.next/server/chunks/7177.js +1 -1
- package/app/.next/server/chunks/7595.js +1 -1
- package/app/.next/server/chunks/7930.js +5 -2
- package/app/.next/server/chunks/8760.js +1 -1
- package/app/.next/server/chunks/9489.js +1 -1
- package/app/.next/server/chunks/9718.js +1 -1
- package/app/.next/server/middleware-build-manifest.js +1 -1
- package/app/.next/server/middleware.js +1 -1
- package/app/.next/server/pages/404.html +1 -1
- package/app/.next/server/pages/500.html +1 -1
- package/app/.next/static/chunks/1321-682ad944ed69404c.js +1 -0
- package/app/.next/static/chunks/4072-fdb34c3bf82582e6.js +6 -0
- package/app/.next/static/chunks/{5095-c2bb7e2fc99ab8c3.js → 5095-47fe70cd930f3c59.js} +2 -2
- package/app/.next/static/chunks/{5497-bebd4378b1048022.js → 5497-b59396fb56e7b9b1.js} +1 -1
- package/app/.next/static/css/{402ee8646e1afa89.css → 9b92fc8235e99d1e.css} +1 -1
- package/app/package.json +2 -2
- package/app/public/i18n/literals/ar.json +25 -1
- package/app/public/i18n/literals/bn.json +25 -1
- package/app/public/i18n/literals/cs.json +25 -1
- package/app/public/i18n/literals/da.json +25 -1
- package/app/public/i18n/literals/de.json +25 -1
- package/app/public/i18n/literals/el.json +25 -1
- package/app/public/i18n/literals/es.json +25 -1
- package/app/public/i18n/literals/fi.json +25 -1
- package/app/public/i18n/literals/fr.json +25 -1
- package/app/public/i18n/literals/he.json +25 -1
- package/app/public/i18n/literals/hi.json +25 -1
- package/app/public/i18n/literals/hu.json +25 -1
- package/app/public/i18n/literals/id.json +25 -1
- package/app/public/i18n/literals/it.json +25 -1
- package/app/public/i18n/literals/ja.json +25 -1
- package/app/public/i18n/literals/ko.json +25 -1
- package/app/public/i18n/literals/nl.json +25 -1
- package/app/public/i18n/literals/no.json +25 -1
- package/app/public/i18n/literals/pl.json +25 -1
- package/app/public/i18n/literals/pt-BR.json +25 -1
- package/app/public/i18n/literals/pt-PT.json +25 -1
- package/app/public/i18n/literals/ro.json +25 -1
- package/app/public/i18n/literals/ru.json +25 -1
- package/app/public/i18n/literals/sv.json +25 -1
- package/app/public/i18n/literals/th.json +25 -1
- package/app/public/i18n/literals/tl.json +25 -1
- package/app/public/i18n/literals/tr.json +25 -1
- package/app/public/i18n/literals/uk.json +25 -1
- package/app/public/i18n/literals/ur.json +25 -1
- package/app/public/i18n/literals/vi.json +25 -1
- package/app/public/i18n/literals/zh-CN.json +26 -1
- package/app/public/i18n/literals/zh-TW.json +25 -1
- package/package.json +2 -2
- package/app/.next/static/chunks/1321-621ed3470478397e.js +0 -1
- package/app/.next/static/chunks/4072-cc92fb1222a2752b.js +0 -3
- /package/app/.next/static/{Q5oB2dEL7XeWBhjwqT_vo → 4G6rOhJtfkDwKINMqIIf1}/_buildManifest.js +0 -0
- /package/app/.next/static/{Q5oB2dEL7XeWBhjwqT_vo → 4G6rOhJtfkDwKINMqIIf1}/_ssgManifest.js +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";exports.id=412,exports.ids=[412],exports.modules={267:(a,b,c)=>{c.d(b,{default:()=>j});var d=c(48249),e=c(67484),f=c(74429),g=c(51126),h=c(99258);let i=a=>({en:{name:"English",flag:"\uD83C\uDDFA\uD83C\uDDF8"},vi:{name:"Tiếng Việt",flag:"\uD83C\uDDFB\uD83C\uDDF3"},"zh-CN":{name:"简体中文",flag:"\uD83C\uDDE8\uD83C\uDDF3"},"zh-TW":{name:"繁體中文",flag:"\uD83C\uDDF9\uD83C\uDDFC"},ja:{name:"日本語",flag:"\uD83C\uDDEF\uD83C\uDDF5"},"pt-BR":{name:"Portugu\xeas (Brasil)",flag:"\uD83C\uDDE7\uD83C\uDDF7"},"pt-PT":{name:"Portugu\xeas (Portugal)",flag:"\uD83C\uDDF5\uD83C\uDDF9"},ko:{name:"한국어",flag:"\uD83C\uDDF0\uD83C\uDDF7"},es:{name:"Espa\xf1ol",flag:"\uD83C\uDDEA\uD83C\uDDF8"},de:{name:"Deutsch",flag:"\uD83C\uDDE9\uD83C\uDDEA"},fr:{name:"Fran\xe7ais",flag:"\uD83C\uDDEB\uD83C\uDDF7"},he:{name:"עברית",flag:"\uD83C\uDDEE\uD83C\uDDF1"},ar:{name:"العربية",flag:"\uD83C\uDDF8\uD83C\uDDE6"},ru:{name:"Русский",flag:"\uD83C\uDDF7\uD83C\uDDFA"},pl:{name:"Polski",flag:"\uD83C\uDDF5\uD83C\uDDF1"},cs:{name:"Čeština",flag:"\uD83C\uDDE8\uD83C\uDDFF"},nl:{name:"Nederlands",flag:"\uD83C\uDDF3\uD83C\uDDF1"},tr:{name:"T\xfcrk\xe7e",flag:"\uD83C\uDDF9\uD83C\uDDF7"},uk:{name:"Українська",flag:"\uD83C\uDDFA\uD83C\uDDE6"},tl:{name:"Tagalog",flag:"\uD83C\uDDF5\uD83C\uDDED"},id:{name:"Indonesia",flag:"\uD83C\uDDEE\uD83C\uDDE9"},th:{name:"ไทย",flag:"\uD83C\uDDF9\uD83C\uDDED"},hi:{name:"हिन्दी",flag:"\uD83C\uDDEE\uD83C\uDDF3"},bn:{name:"বাংলা",flag:"\uD83C\uDDE7\uD83C\uDDE9"},ur:{name:"اردو",flag:"\uD83C\uDDF5\uD83C\uDDF0"},ro:{name:"Rom\xe2nă",flag:"\uD83C\uDDF7\uD83C\uDDF4"},sv:{name:"Svenska",flag:"\uD83C\uDDF8\uD83C\uDDEA"},it:{name:"Italiano",flag:"\uD83C\uDDEE\uD83C\uDDF9"},el:{name:"Ελληνικά",flag:"\uD83C\uDDEC\uD83C\uDDF7"},hu:{name:"Magyar",flag:"\uD83C\uDDED\uD83C\uDDFA"},fi:{name:"Suomi",flag:"\uD83C\uDDEB\uD83C\uDDEE"},da:{name:"Dansk",flag:"\uD83C\uDDE9\uD83C\uDDF0"},no:{name:"Norsk",flag:"\uD83C\uDDF3\uD83C\uDDF4"}})[a]||{name:a,flag:"\uD83C\uDF10"};function j({className:a="",isOpen:b,onClose:c,hideTrigger:k=!1}){let[l,m]=(0,e.useState)("en"),[n,o]=(0,e.useState)(!1),[p,q]=(0,e.useState)(!1),r=(0,e.useRef)(null),s="boolean"==typeof b,t=s?b:p,u=a=>{s?!a&&c&&c():q(a)},v=async a=>{if(a!==l&&!n){o(!0),u(!1);try{await fetch("/api/locale",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({locale:a})}),await (0,h.wn)(),m(a)}catch(a){console.error("Failed to set locale:",a)}finally{o(!1)}}};return(0,d.jsxs)("div",{className:a,children:[!k&&(0,d.jsxs)("button",{onClick:()=>u(!t),disabled:n,className:"flex items-center gap-2 px-3 py-2 rounded-lg text-text-muted hover:text-text-main hover:bg-surface/60 transition-colors",title:"Language","data-i18n-skip":"true",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[20px]",children:"language"}),(0,d.jsx)("span",{className:"text-sm font-medium",children:i(l).name}),(0,d.jsx)("span",{className:"text-lg",children:i(l).flag})]}),t&&(0,f.createPortal)((0,d.jsxs)("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4","data-i18n-skip":"true",children:[(0,d.jsx)("div",{className:"absolute inset-0 bg-black/30 backdrop-blur-sm",onClick:()=>u(!1)}),(0,d.jsxs)("div",{ref:r,className:"relative w-full bg-surface border border-black/10 dark:border-white/10 rounded-xl shadow-2xl animate-in fade-in zoom-in-95 duration-200 max-w-2xl flex flex-col max-h-[80vh]",children:[(0,d.jsxs)("div",{className:"flex items-center justify-between p-3 border-b border-black/5 dark:border-white/5",children:[(0,d.jsx)("h2",{className:"text-lg font-semibold text-text-main",children:"Select Language"}),(0,d.jsx)("button",{onClick:()=>u(!1),className:"p-1.5 rounded-lg text-text-muted hover:bg-black/5 dark:hover:bg-white/5 transition-colors","aria-label":"Close",children:(0,d.jsx)("span",{className:"material-symbols-outlined text-[20px]",children:"close"})})]}),(0,d.jsx)("div",{className:"p-6 overflow-y-auto flex-1",children:(0,d.jsx)("div",{className:"grid grid-cols-[repeat(auto-fill,minmax(100px,1fr))] gap-2",children:g.YZ.map(a=>{let b=l===a,c=i(a);return(0,d.jsxs)("button",{onClick:()=>v(a),disabled:n,className:`flex flex-col items-center justify-start gap-1 px-2 py-3 rounded-lg text-xs font-medium transition-colors w-full ${b?"bg-primary/15 text-primary ring-2 ring-primary":"text-text-main hover:bg-black/5 dark:hover:bg-white/5"} ${n?"opacity-70 cursor-wait":""}`,title:c.name,children:[(0,d.jsx)("span",{className:"text-2xl",children:c.flag}),(0,d.jsx)("span",{className:"text-center leading-tight line-clamp-2 h-8 flex items-center",children:c.name}),b&&(0,d.jsx)("span",{className:"material-symbols-outlined text-sm",children:"check"})]},a)})})})]})]}),document.body)]})}},3236:(a,b,c)=>{c.d(b,{default:()=>p});var d=c(48249),e=c(67484),f=c(19099),g=c(49885),h=c.n(g);c(51126);var i=c(42118),j=c(37900),k=c(11229),l=c(97564),m=c(267);let n={en:{name:"English",flag:"\uD83C\uDDFA\uD83C\uDDF8"},vi:{name:"Tiếng Việt",flag:"\uD83C\uDDFB\uD83C\uDDF3"},"zh-CN":{name:"简体中文",flag:"\uD83C\uDDE8\uD83C\uDDF3"},"zh-TW":{name:"繁體中文",flag:"\uD83C\uDDF9\uD83C\uDDFC"},ja:{name:"日本語",flag:"\uD83C\uDDEF\uD83C\uDDF5"},"pt-BR":{name:"Portugu\xeas (BR)",flag:"\uD83C\uDDE7\uD83C\uDDF7"},"pt-PT":{name:"Portugu\xeas (PT)",flag:"\uD83C\uDDF5\uD83C\uDDF9"},ko:{name:"한국어",flag:"\uD83C\uDDF0\uD83C\uDDF7"},es:{name:"Espa\xf1ol",flag:"\uD83C\uDDEA\uD83C\uDDF8"},de:{name:"Deutsch",flag:"\uD83C\uDDE9\uD83C\uDDEA"},fr:{name:"Fran\xe7ais",flag:"\uD83C\uDDEB\uD83C\uDDF7"},he:{name:"עברית",flag:"\uD83C\uDDEE\uD83C\uDDF1"},ar:{name:"العربية",flag:"\uD83C\uDDF8\uD83C\uDDE6"},ru:{name:"Русский",flag:"\uD83C\uDDF7\uD83C\uDDFA"},pl:{name:"Polski",flag:"\uD83C\uDDF5\uD83C\uDDF1"},cs:{name:"Čeština",flag:"\uD83C\uDDE8\uD83C\uDDFF"},nl:{name:"Nederlands",flag:"\uD83C\uDDF3\uD83C\uDDF1"},tr:{name:"T\xfcrk\xe7e",flag:"\uD83C\uDDF9\uD83C\uDDF7"},uk:{name:"Українська",flag:"\uD83C\uDDFA\uD83C\uDDE6"},tl:{name:"Tagalog",flag:"\uD83C\uDDF5\uD83C\uDDED"},id:{name:"Indonesia",flag:"\uD83C\uDDEE\uD83C\uDDE9"},th:{name:"ไทย",flag:"\uD83C\uDDF9\uD83C\uDDED"},hi:{name:"हिन्दी",flag:"\uD83C\uDDEE\uD83C\uDDF3"},bn:{name:"বাংলা",flag:"\uD83C\uDDE7\uD83C\uDDE9"},ur:{name:"اردو",flag:"\uD83C\uDDF5\uD83C\uDDF0"},ro:{name:"Rom\xe2nă",flag:"\uD83C\uDDF7\uD83C\uDDF4"},sv:{name:"Svenska",flag:"\uD83C\uDDF8\uD83C\uDDEA"},it:{name:"Italiano",flag:"\uD83C\uDDEE\uD83C\uDDF9"},el:{name:"Ελληνικά",flag:"\uD83C\uDDEC\uD83C\uDDF7"},hu:{name:"Magyar",flag:"\uD83C\uDDED\uD83C\uDDFA"},fi:{name:"Suomi",flag:"\uD83C\uDDEB\uD83C\uDDEE"},da:{name:"Dansk",flag:"\uD83C\uDDE9\uD83C\uDDF0"},no:{name:"Norsk",flag:"\uD83C\uDDF3\uD83C\uDDF4"}};function o({icon:a,label:b,onClick:c,trailing:e,danger:f}){return(0,d.jsxs)("button",{onClick:c,className:`flex items-center gap-3 w-full px-4 py-2.5 text-sm transition-colors ${f?"text-red-500 hover:bg-red-500/10":"text-text-main hover:bg-black/5 dark:hover:bg-white/5"}`,children:[(0,d.jsx)("span",{className:`material-symbols-outlined text-[20px] ${f?"":"text-text-muted"}`,children:a}),(0,d.jsx)("span",{className:"flex-1 text-left",children:b}),e&&(0,d.jsx)("span",{className:"text-base",children:e})]})}function p({onLogout:a}){let[b,c]=(0,e.useState)(!1),[g,h]=(0,e.useState)(!1),[q,r]=(0,e.useState)(!1),[s,t]=(0,e.useState)(!1),[u,v]=(0,e.useState)("en"),w=(0,f.useRouter)(),{toggleTheme:x,isDark:y}=(0,i.D)(),{role:z}=(0,j.hd)(),[A,B]=(0,e.useState)(null),C=(0,e.useRef)(null),D="sub_user"===(A||z||null);return(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("div",{className:"relative",ref:C,children:[(0,d.jsx)("button",{onClick:()=>c(a=>!a),className:"flex items-center justify-center p-2 rounded-lg text-text-muted hover:text-text-main hover:bg-black/5 dark:hover:bg-white/5 transition-all",title:"Menu",children:(0,d.jsx)("span",{className:"material-symbols-outlined",children:"grid_view"})}),b&&(0,d.jsxs)("div",{className:"absolute right-0 top-full mt-2 w-60 bg-surface border border-black/10 dark:border-white/10 rounded-xl shadow-2xl z-50 animate-in fade-in zoom-in-95 duration-150 overflow-hidden py-1",children:[D&&(0,d.jsx)(o,{icon:"dashboard",label:"Dashboard",onClick:()=>{c(!1),w.push("/dashboard")}}),D&&(0,d.jsx)(o,{icon:"terminal",label:"CLI Tools",onClick:()=>{c(!1),w.push("/dashboard/cli-tools")}}),!D&&(0,d.jsx)(o,{icon:"history",label:"Change Log",onClick:()=>{c(!1),h(!0)}}),(0,d.jsx)(o,{icon:"language",label:n[u]?.name||u,trailing:n[u]?.flag||"\uD83C\uDF10",onClick:()=>{c(!1),t(!0)}}),!D&&(0,d.jsx)(o,{icon:y?"light_mode":"dark_mode",label:"Theme",onClick:()=>{x(),c(!1)}}),!D&&(0,d.jsx)(o,{icon:"computer",label:"Remote",onClick:()=>{c(!1),r(!0)}}),(0,d.jsx)(o,{icon:"logout",label:"Logout",danger:!0,onClick:()=>{c(!1),a()}})]})]}),(0,d.jsx)(k.default,{isOpen:g,onClose:()=>h(!1)}),(0,d.jsx)(l.A,{isOpen:q,onClose:()=>r(!1)}),(0,d.jsx)(m.default,{hideTrigger:!0,isOpen:s,onClose:()=>t(!1)})]})}o.propTypes={icon:h().string.isRequired,label:h().string.isRequired,onClick:h().func.isRequired,trailing:h().node,danger:h().bool},p.propTypes={onLogout:h().func.isRequired}},4770:(a,b,c)=>{c.d(b,{default:()=>f});var d=c(48249),e=c(71404);function f({label:a,options:b=[],children:c,value:g,onChange:h,placeholder:i="Select an option",error:j,hint:k,disabled:l=!1,required:m=!1,className:n,selectClassName:o,...p}){return(0,d.jsxs)("div",{className:(0,e.cn)("flex flex-col gap-1.5",n),children:[a&&(0,d.jsxs)("label",{className:"text-sm font-medium text-text-main",children:[a,m&&(0,d.jsx)("span",{className:"text-red-500 ml-1",children:"*"})]}),(0,d.jsxs)("div",{className:"relative",children:[(0,d.jsx)("select",{value:g,onChange:h,disabled:l,className:(0,e.cn)("w-full py-2.5 px-3 pr-10 text-sm text-text-main","bg-surface-2 border border-transparent rounded-[10px] appearance-none","focus:outline-none focus:ring-2 focus:ring-brand-500/30 focus:border-brand-500/40","transition-all duration-150 disabled:opacity-50 disabled:cursor-not-allowed","text-[16px] sm:text-sm",j&&"ring-1 ring-red-500 focus:ring-2 focus:ring-red-500/40 border-red-500/40",o),...p,children:c||(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("option",{value:"",disabled:!0,children:i}),b.map(a=>(0,d.jsx)("option",{value:a.value,children:a.label},a.value))]})}),(0,d.jsx)("div",{className:"absolute inset-y-0 right-0 flex items-center pr-3 pointer-events-none text-text-muted",children:(0,d.jsx)("span",{className:"material-symbols-outlined text-[20px]",children:"expand_more"})})]}),j&&(0,d.jsxs)("p",{className:"text-xs text-red-500 flex items-center gap-1",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"error"}),j]}),k&&!j&&(0,d.jsx)("p",{className:"text-xs text-text-muted",children:k})]})}},5291:(a,b,c)=>{c.d(b,{default:()=>k});var d=c(48249),e=c(67484),f=c(49885),g=c.n(f),h=c(79346),i=c(86209),j=c(56110);function k({isOpen:a,providerInfo:b,onSuccess:c,onClose:f}){let[g,l]=(0,e.useState)(null),[m,n]=(0,e.useState)(null),[o,p]=(0,e.useState)(null),q=(0,e.useCallback)((a,b)=>{"builder-id"===a?l("builder-id"):"idc"===a?(l("idc"),p(b)):"social"===a?(l("social"),n(b.provider)):"import"===a&&c?.()},[c]),r=()=>{l(null),n(null),p(null)};return g?"builder-id"===g||"idc"===g?(0,d.jsx)(h.default,{isOpen:a,provider:"kiro",providerInfo:b,onSuccess:()=>{l(null),p(null),c?.(),f?.()},onClose:r,idcConfig:o}):"social"===g&&m?(0,d.jsx)(j.default,{isOpen:a,provider:m,onSuccess:()=>{l(null),n(null),c?.(),f?.()},onClose:r}):null:(0,d.jsx)(i.default,{isOpen:a,onMethodSelect:q,onClose:f})}k.propTypes={isOpen:g().bool.isRequired,providerInfo:g().shape({name:g().string}),onSuccess:g().func,onClose:g().func.isRequired}},11229:(a,b,c)=>{c.d(b,{default:()=>j});var d=c(48249),e=c(67484),f=c(74429),g=c(49885),h=c.n(g),i=c(26921);function j({isOpen:a,onClose:b}){let[c,g]=(0,e.useState)(""),[h,i]=(0,e.useState)(!1),[k,l]=(0,e.useState)(""),m=(0,e.useRef)(null);return!a||"u"<typeof document?null:(0,f.createPortal)((0,d.jsxs)("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",children:[(0,d.jsx)("div",{className:"absolute inset-0 bg-black/30 backdrop-blur-sm",onClick:b}),(0,d.jsxs)("div",{ref:m,className:"relative w-full bg-surface border border-black/10 dark:border-white/10 rounded-xl shadow-2xl animate-in fade-in zoom-in-95 duration-200 max-w-3xl flex flex-col max-h-[85vh]",children:[(0,d.jsxs)("div",{className:"flex items-center justify-between p-3 border-b border-black/5 dark:border-white/5",children:[(0,d.jsx)("h2",{className:"text-lg font-semibold text-text-main",children:"Change Log"}),(0,d.jsx)("button",{onClick:b,className:"p-1.5 rounded-lg text-text-muted hover:bg-black/5 dark:hover:bg-white/5 transition-colors","aria-label":"Close",children:(0,d.jsx)("span",{className:"material-symbols-outlined text-[20px]",children:"close"})})]}),(0,d.jsxs)("div",{className:"p-6 overflow-y-auto flex-1",children:[h&&(0,d.jsxs)("div",{className:"flex items-center justify-center py-10 text-text-muted",children:[(0,d.jsx)("span",{className:"material-symbols-outlined animate-spin mr-2",children:"progress_activity"}),"Loading..."]}),k&&(0,d.jsxs)("div",{className:"text-red-500 py-4",children:["Failed to load changelog: ",k]}),!h&&!k&&c&&(0,d.jsx)("div",{className:"changelog-body text-text-main",dangerouslySetInnerHTML:{__html:c}})]})]})]}),document.body)}c(12020),i.xI.setOptions({gfm:!0,breaks:!0}),j.propTypes={isOpen:h().bool.isRequired,onClose:h().func.isRequired}},11633:(a,b,c)=>{c.d(b,{default:()=>g});var d=c(48249),e=c(17660);let f={mode:{label:"Mode",format:a=>a},defaultModel:{label:"Model",format:a=>a,mono:!0},baseUrl:{label:"Endpoint",format:a=>a,isLink:!0,mono:!0},costPerQuery:{label:"Cost / call",format:a=>0===a?"Free":`$${a.toFixed(4)}`},pricingUrl:{label:"Pricing",format:()=>"View pricing",isLink:!0},freeTier:{label:"Free tier",format:a=>a},freeMonthlyQuota:{label:"Free quota",format:a=>0===a?"—":a>=999999?"Unlimited":`${a.toLocaleString()} / mo`},searchTypes:{label:"Types",format:a=>a.join(", ")},formats:{label:"Formats",format:a=>a.join(", ")},maxMaxResults:{label:"Max results",format:a=>a},maxCharacters:{label:"Max chars",format:a=>a.toLocaleString()}};function g({config:a,provider:b,title:c="Provider Info"}){if(!a)return null;let h=Object.entries(f).filter(([b])=>void 0!==a[b]&&null!==a[b]&&""!==a[b]).map(([b,c])=>({key:b,label:c.label,value:c.format(a[b]),isLink:c.isLink,mono:c.mono,raw:a[b]})),i=b?.notice?.apiKeyUrl||b?.website,j=b?.notice?.text;return(0,d.jsxs)(e.default,{children:[(0,d.jsxs)("div",{className:"flex items-center justify-between mb-3",children:[(0,d.jsx)("h2",{className:"text-lg font-semibold",children:c}),i&&(0,d.jsxs)("a",{href:i,target:"_blank",rel:"noopener noreferrer",className:"text-xs text-primary hover:underline inline-flex items-center gap-1",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-sm",children:"open_in_new"}),"Get API Key"]})]}),(0,d.jsxs)("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-x-6 gap-y-2",children:[h.map(a=>(0,d.jsxs)("div",{className:"flex items-center gap-3 min-w-0",children:[(0,d.jsx)("span",{className:"text-xs text-text-muted w-28 shrink-0",children:a.label}),a.isLink?(0,d.jsx)("a",{href:a.raw,target:"_blank",rel:"noopener noreferrer",className:`text-sm text-primary hover:underline truncate ${a.mono?"font-mono":""}`,children:a.value}):(0,d.jsx)("span",{className:`text-sm text-text-main truncate ${a.mono?"font-mono":""}`,children:a.value})]},a.key)),j&&(0,d.jsxs)("div",{className:"flex items-start gap-3 min-w-0 sm:col-span-2",children:[(0,d.jsx)("span",{className:"text-xs text-text-muted w-28 shrink-0 mt-0.5",children:"Notice"}),(0,d.jsx)("span",{className:"text-sm text-text-main leading-relaxed",children:j})]})]})]})}},17660:(a,b,c)=>{c.d(b,{default:()=>f});var d=c(48249),e=c(71404);function f({children:a,title:b,subtitle:c,icon:g,action:h,padding:i="md",hover:j=!1,elev:k=!1,className:l,...m}){return(0,d.jsxs)("div",{className:(0,e.cn)("bg-surface border border-border-subtle",k?"rounded-[14px] shadow-[var(--shadow-elev)]":"rounded-[14px] shadow-[var(--shadow-soft)]",j&&"hover:shadow-[var(--shadow-warm)] hover:border-brand-500/30 transition-all cursor-pointer",{none:"",xs:"p-3",sm:"p-4",md:"p-6",lg:"p-8"}[i],l),...m,children:[(b||h)&&(0,d.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,d.jsxs)("div",{className:"flex items-center gap-3",children:[g&&(0,d.jsx)("div",{className:"p-2 rounded-[10px] bg-bg text-text-muted",children:(0,d.jsx)("span",{className:"material-symbols-outlined text-[20px]",children:g})}),(0,d.jsxs)("div",{children:[b&&(0,d.jsx)("h3",{className:"text-text-main font-semibold",children:b}),c&&(0,d.jsx)("p",{className:"text-sm text-text-muted",children:c})]})]}),h]}),a]})}f.Section=function({children:a,className:b,...c}){return(0,d.jsx)("div",{className:(0,e.cn)("p-4 rounded-[10px]","bg-bg border border-border-subtle",b),...c,children:a})},f.Row=function({children:a,className:b,...c}){return(0,d.jsx)("div",{className:(0,e.cn)("p-3 -mx-3 px-3 transition-colors","border-b border-border-subtle last:border-b-0","hover:bg-surface-2/50",b),...c,children:a})},f.ListItem=function({children:a,actions:b,className:c,...f}){return(0,d.jsxs)("div",{className:(0,e.cn)("group flex items-center justify-between p-3 -mx-3 px-3","border-b border-border-subtle last:border-b-0","hover:bg-surface-2/50 transition-colors",c),...f,children:[(0,d.jsx)("div",{className:"flex-1 min-w-0",children:a}),b&&(0,d.jsx)("div",{className:"flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:b})]})}},20084:(a,b,c)=>{c.d(b,{default:()=>g});var d=c(48249),e=c(67484),f=c(95145);function g({isOpen:a,onClose:b,onAdd:c,addedNames:h=[]}){let[i,j]=(0,e.useState)([]),[k,l]=(0,e.useState)(!1),[m,n]=(0,e.useState)(""),[o,p]=(0,e.useState)("all"),[q,r]=(0,e.useState)(null),[s,t]=(0,e.useState)(null),[u,v]=(0,e.useState)({}),[w,x]=(0,e.useState)({}),[y,z]=(0,e.useState)({}),A=(0,e.useMemo)(()=>new Set(h),[h]),B=(0,e.useMemo)(()=>{let a=m.trim().toLowerCase();return i.filter(b=>("authless"!==o||!b.oauth)&&("oauth"!==o||!!b.oauth)&&(!a||(b.title||"").toLowerCase().includes(a)||(b.description||"").toLowerCase().includes(a)||(b.name||"").toLowerCase().includes(a)))},[i,m,o]),C=async a=>{if(!u[a.url]){x(b=>({...b,[a.url]:!0}));try{let b=await fetch("/api/cli-tools/cowork-mcp-tools",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:a.url})}),c=await b.json(),d=c.tools||[],e=Array.isArray(a.toolNames)?a.toolNames:[],f=d.length>0?d.map(a=>a.name):e;v(b=>({...b,[a.url]:{tools:d,requiresAuth:!!c.requiresAuth,error:c.error}})),z(b=>({...b,[a.url]:Object.fromEntries(f.map(a=>[a,!0]))}))}catch(b){v(c=>({...c,[a.url]:{tools:[],error:b.message}}))}finally{x(b=>({...b,[a.url]:!1}))}}},D=(a,b)=>{let c=y[a]||{};z(d=>({...d,[a]:Object.fromEntries(Object.keys(c).map(a=>[a,b]))}))};return(0,d.jsx)(f.default,{isOpen:a,onClose:b,title:"Browse MCP Marketplace",size:"lg",children:(0,d.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("input",{type:"text",value:m,onChange:a=>n(a.target.value),placeholder:"Search by name or description...",className:"flex-1 px-2 py-1.5 bg-surface rounded text-xs border border-border focus:outline-none focus:ring-1 focus:ring-primary/50"}),(0,d.jsxs)("select",{value:o,onChange:a=>p(a.target.value),className:"px-2 py-1.5 bg-surface rounded text-xs border border-border focus:outline-none focus:ring-1 focus:ring-primary/50",children:[(0,d.jsx)("option",{value:"all",children:"All"}),(0,d.jsx)("option",{value:"authless",children:"Authless"}),(0,d.jsx)("option",{value:"oauth",children:"OAuth"})]})]}),q&&(0,d.jsx)("div",{className:"px-2 py-1.5 rounded text-xs bg-red-500/10 text-red-600",children:q}),k&&(0,d.jsxs)("div",{className:"flex items-center gap-2 text-text-muted text-xs py-4 justify-center",children:[(0,d.jsx)("span",{className:"material-symbols-outlined animate-spin text-[18px]",children:"progress_activity"}),(0,d.jsx)("span",{children:"Loading registry..."})]}),!k&&(0,d.jsxs)("div",{className:"flex flex-col gap-1 max-h-[60vh] overflow-y-auto",children:[0===B.length&&(0,d.jsx)("div",{className:"text-center text-xs text-text-muted py-6",children:"No servers match filter"}),B.map(a=>{let b=A.has(a.slug||a.name),e=s===a.url,f=u[a.url],g=w[a.url],h=y[a.url]||{},i=Object.keys(h),j=Object.values(h).filter(Boolean).length;return(0,d.jsxs)("div",{className:"rounded border border-transparent hover:border-border",children:[(0,d.jsxs)("div",{className:"flex items-start gap-2 px-2 py-2 hover:bg-black/5 dark:hover:bg-white/5",children:[a.iconUrl?(0,d.jsx)("img",{src:a.iconUrl,alt:"",className:"size-7 rounded shrink-0 object-contain",onError:a=>{a.target.style.display="none"}}):(0,d.jsx)("div",{className:"size-7 rounded bg-surface shrink-0"}),(0,d.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,d.jsxs)("div",{className:"flex items-center gap-1.5 flex-wrap",children:[(0,d.jsx)("span",{className:"font-medium text-xs",children:a.title}),a.oauth?(0,d.jsx)("span",{className:"px-1 py-0.5 text-[9px] rounded bg-amber-500/10 text-amber-600",children:"OAuth"}):(0,d.jsx)("span",{className:"px-1 py-0.5 text-[9px] rounded bg-green-500/10 text-green-600",children:"Authless"}),a.toolCount>0&&(0,d.jsxs)("span",{className:"text-[10px] text-text-muted",children:[a.toolCount," tools"]})]}),a.description&&(0,d.jsx)("p",{className:"text-[10px] text-text-muted line-clamp-2 mt-0.5",children:a.description})]}),(0,d.jsx)("button",{onClick:()=>b?null:void(s===a.url?t(null):(t(a.url),C(a))),disabled:b,className:`shrink-0 px-2 py-1 rounded text-[10px] font-medium transition-colors ${b?"bg-green-500/10 text-green-600 cursor-default":e?"bg-surface border border-border text-text-muted hover:bg-black/5":"bg-primary/10 border border-primary/40 text-primary hover:bg-primary/20"}`,children:b?"Added":e?"Cancel":"+ Add"})]}),e&&(0,d.jsxs)("div",{className:"px-3 py-2 bg-surface/40 border-t border-border flex flex-col gap-2",children:[g&&(0,d.jsxs)("div",{className:"flex items-center gap-2 text-text-muted text-[10px] py-1",children:[(0,d.jsx)("span",{className:"material-symbols-outlined animate-spin text-[14px]",children:"progress_activity"}),(0,d.jsx)("span",{children:"Probing server for tools..."})]}),!g&&f?.requiresAuth&&(0,d.jsx)("p",{className:"text-[10px] text-amber-600 bg-amber-500/10 px-2 py-1 rounded",children:"\uD83D\uDD10 OAuth required. Add now and authenticate after Apply; tool list will be discovered after first connect."}),!g&&f?.error&&!f?.requiresAuth&&(0,d.jsxs)("p",{className:"text-[10px] text-red-600 bg-red-500/10 px-2 py-1 rounded",children:["Probe failed: ",f.error]}),!g&&0===i.length&&!f?.requiresAuth&&!f?.error&&(0,d.jsx)("p",{className:"text-[10px] text-text-muted",children:"No tools advertised by server."}),!g&&i.length>0&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("div",{className:"flex items-center justify-between",children:[(0,d.jsxs)("span",{className:"text-[10px] text-text-muted",children:[j,"/",i.length," tools enabled"]}),(0,d.jsxs)("div",{className:"flex gap-1",children:[(0,d.jsx)("button",{onClick:()=>D(a.url,!0),className:"text-[10px] text-primary hover:underline",children:"All"}),(0,d.jsx)("span",{className:"text-[10px] text-text-muted",children:"\xb7"}),(0,d.jsx)("button",{onClick:()=>D(a.url,!1),className:"text-[10px] text-primary hover:underline",children:"None"})]})]}),(0,d.jsx)("div",{className:"grid grid-cols-2 gap-1 max-h-40 overflow-y-auto",children:i.map(b=>(0,d.jsxs)("label",{className:"flex items-center gap-1.5 text-[10px] cursor-pointer hover:bg-black/5 dark:hover:bg-white/5 px-1 rounded",children:[(0,d.jsx)("input",{type:"checkbox",checked:!!h[b],onChange:()=>{var c;return c=a.url,void z(a=>({...a,[c]:{...a[c],[b]:!a[c]?.[b]}}))},className:"size-3"}),(0,d.jsx)("span",{className:"truncate",children:b})]},b))})]}),(0,d.jsx)("button",{onClick:()=>{let b,d;return d=Object.keys(b=y[a.url]||{}).filter(a=>b[a]),void(c?.({name:a.slug||a.name,title:a.title,description:a.description,url:a.url,transport:a.transport,oauth:a.oauth,toolNames:d}),t(null))},className:"self-end px-2 py-1 rounded text-[10px] font-medium bg-primary text-white hover:bg-primary/90",children:"✓ Confirm Add"})]})]},a.url)})]}),(0,d.jsxs)("div",{className:"text-[10px] text-text-muted text-right",children:[B.length," of ",i.length," servers"]})]})})}},23048:(a,b,c)=>{c.d(b,{default:()=>g});var d=c(48249),e=c(67484),f=c(97564);function g(){let[a,b]=(0,e.useState)(!1);return(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("button",{onClick:()=>b(!0),className:"relative flex items-center gap-1.5 px-2.5 py-1.5 rounded-lg transition-all text-text-muted hover:text-text-main hover:bg-black/5 dark:hover:bg-white/5",title:"9Remote",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"computer"}),(0,d.jsx)("span",{className:"text-xs font-medium",children:"Remote"})]}),(0,d.jsx)(f.A,{isOpen:a,onClose:()=>b(!1)})]})}},25919:(a,b,c)=>{c.d(b,{default:()=>f});var d=c(48249),e=c(71404);function f({src:a,alt:b="Avatar",name:c,size:g="md",className:h}){let i={xs:"size-6 text-xs",sm:"size-8 text-sm",md:"size-10 text-base",lg:"size-12 text-lg",xl:"size-16 text-xl"};return a?(0,d.jsx)("div",{className:(0,e.cn)("rounded-full bg-cover bg-center bg-no-repeat","ring-2 ring-white dark:ring-surface-dark shadow-sm",i[g],h),style:{backgroundImage:`url(${a})`},role:"img","aria-label":b}):(0,d.jsx)("div",{className:(0,e.cn)("rounded-full flex items-center justify-center font-semibold text-white","ring-2 ring-white dark:ring-surface-dark shadow-sm",i[g],(a=>{if(!a)return"bg-primary";let b=["bg-red-500","bg-orange-500","bg-amber-500","bg-yellow-500","bg-lime-500","bg-green-500","bg-emerald-500","bg-teal-500","bg-cyan-500","bg-sky-500","bg-blue-500","bg-indigo-500","bg-violet-500","bg-purple-500","bg-fuchsia-500","bg-pink-500","bg-rose-500"],c=a.charCodeAt(0)%b.length;return b[c]})(c),h),role:"img","aria-label":b,children:(a=>{if(!a)return"?";let b=a.split(" ");return b.length>=2?`${b[0][0]}${b[1][0]}`.toUpperCase():a.substring(0,2).toUpperCase()})(c)})}},28403:(a,b,c)=>{c.d(b,{default:()=>S});var d=c(48249),e=c(67484),f=c(19099),g=c(96919),h=c(75171),i=c(17660),j=c(83021),k=c(49885),l=c.n(k);let m=a=>new Intl.NumberFormat().format(a||0),n=a=>`$${(a||0).toFixed(2)}`;function o(a){if(!a)return"Never";let b=Math.floor((Date.now()-new Date(a))/6e4);return b<1?"Just now":b<60?`${b}m ago`:b<1440?`${Math.floor(b/60)}h ago`:new Date(a).toLocaleDateString()}function p({field:a,currentSort:b,currentOrder:c}){return b!==a?(0,d.jsx)("span",{className:"ml-1 opacity-20",children:"↕"}):(0,d.jsx)("span",{className:"ml-1",children:"asc"===c?"↑":"↓"})}function q({item:a,viewMode:b,isSummary:c=!1}){return"tokens"===b?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("td",{className:"px-6 py-3 text-right text-text-muted",children:c&&void 0===a.promptTokens?"—":m(a.promptTokens)}),(0,d.jsx)("td",{className:"px-6 py-3 text-right text-text-muted",children:c&&void 0===a.completionTokens?"—":m(a.completionTokens)}),(0,d.jsx)("td",{className:"px-6 py-3 text-right font-medium",children:m(a.totalTokens)})]}):(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("td",{className:"px-6 py-3 text-right text-text-muted",children:c&&void 0===a.inputCost?"—":n(a.inputCost)}),(0,d.jsx)("td",{className:"px-6 py-3 text-right text-text-muted",children:c&&void 0===a.outputCost?"—":n(a.outputCost)}),(0,d.jsx)("td",{className:"px-6 py-3 text-right font-medium text-warning",children:n(a.totalCost||a.cost)})]})}function r({title:a,columns:b,groupedData:c,tableType:f,sortBy:g,sortOrder:h,onToggleSort:j,viewMode:k,storageKey:l,renderDetailCells:m,renderSummaryCells:n,emptyMessage:o}){let[s,t]=(0,e.useState)(new Set),u=(0,e.useCallback)(a=>{t(b=>{let c=new Set(b);return c.has(a)?c.delete(a):c.add(a),c})},[]),v=(0,e.useMemo)(()=>"tokens"===k?[{field:"promptTokens",label:"Input Tokens"},{field:"completionTokens",label:"Output Tokens"},{field:"totalTokens",label:"Total Tokens"}]:[{field:"promptTokens",label:"Input Cost"},{field:"completionTokens",label:"Output Cost"},{field:"cost",label:"Total Cost"}],[k]),w=b.length+v.length;return(0,d.jsxs)(i.default,{className:"overflow-hidden",children:[(0,d.jsx)("div",{className:"p-4 border-b border-border bg-bg-subtle/50",children:(0,d.jsx)("h3",{className:"font-semibold",children:a})}),(0,d.jsx)("div",{className:"overflow-x-auto",children:(0,d.jsxs)("table",{className:"w-full text-sm text-left",children:[(0,d.jsx)("thead",{className:"bg-bg-subtle/30 text-text-muted uppercase text-xs",children:(0,d.jsxs)("tr",{children:[b.map(a=>(0,d.jsxs)("th",{className:`px-6 py-3 cursor-pointer hover:bg-bg-subtle/50 ${"right"===a.align?"text-right":""}`,onClick:()=>j(f,a.field),children:[a.label," ",(0,d.jsx)(p,{field:a.field,currentSort:g,currentOrder:h})]},a.field)),v.map(a=>(0,d.jsxs)("th",{className:"px-6 py-3 text-right cursor-pointer hover:bg-bg-subtle/50",onClick:()=>j(f,a.field),children:[a.label," ",(0,d.jsx)(p,{field:a.field,currentSort:g,currentOrder:h})]},a.field))]})}),(0,d.jsxs)("tbody",{className:"divide-y divide-border",children:[c.map(a=>(0,d.jsxs)(e.Fragment,{children:[(0,d.jsxs)("tr",{className:"group-summary cursor-pointer hover:bg-bg-subtle/50 transition-colors",onClick:()=>u(a.groupKey),children:[(0,d.jsx)("td",{className:"px-6 py-3",children:(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("span",{className:`material-symbols-outlined text-[18px] text-text-muted transition-transform ${s.has(a.groupKey)?"rotate-90":""}`,children:"chevron_right"}),(0,d.jsx)("span",{className:`font-medium transition-colors ${a.summary.pending>0?"text-primary":""}`,children:a.groupKey})]})}),n(a),(0,d.jsx)(q,{item:a.summary,viewMode:k,isSummary:!0})]}),s.has(a.groupKey)&&a.items.map(a=>(0,d.jsxs)("tr",{className:"group-detail hover:bg-bg-subtle/20 transition-colors",children:[m(a),(0,d.jsx)(q,{item:a,viewMode:k})]},`detail-${a.key}`))]},a.groupKey)),0===c.length&&(0,d.jsx)("tr",{children:(0,d.jsx)("td",{colSpan:w,className:"px-6 py-8 text-center text-text-muted",children:o})})]})]})})]})}p.propTypes={field:l().string.isRequired,currentSort:l().string.isRequired,currentOrder:l().string.isRequired},q.propTypes={item:l().object.isRequired,viewMode:l().string.isRequired,isSummary:l().bool},r.propTypes={title:l().string.isRequired,columns:l().arrayOf(l().shape({field:l().string.isRequired,label:l().string.isRequired,align:l().string})).isRequired,groupedData:l().array.isRequired,tableType:l().string.isRequired,sortBy:l().string.isRequired,sortOrder:l().string.isRequired,onToggleSort:l().func.isRequired,viewMode:l().string.isRequired,storageKey:l().string.isRequired,renderDetailCells:l().func.isRequired,renderSummaryCells:l().func.isRequired,emptyMessage:l().string.isRequired};var s=c(96103),t=c(22805);function u({data:a}){let{label:b,color:c,imageUrl:f,textIcon:g,active:h}=a,[i,j]=(0,e.useState)(!1);return(0,d.jsxs)("div",{className:"flex items-center gap-2.5 px-4 py-2.5 rounded-lg border-2 transition-all duration-300 bg-bg",style:{borderColor:h?c:"var(--color-border)",boxShadow:h?`0 0 16px ${c}40`:"none",minWidth:"150px"},children:[(0,d.jsx)(s.h7,{type:"target",position:t.yX.Top,id:"top",className:"!bg-transparent !border-0 !w-0 !h-0"}),(0,d.jsx)(s.h7,{type:"target",position:t.yX.Bottom,id:"bottom",className:"!bg-transparent !border-0 !w-0 !h-0"}),(0,d.jsx)(s.h7,{type:"target",position:t.yX.Left,id:"left",className:"!bg-transparent !border-0 !w-0 !h-0"}),(0,d.jsx)(s.h7,{type:"target",position:t.yX.Right,id:"right",className:"!bg-transparent !border-0 !w-0 !h-0"}),(0,d.jsx)("div",{className:"w-8 h-8 rounded-md flex items-center justify-center shrink-0",style:{backgroundColor:`${c}15`},children:i?(0,d.jsx)("span",{className:"text-sm font-bold",style:{color:c},children:g}):(0,d.jsx)("img",{src:f,alt:b,className:"w-6 h-6 rounded-sm object-contain",onError:()=>j(!0)})}),(0,d.jsx)("span",{className:"text-base font-medium truncate",style:{color:h?c:"var(--color-text)"},children:b}),h&&(0,d.jsxs)("span",{className:"relative flex h-2 w-2 shrink-0",children:[(0,d.jsx)("span",{className:"animate-ping absolute inline-flex h-full w-full rounded-full opacity-75",style:{backgroundColor:c}}),(0,d.jsx)("span",{className:"relative inline-flex rounded-full h-2 w-2",style:{backgroundColor:c}})]})]})}function v({data:a}){return(0,d.jsxs)("div",{className:"flex items-center justify-center px-5 py-3 rounded-xl border-2 border-primary bg-primary/5 shadow-md min-w-[130px]",children:[(0,d.jsx)(s.h7,{type:"source",position:t.yX.Top,id:"top",className:"!bg-transparent !border-0 !w-0 !h-0"}),(0,d.jsx)(s.h7,{type:"source",position:t.yX.Bottom,id:"bottom",className:"!bg-transparent !border-0 !w-0 !h-0"}),(0,d.jsx)(s.h7,{type:"source",position:t.yX.Left,id:"left",className:"!bg-transparent !border-0 !w-0 !h-0"}),(0,d.jsx)(s.h7,{type:"source",position:t.yX.Right,id:"right",className:"!bg-transparent !border-0 !w-0 !h-0"}),(0,d.jsx)("img",{src:"/favicon.svg",alt:"openrouterx",className:"w-6 h-6 mr-2"}),(0,d.jsx)("span",{className:"text-sm font-bold text-primary",children:"openrouterx"}),a.activeCount>0&&(0,d.jsx)("span",{className:"ml-2 px-1.5 py-0.5 rounded-full bg-primary text-white text-xs font-bold",children:a.activeCount})]})}c(71763),u.propTypes={data:l().object.isRequired},v.propTypes={data:l().object.isRequired};let w={provider:u,router:v};function x({providers:a=[],activeRequests:b=[],lastProvider:c="",errorProvider:f=""}){let h=(0,e.useMemo)(()=>b.map(a=>a.provider?.toLowerCase()).filter(Boolean).sort().join(","),[b]),i=c?.toLowerCase()||"",j=f?.toLowerCase()||"",k=(0,e.useMemo)(()=>new Set(h?h.split(","):[]),[h]),l=(0,e.useMemo)(()=>new Set(i?[i]:[]),[i]),m=(0,e.useMemo)(()=>new Set(j?[j]:[]),[j]),n=(0,e.useRef)({}),[o,p]=(0,e.useState)(0),q=(0,e.useMemo)(()=>{let a=Date.now(),b=new Set;for(let c of k){let d=n.current[c];(!d||a-d<6e4)&&b.add(c)}return b},[k,o]),{nodes:r,edges:t}=(0,e.useMemo)(()=>(function(a,b,c,d){let e=a.length,f=Math.max(320,204*e/(2*Math.PI)),h=Math.max(200,.55*f);if(0===e)return{nodes:[{id:"router",type:"router",position:{x:0,y:0},data:{activeCount:0},draggable:!1}],edges:[]};let i=[],j=[];return i.push({id:"router",type:"router",position:{x:-60,y:-22},data:{activeCount:b.size},draggable:!1}),a.forEach((a,k)=>{var l,m;let n,o,p=(l=a.provider,g.Q2[l]||{color:"#6b7280",name:l}),q=b.has(a.provider?.toLowerCase()),r=!q&&c.has(a.provider?.toLowerCase()),s=!q&&d.has(a.provider?.toLowerCase()),t=`provider-${a.provider}`,u={label:(p.name!==a.provider?p.name:null)||a.name||a.provider,color:p.color||"#6b7280",imageUrl:(m=a.provider,`/providers/${m}.png`),textIcon:p.textIcon||(a.provider||"?").slice(0,2).toUpperCase(),active:q},v=-Math.PI/2+2*Math.PI*k/e,w=f*Math.cos(v),x=h*Math.sin(v);Math.abs(v+Math.PI/2)<Math.PI/4||Math.abs(v-3*Math.PI/2)<Math.PI/4?(n="top",o="bottom"):Math.abs(v-Math.PI/2)<Math.PI/4?(n="bottom",o="top"):w>0?(n="right",o="left"):(n="left",o="right"),i.push({id:t,type:"provider",position:{x:w-90,y:x-15},data:u,draggable:!1}),j.push({id:`e-${t}`,source:"router",sourceHandle:n,target:t,targetHandle:o,animated:q,style:(p.color,s?{stroke:"#ef4444",strokeWidth:2.5,opacity:.9}:q?{stroke:"#22c55e",strokeWidth:2.5,opacity:.9}:r?{stroke:"#f59e0b",strokeWidth:2,opacity:.7}:{stroke:"var(--color-border)",strokeWidth:1,opacity:.3})})}),{nodes:i,edges:j}})(a,q,l,m),[a,q,i,j]),u=(0,e.useMemo)(()=>a.map(a=>a.provider).sort().join(","),[a]),v=(0,e.useRef)(null),y=(0,e.useRef)(null),z={padding:.2,duration:200},A=(0,e.useCallback)(a=>{v.current=a,setTimeout(()=>a.fitView(z),50)},[]);return(0,d.jsx)("div",{ref:y,className:"h-[320px] w-full min-w-0 rounded-lg border border-border bg-bg-subtle/30 sm:h-[480px]",children:0===a.length?(0,d.jsx)("div",{className:"h-full flex items-center justify-center text-text-muted text-sm",children:"No providers connected"}):(0,d.jsx)(s.Gc,{nodes:r,edges:t,nodeTypes:w,fitView:!0,fitViewOptions:z,minZoom:.1,maxZoom:2,onInit:A,proOptions:{hideAttribution:!0},panOnDrag:!0,zoomOnScroll:!0,zoomOnPinch:!0,zoomOnDoubleClick:!0,preventScrolling:!1,nodesDraggable:!1,nodesConnectable:!1,elementsSelectable:!1,children:(0,d.jsx)(s.H2,{showInteractive:!1,className:"react-flow-controls-custom"})},u)})}x.propTypes={providers:l().arrayOf(l().shape({id:l().string,provider:l().string,name:l().string})),activeRequests:l().arrayOf(l().shape({provider:l().string,model:l().string,account:l().string})),lastProvider:l().string,errorProvider:l().string};var y=c(80322),z=c(70452),A=c(28946),B=c(22393),C=c(54206),D=c(83954),E=c(44780);let F=a=>a>=1e6?`${(a/1e6).toFixed(1)}M`:a>=1e3?`${(a/1e3).toFixed(1)}K`:String(a||0),G=a=>`$${(a||0).toFixed(4)}`;function H({period:a="24h"}){let[b,c]=(0,e.useState)([]),[f,g]=(0,e.useState)(!0),[h,j]=(0,e.useState)("tokens");(0,e.useCallback)(async()=>{g(!0);try{let b=await fetch(`/api/usage/chart?period=${a}`);if(b.ok){let a=await b.json();c(a)}}catch(a){console.error("Failed to fetch chart data:",a)}finally{g(!1)}},[a]);let k=b.some(a=>a.tokens>0||a.cost>0);return(0,d.jsxs)(i.default,{className:"flex min-w-0 flex-col gap-3 p-3 sm:p-4",children:[(0,d.jsxs)("div",{className:"grid w-full grid-cols-2 items-center gap-1 rounded-lg border border-border bg-bg-subtle p-1 sm:w-auto sm:self-start",children:[(0,d.jsx)("button",{onClick:()=>j("tokens"),className:`px-3 py-1 rounded-md text-sm font-medium transition-colors ${"tokens"===h?"bg-primary text-white shadow-sm":"text-text-muted hover:text-text hover:bg-bg-hover"}`,children:"Tokens"}),(0,d.jsx)("button",{onClick:()=>j("cost"),className:`px-3 py-1 rounded-md text-sm font-medium transition-colors ${"cost"===h?"bg-primary text-white shadow-sm":"text-text-muted hover:text-text hover:bg-bg-hover"}`,children:"Cost"})]}),f?(0,d.jsx)("div",{className:"h-48 flex items-center justify-center text-text-muted text-sm",children:"Loading..."}):k?(0,d.jsx)(y.u,{width:"100%",height:220,children:(0,d.jsxs)(z.Q,{data:b,margin:{top:4,right:8,left:0,bottom:0},children:[(0,d.jsxs)("defs",{children:[(0,d.jsxs)("linearGradient",{id:"gradTokens",x1:"0",y1:"0",x2:"0",y2:"1",children:[(0,d.jsx)("stop",{offset:"5%",stopColor:"#6366f1",stopOpacity:.25}),(0,d.jsx)("stop",{offset:"95%",stopColor:"#6366f1",stopOpacity:0})]}),(0,d.jsxs)("linearGradient",{id:"gradCost",x1:"0",y1:"0",x2:"0",y2:"1",children:[(0,d.jsx)("stop",{offset:"5%",stopColor:"#f59e0b",stopOpacity:.25}),(0,d.jsx)("stop",{offset:"95%",stopColor:"#f59e0b",stopOpacity:0})]})]}),(0,d.jsx)(A.d,{strokeDasharray:"3 3",strokeOpacity:.1}),(0,d.jsx)(B.W,{dataKey:"label",tick:{fontSize:10,fill:"currentColor",fillOpacity:.5},tickLine:!1,axisLine:!1,interval:"preserveStartEnd"}),(0,d.jsx)(C.h,{tick:{fontSize:10,fill:"currentColor",fillOpacity:.5},tickLine:!1,axisLine:!1,tickFormatter:"tokens"===h?F:G,width:50}),(0,d.jsx)(D.m,{contentStyle:{backgroundColor:"var(--color-bg)",border:"1px solid var(--color-border)",borderRadius:"8px",fontSize:"12px"},formatter:(a,b)=>"tokens"===b?[F(a),"Tokens"]:[G(a),"Cost"]}),"tokens"===h?(0,d.jsx)(E.Gk,{type:"monotone",dataKey:"tokens",stroke:"#6366f1",strokeWidth:2,fill:"url(#gradTokens)",dot:!1,activeDot:{r:4}}):(0,d.jsx)(E.Gk,{type:"monotone",dataKey:"cost",stroke:"#f59e0b",strokeWidth:2,fill:"url(#gradCost)",dot:!1,activeDot:{r:4}})]})}):(0,d.jsx)("div",{className:"h-48 flex items-center justify-center text-text-muted text-sm",children:"No data for this period"})]})}function I({timestamp:a}){let b,[,c]=(0,e.useState)(0);return(0,d.jsx)(d.Fragment,{children:(b=Math.floor((Date.now()-new Date(a))/1e3))<60?`${b}s ago`:b<3600?`${Math.floor(b/60)}m ago`:b<86400?`${Math.floor(b/3600)}h ago`:`${Math.floor(b/86400)}d ago`})}function J({requests:a=[]}){return(0,d.jsxs)(i.default,{className:"flex min-w-0 flex-col overflow-hidden",padding:"sm",style:{height:480},children:[(0,d.jsx)("div",{className:"px-1 py-2 border-b border-border shrink-0",children:(0,d.jsx)("span",{className:"text-xs font-semibold text-text-muted uppercase tracking-wide",children:"Recent Requests"})}),a.length?(0,d.jsx)("div",{className:"flex-1 overflow-y-auto",children:(0,d.jsxs)("table",{className:"w-full min-w-[300px] border-collapse text-xs",children:[(0,d.jsx)("thead",{className:"sticky top-0 bg-bg z-10",children:(0,d.jsxs)("tr",{className:"border-b border-border",children:[(0,d.jsx)("th",{className:"py-1.5 text-left font-semibold text-text-muted w-2"}),(0,d.jsx)("th",{className:"py-1.5 text-left font-semibold text-text-muted",children:"Model"}),(0,d.jsx)("th",{className:"py-1.5 text-right font-semibold text-text-muted whitespace-nowrap",children:"In / Out"}),(0,d.jsx)("th",{className:"py-1.5 text-right font-semibold text-text-muted",children:"When"})]})}),(0,d.jsx)("tbody",{className:"divide-y divide-border/50",children:a.map((a,b)=>{let c=!a.status||"ok"===a.status||"success"===a.status;return(0,d.jsxs)("tr",{className:"hover:bg-bg-subtle transition-colors",children:[(0,d.jsx)("td",{className:"py-1.5",children:(0,d.jsx)("span",{className:`block w-1.5 h-1.5 rounded-full ${c?"bg-success":"bg-error"}`})}),(0,d.jsx)("td",{className:"py-1.5 font-mono truncate max-w-[120px]",title:a.model,children:a.model}),(0,d.jsxs)("td",{className:"py-1.5 text-right whitespace-nowrap",children:[(0,d.jsxs)("span",{className:"text-primary",children:[m(a.promptTokens),"↑"]})," ",(0,d.jsxs)("span",{className:"text-success",children:[m(a.completionTokens),"↓"]})]}),(0,d.jsx)("td",{className:"py-1.5 text-right text-text-muted whitespace-nowrap",children:(0,d.jsx)(I,{timestamp:a.timestamp})})]},b)})})]})}):(0,d.jsx)("div",{className:"flex-1 flex items-center justify-center text-text-muted text-sm",children:"No requests yet."})]})}function K(a,b={},c,d){return Object.entries(a||{}).map(([a,c])=>{let d=(c.promptTokens||0)+(c.completionTokens||0),e=c.cost||0,f=d>0?(c.promptTokens||0)*(e/d):0,g=d>0?(c.completionTokens||0)*(e/d):0;return{...c,key:a,totalTokens:d,totalCost:e,inputCost:f,outputCost:g,pending:b[a]||0}}).sort((a,b)=>{let e=a[c],f=b[c];return("string"==typeof e&&(e=e.toLowerCase()),"string"==typeof f&&(f=f.toLowerCase()),e<f)?"asc"===d?-1:1:e>f?"asc"===d?1:-1:0})}function L(a,b){if(!Array.isArray(a))return[];let c={};return a.forEach(a=>{let d=function(a,b){switch(b){case"rawModel":return a.rawModel||"Unknown Model";case"accountName":return a.accountName||`Account ${a.connectionId?.slice(0,8)}...`||"Unknown Account";case"keyName":return a.keyName||"Unknown Key";case"endpoint":return a.endpoint||"Unknown Endpoint";default:return a[b]||"Unknown"}}(a,b);c[d]||(c[d]={groupKey:d,summary:{requests:0,promptTokens:0,completionTokens:0,totalTokens:0,cost:0,inputCost:0,outputCost:0,lastUsed:null,pending:0},items:[]});let e=c[d].summary;e.requests+=a.requests||0,e.promptTokens+=a.promptTokens||0,e.completionTokens+=a.completionTokens||0,e.totalTokens+=a.totalTokens||0,e.cost+=a.cost||0,e.inputCost+=a.inputCost||0,e.outputCost+=a.outputCost||0,e.pending+=a.pending||0,a.lastUsed&&(!e.lastUsed||new Date(a.lastUsed)>new Date(e.lastUsed))&&(e.lastUsed=a.lastUsed),c[d].items.push(a)}),Object.values(c)}H.propTypes={period:l().string};let M=[{field:"rawModel",label:"Model"},{field:"provider",label:"Provider"},{field:"requests",label:"Requests",align:"right"},{field:"lastUsed",label:"Last Used",align:"right"}],N=[{field:"rawModel",label:"Model"},{field:"provider",label:"Provider"},{field:"accountName",label:"Account"},{field:"requests",label:"Requests",align:"right"},{field:"lastUsed",label:"Last Used",align:"right"}],O=[{field:"keyName",label:"API Key Name"},{field:"rawModel",label:"Model"},{field:"provider",label:"Provider"},{field:"requests",label:"Requests",align:"right"},{field:"lastUsed",label:"Last Used",align:"right"}],P=[{field:"endpoint",label:"Endpoint"},{field:"rawModel",label:"Model"},{field:"provider",label:"Provider"},{field:"requests",label:"Requests",align:"right"},{field:"lastUsed",label:"Last Used",align:"right"}],Q=[{value:"model",label:"Usage by Model"},{value:"account",label:"Usage by Account"},{value:"apiKey",label:"Usage by API Key"},{value:"endpoint",label:"Usage by Endpoint"}],R=[{value:"today",label:"Today"},{value:"24h",label:"24h"},{value:"7d",label:"7D"},{value:"30d",label:"30D"},{value:"60d",label:"60D"}];function S({period:a,setPeriod:b,hidePeriodSelector:c=!1}={}){let g=(0,f.useRouter)(),i=(0,f.useSearchParams)(),k=i.get("sortBy")||"rawModel",l=i.get("sortOrder")||"asc",[n,p]=(0,e.useState)(null),[q,s]=(0,e.useState)(!0),[t,u]=(0,e.useState)(!1),[v,w]=(0,e.useState)("model"),[y,z]=(0,e.useState)("costs"),[A,B]=(0,e.useState)([]),[C,D]=(0,e.useState)("today"),E=a??C,F=b??D,[G,I]=(0,e.useState)(null),[T,U]=(0,e.useState)(!1),V="sub_user"===G,W=V?"apiKey":v,X=(0,e.useCallback)((a,b)=>{let c=new URLSearchParams(i.toString());c.get("sortBy")===b?c.set("sortOrder","asc"===c.get("sortOrder")?"desc":"asc"):(c.set("sortBy",b),c.set("sortOrder","asc")),g.replace(`?${c.toString()}`,{scroll:!1})},[i,g]),Y=(0,e.useMemo)(()=>{if(!n)return null;switch(W){case"model":{let a=n.pending?.byModel||{};return{columns:M,groupedData:L(K(n.byModel,a,k,l),"rawModel"),storageKey:"usage-stats:expanded-models",emptyMessage:"No usage recorded yet.",renderSummaryCells:a=>(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("td",{className:"px-6 py-3 text-text-muted",children:"—"}),(0,d.jsx)("td",{className:"px-6 py-3 text-right",children:m(a.summary.requests)}),(0,d.jsx)("td",{className:"px-6 py-3 text-right text-text-muted whitespace-nowrap",children:o(a.summary.lastUsed)})]}),renderDetailCells:a=>(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("td",{className:`px-6 py-3 font-medium transition-colors ${a.pending>0?"text-primary":""}`,children:a.rawModel}),(0,d.jsx)("td",{className:"px-6 py-3",children:(0,d.jsx)(h.default,{variant:a.pending>0?"primary":"neutral",size:"sm",children:a.provider})}),(0,d.jsx)("td",{className:"px-6 py-3 text-right",children:m(a.requests)}),(0,d.jsx)("td",{className:"px-6 py-3 text-right text-text-muted whitespace-nowrap",children:o(a.lastUsed)})]})}}case"account":{let a={};return n?.pending?.byAccount&&Object.entries(n.byAccount||{}).forEach(([b,c])=>{let d=n.pending.byAccount[c.connectionId];if(d){let e=c.provider?`${c.rawModel} (${c.provider})`:c.rawModel;a[b]=d[e]||0}}),{columns:N,groupedData:L(K(n.byAccount,a,k,l),"accountName"),storageKey:"usage-stats:expanded-accounts",emptyMessage:"No account-specific usage recorded yet.",renderSummaryCells:a=>(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("td",{className:"px-6 py-3 text-text-muted",children:"—"}),(0,d.jsx)("td",{className:"px-6 py-3 text-text-muted",children:"—"}),(0,d.jsx)("td",{className:"px-6 py-3 text-right",children:m(a.summary.requests)}),(0,d.jsx)("td",{className:"px-6 py-3 text-right text-text-muted whitespace-nowrap",children:o(a.summary.lastUsed)})]}),renderDetailCells:a=>(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("td",{className:`px-6 py-3 font-medium transition-colors ${a.pending>0?"text-primary":""}`,children:a.accountName||`Account ${a.connectionId?.slice(0,8)}...`}),(0,d.jsx)("td",{className:`px-6 py-3 font-medium transition-colors ${a.pending>0?"text-primary":""}`,children:a.rawModel}),(0,d.jsx)("td",{className:"px-6 py-3",children:(0,d.jsx)(h.default,{variant:a.pending>0?"primary":"neutral",size:"sm",children:a.provider})}),(0,d.jsx)("td",{className:"px-6 py-3 text-right",children:m(a.requests)}),(0,d.jsx)("td",{className:"px-6 py-3 text-right text-text-muted whitespace-nowrap",children:o(a.lastUsed)})]})}}case"apiKey":return{columns:O,groupedData:L(K(n.byApiKey,{},k,l),"keyName"),storageKey:"usage-stats:expanded-apikeys",emptyMessage:"No API key usage recorded yet.",renderSummaryCells:a=>(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("td",{className:"px-6 py-3 text-text-muted",children:"—"}),(0,d.jsx)("td",{className:"px-6 py-3 text-text-muted",children:"—"}),(0,d.jsx)("td",{className:"px-6 py-3 text-right",children:m(a.summary.requests)}),(0,d.jsx)("td",{className:"px-6 py-3 text-right text-text-muted whitespace-nowrap",children:o(a.summary.lastUsed)})]}),renderDetailCells:a=>(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("td",{className:"px-6 py-3 font-medium",children:a.keyName}),(0,d.jsx)("td",{className:"px-6 py-3",children:a.rawModel}),(0,d.jsx)("td",{className:"px-6 py-3",children:(0,d.jsx)(h.default,{variant:"neutral",size:"sm",children:a.provider})}),(0,d.jsx)("td",{className:"px-6 py-3 text-right",children:m(a.requests)}),(0,d.jsx)("td",{className:"px-6 py-3 text-right text-text-muted whitespace-nowrap",children:o(a.lastUsed)})]})};default:return{columns:P,groupedData:L(K(n.byEndpoint,{},k,l),"endpoint"),storageKey:"usage-stats:expanded-endpoints",emptyMessage:"No endpoint usage recorded yet.",renderSummaryCells:a=>(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("td",{className:"px-6 py-3 text-text-muted",children:"—"}),(0,d.jsx)("td",{className:"px-6 py-3 text-text-muted",children:"—"}),(0,d.jsx)("td",{className:"px-6 py-3 text-right",children:m(a.summary.requests)}),(0,d.jsx)("td",{className:"px-6 py-3 text-right text-text-muted whitespace-nowrap",children:o(a.summary.lastUsed)})]}),renderDetailCells:a=>(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("td",{className:"px-6 py-3 font-medium font-mono text-sm",children:a.endpoint}),(0,d.jsx)("td",{className:"px-6 py-3",children:a.rawModel}),(0,d.jsx)("td",{className:"px-6 py-3",children:(0,d.jsx)(h.default,{variant:"neutral",size:"sm",children:a.provider})}),(0,d.jsx)("td",{className:"px-6 py-3 text-right",children:m(a.requests)}),(0,d.jsx)("td",{className:"px-6 py-3 text-right text-text-muted whitespace-nowrap",children:o(a.lastUsed)})]})}}},[n,W,k,l]);if(!n&&!q)return(0,d.jsx)("div",{className:"text-text-muted",children:"Failed to load usage statistics."});let Z=(0,d.jsx)("div",{className:"flex items-center justify-center py-12 text-text-muted",children:(0,d.jsx)("span",{className:"material-symbols-outlined text-[32px] animate-spin",children:"progress_activity"})});return(0,d.jsxs)("div",{className:"flex min-w-0 flex-col gap-6",children:[!c&&(0,d.jsxs)("div",{className:"flex w-full items-center gap-2 sm:w-auto sm:self-end",children:[(0,d.jsx)("div",{className:"grid flex-1 grid-cols-5 items-center gap-1 rounded-lg border border-border bg-bg-subtle p-1 sm:flex sm:flex-none",children:R.map(a=>(0,d.jsx)("button",{onClick:()=>F(a.value),disabled:t,className:`rounded-md px-3 py-1 text-sm font-medium transition-colors ${E===a.value?"bg-primary text-white shadow-sm":"text-text-muted hover:bg-bg-hover hover:text-text"}`,children:a.label},a.value))}),t&&(0,d.jsx)("span",{className:"material-symbols-outlined text-[16px] text-text-muted animate-spin",children:"progress_activity"})]}),q?Z:(0,d.jsx)(j.A,{stats:n}),!T||V||q?null:(0,d.jsxs)("div",{className:"grid min-w-0 grid-cols-1 items-stretch gap-2 lg:grid-cols-[minmax(0,2fr)_minmax(280px,1fr)]",children:[(0,d.jsx)(x,{providers:A,activeRequests:n.activeRequests||[],lastProvider:n.recentRequests?.[0]?.provider||"",errorProvider:n.errorProvider||""}),(0,d.jsx)(J,{requests:n.recentRequests||[]})]}),q?Z:(0,d.jsx)(H,{period:E}),(0,d.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,d.jsxs)("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between",children:[T?V?(0,d.jsx)("div",{className:"w-full rounded-lg border border-border bg-bg-subtle px-3 py-1.5 text-sm font-medium text-text sm:w-auto",children:"Usage by API Key"}):(0,d.jsx)("select",{value:v,onChange:a=>w(a.target.value),className:"w-full rounded-lg border border-border bg-bg-subtle px-3 py-1.5 text-sm font-medium text-text focus:outline-none focus:ring-2 focus:ring-primary/50 sm:w-auto",children:Q.map(a=>(0,d.jsx)("option",{value:a.value,children:a.label},a.value))}):(0,d.jsx)("div",{className:"h-[38px]"}),(0,d.jsxs)("div",{className:"grid grid-cols-2 items-center gap-1 rounded-lg border border-border bg-bg-subtle p-1 sm:flex",children:[(0,d.jsx)("button",{onClick:()=>z("costs"),className:`px-3 py-1 rounded-md text-sm font-medium transition-colors ${"costs"===y?"bg-primary text-white shadow-sm":"text-text-muted hover:text-text hover:bg-bg-hover"}`,children:"Costs"}),(0,d.jsx)("button",{onClick:()=>z("tokens"),className:`px-3 py-1 rounded-md text-sm font-medium transition-colors ${"tokens"===y?"bg-primary text-white shadow-sm":"text-text-muted hover:text-text hover:bg-bg-hover"}`,children:"Tokens"})]})]}),q?Z:Y&&(0,d.jsx)(r,{title:"",columns:Y.columns,groupedData:Y.groupedData,tableType:W,sortBy:k,sortOrder:l,onToggleSort:X,viewMode:y,storageKey:Y.storageKey,renderSummaryCells:Y.renderSummaryCells,renderDetailCells:Y.renderDetailCells,emptyMessage:Y.emptyMessage})]})]})}},31402:(a,b,c)=>{c.d(b,{default:()=>k});var d=c(48249),e=c(67484),f=c(49885),g=c.n(f),h=c(50412),i=c(66828),j=c(45390);function k({isOpen:a,onClose:b,onCreated:c,onSaved:f,node:g}){let l=!!g,[m,n]=(0,e.useState)({name:"",prefix:"",baseUrl:"https://api.openai.com/v1",defaultSize:""}),[o,p]=(0,e.useState)(""),[q,r]=(0,e.useState)(""),[s,t]=(0,e.useState)(!1),[u,v]=(0,e.useState)(""),[w,x]=(0,e.useState)(""),[y,z]=(0,e.useState)(!1),[A,B]=(0,e.useState)(null),C=async()=>{if(m.name.trim()&&m.prefix.trim()&&m.baseUrl.trim()){t(!0);try{let a=l?`/api/provider-nodes/${g.id}`:"/api/provider-nodes",b={name:m.name,prefix:m.prefix,baseUrl:m.baseUrl,defaultSize:m.defaultSize.trim()};l||(b.type="custom-image");let d=await fetch(a,{method:l?"PUT":"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(b)}),e=await d.json();d.ok&&(l?f?.(e.node):c?.(e.node))}catch(a){console.log("Error saving custom image node:",a)}finally{t(!1)}}},D=async()=>{z(!0);try{let a=await fetch("/api/provider-nodes/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({baseUrl:m.baseUrl,apiKey:u,type:"custom-image",modelId:w.trim()||void 0,imageSize:m.defaultSize.trim()||void 0})}),b=await a.json();b.normalizedBaseUrl&&n(a=>({...a,baseUrl:b.normalizedBaseUrl})),B(b)}catch{B({valid:!1,error:"Network error"})}finally{z(!1)}};return(0,d.jsx)(h.aF,{isOpen:a,title:l?"Edit Custom Image":"Add Custom Image",onClose:b,children:(0,d.jsxs)("div",{className:"flex flex-col gap-4",children:[!l&&(0,d.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,d.jsx)("label",{className:"text-sm font-medium text-text-main",children:"Import From cURL"}),(0,d.jsx)("textarea",{value:o,onChange:a=>p(a.target.value),placeholder:'curl https://api.example.com/v1/images/generations -H "Authorization: Bearer sk-xxx" -H "Content-Type: application/json" -d \'{"model":"gpt-image-1","prompt":"A cute cat","size":"1024x1024","n":1}\'',className:"min-h-32 w-full rounded-lg border border-border bg-surface px-3 py-2 text-sm focus:outline-none focus:ring-1 focus:ring-primary/50"}),(0,d.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,d.jsx)("p",{className:"text-xs text-text-muted",children:"Paste a working OpenAI-compatible image curl command to auto-fill fields."}),(0,d.jsx)(h.$n,{onClick:()=>{try{let a=(0,j.rk)(o);n({name:a.defaultName,prefix:a.defaultPrefix,baseUrl:a.baseUrl,defaultSize:a.imageSize||""}),v(a.apiKey||""),x(a.modelId||""),r("")}catch(a){r(a.message||"Failed to parse curl")}},variant:"secondary",children:"Parse cURL"})]}),q&&(0,d.jsx)("p",{className:"text-sm text-red-500",children:q})]}),(0,d.jsx)(h.pd,{label:"Name",value:m.name,onChange:a=>n({...m,name:a.target.value}),placeholder:"SenseNova Image",hint:"Required. A friendly label for this image provider."}),(0,d.jsx)(h.pd,{label:"Prefix",value:m.prefix,onChange:a=>n({...m,prefix:a.target.value}),placeholder:"sensenova",hint:"Required. Used as the provider prefix for model IDs (e.g. sensenova/sensenova-u1-fast)."}),(0,d.jsx)(h.pd,{label:"Base URL",value:m.baseUrl,onChange:a=>n({...m,baseUrl:a.target.value}),placeholder:"https://token.sensenova.cn/v1",hint:"The app will append /images/generations automatically."}),(0,d.jsxs)("div",{children:[(0,d.jsx)("label",{className:"text-xs text-text-muted mb-1 block",children:"Default Size"}),(0,d.jsxs)("select",{className:"w-full px-3 py-2 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary",value:m.defaultSize,onChange:a=>n({...m,defaultSize:a.target.value}),children:[(0,d.jsx)("option",{value:"",children:"Use fallback"}),i.z.filter(a=>"auto"!==a).map(a=>(0,d.jsx)("option",{value:a,children:a},a))]}),(0,d.jsx)("p",{className:"mt-1 text-xs text-text-muted",children:"Used by model test and request example for vendors with restricted sizes."})]}),(0,d.jsx)(h.pd,{label:"API Key (for Check)",type:"password",value:u,onChange:a=>v(a.target.value)}),(0,d.jsx)(h.pd,{label:"Model ID (for Check)",value:w,onChange:a=>x(a.target.value),placeholder:"e.g. sensenova-u1-fast",hint:"Required for validation. Will send a test image generation request."}),(0,d.jsxs)("div",{className:"flex items-center gap-3",children:[(0,d.jsx)(h.$n,{onClick:D,disabled:!u||!w.trim()||y||!m.baseUrl.trim(),variant:"secondary",children:y?"Checking...":"Check"}),(()=>{if(!A)return null;let{valid:a,error:b}=A;return a?(0,d.jsx)(h.Ex,{variant:"success",children:"Valid"}):(0,d.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,d.jsx)(h.Ex,{variant:"error",children:"Invalid"}),b&&(0,d.jsx)("span",{className:"text-sm text-red-500",children:b})]})})()]}),(0,d.jsxs)("div",{className:"flex gap-2",children:[(0,d.jsx)(h.$n,{onClick:C,fullWidth:!0,disabled:!m.name.trim()||!m.prefix.trim()||!m.baseUrl.trim()||s,children:s?l?"Saving...":"Creating...":l?"Save":"Create"}),(0,d.jsx)(h.$n,{onClick:b,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})})}k.propTypes={isOpen:g().bool.isRequired,onClose:g().func.isRequired,onCreated:g().func,onSaved:g().func,node:g().shape({id:g().string,name:g().string,prefix:g().string,baseUrl:g().string,defaultSize:g().string})}},32971:(a,b,c)=>{c.d(b,{default:()=>e});var d=c(48249);function e({text:a,children:b,position:c="top",color:f}){let g=f?"":"bg-gray-900";return(0,d.jsxs)("div",{className:"relative inline-flex group",children:[b,(0,d.jsx)("div",{className:`pointer-events-none absolute ${{top:"bottom-full left-1/2 -translate-x-1/2 mb-1.5",bottom:"top-full left-1/2 -translate-x-1/2 mt-1.5",left:"right-full top-1/2 -translate-y-1/2 mr-1.5",right:"left-full top-1/2 -translate-y-1/2 ml-1.5"}[c]} z-50 w-max max-w-56 rounded px-2 py-1 text-[11px] leading-snug ${g} text-white opacity-0 group-hover:opacity-100 transition-opacity duration-150 whitespace-normal`,style:f?{backgroundColor:f}:{},children:a})]})}},37365:(a,b,c)=>{c.d(b,{C:()=>d});let d=(0,c(31417).v)(a=>({query:"",placeholder:"",visible:!1,setQuery:b=>a({query:b}),register:(b="Search...")=>a({visible:!0,placeholder:b,query:""}),unregister:()=>a({visible:!1,placeholder:"",query:""})}))},37900:(a,b,c)=>{c.d(b,{Od:()=>i,UserRoleProvider:()=>g,hd:()=>h});var d=c(48249),e=c(67484);let f=(0,e.createContext)({role:null,userId:null,displayName:null});function g({role:a,userId:b,displayName:c,children:h}){let[i,j]=(0,e.useState)({role:a,userId:b,displayName:c});return(0,d.jsx)(f.Provider,{value:i,children:h})}function h(){return(0,e.useContext)(f)}function i(){let{role:a}=(0,e.useContext)(f);return"super_admin"===a}},39645:(a,b,c)=>{c.d(b,{default:()=>i});var d=c(48249),e=c(67484),f=c(95145),g=c(99070),h=c(50377);function i({isOpen:a,onClose:b,title:c="Manual Configuration",configs:j=[]}){let{copy:k}=(0,h.C)(),[l,m]=(0,e.useState)(null);return(0,d.jsx)(f.default,{isOpen:a,onClose:b,title:c,size:"xl",children:(0,d.jsx)("div",{className:"flex flex-col gap-4",children:j.map((a,b)=>(0,d.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,d.jsxs)("div",{className:"flex items-center justify-between",children:[(0,d.jsx)("span",{className:"text-sm font-medium text-text-main",children:a.filename}),(0,d.jsxs)(g.default,{variant:"ghost",size:"sm",onClick:()=>{var c;return c=a.content,void(k(c,`manualconfig-${b}`),m(b),setTimeout(()=>m(null),2e3))},children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:l===b?"check":"content_copy"}),l===b?"Copied!":"Copy"]})]}),(0,d.jsx)("pre",{className:"px-3 py-2 bg-black/5 dark:bg-white/5 rounded font-mono text-xs overflow-x-auto whitespace-pre-wrap break-all max-h-60 overflow-y-auto border border-border",children:a.content})]},b))})})}},41371:(a,b,c)=>{c.d(b,{i:()=>f});var d=c(31417);let e=0,f=(0,d.v)((a,b)=>({notifications:[],addNotification:c=>{let d=++e,f={id:d,type:c.type||"info",message:c.message,title:c.title||null,duration:c.duration??5e3,dismissible:c.dismissible??!0,createdAt:Date.now()};return a(a=>({notifications:[...a.notifications,f]})),f.duration>0&&setTimeout(()=>b().removeNotification(d),f.duration),d},removeNotification:b=>{a(a=>({notifications:a.notifications.filter(a=>a.id!==b)}))},clearAll:()=>a({notifications:[]}),success:(a,c)=>b().addNotification({type:"success",message:a,title:c}),error:(a,c)=>b().addNotification({type:"error",message:a,title:c,duration:8e3}),warning:(a,c)=>b().addNotification({type:"warning",message:a,title:c}),info:(a,c)=>b().addNotification({type:"info",message:a,title:c})}))},42118:(a,b,c)=>{c.d(b,{D:()=>i});var d=c(67484),e=c(13033);function f(a){return()=>{}}function g(){return!1}function h(){return!1}function i(){let{theme:a,setTheme:b,toggleTheme:c,initTheme:i}=(0,e.A)(),j=(0,d.useSyncExternalStore)(f,g,h);return{theme:a,setTheme:b,toggleTheme:c,isDark:"dark"===a||"system"===a&&j}}},42196:(a,b,c)=>{c.d(b,{default:()=>w});var d=c(48249),e=c(67484),f=c(49885),g=c.n(f),h=c(2116),i=c.n(h),j=c(19099),k=c(71404),l=c(12020),m=c(96919),n=c(50377),o=c(37900),p=c(99070),q=c(95145);let r=["embedding","image","tts","stt"],s="/dashboard/media-providers/web",t=[{href:"/dashboard/endpoint",label:"Endpoint",icon:"api"},{href:"/dashboard/providers",label:"Providers",icon:"dns"},{href:"/dashboard/combos",label:"Combos",icon:"layers"},{href:"/dashboard/usage",label:"Usage",icon:"bar_chart"},{href:"/dashboard/quota",label:"Quota Tracker",icon:"data_usage"},{href:"/dashboard/mitm",label:"MITM",icon:"security"},{href:"/dashboard/focus-ui",label:"Focus UI",icon:"visibility"},{href:"/dashboard/cli-tools",label:"CLI Tools",icon:"terminal"}],u=[{href:"/dashboard/network-analysis",label:"Network Analysis",icon:"network_check"},{href:"/dashboard/console-log",label:"Console Log",icon:"terminal"},{href:"/dashboard/translator",label:"Translator",icon:"translate"}],v=[{href:"/dashboard/proxy-pools",label:"Proxy Pools",icon:"lan"},{href:"/dashboard/skills",label:"Skills",icon:"extension"}];function w({onClose:a,collapsed:b=!1,onCollapsedChange:c}){let f=(0,j.usePathname)(),g=(0,o.Od)(),{permissions:h=[]}=(0,o.hd)(),y=g||h.includes("view_usage"),z=g?t:t.filter(a=>"/dashboard/usage"===a.href?y:!["/dashboard/providers","/dashboard/combos","/dashboard/mitm","/dashboard/focus-ui","/dashboard/cli-tools","/dashboard/proxy-pools","/dashboard/quota","/dashboard/network-analysis"].includes(a.href)),[A,B]=(0,e.useState)(!1),[C,D]=(0,e.useState)(!1),[E,F]=(0,e.useState)(!1),[G,H]=(0,e.useState)(!1),[I,J]=(0,e.useState)(null),[K,L]=(0,e.useState)(!1),[M,N]=(0,e.useState)(!1),[O,P]=(0,e.useState)(0),[Q,R]=(0,e.useState)(!1),{copied:S,copy:T}=(0,n.C)(2e3),U=l.h0.installCmdLatest||l.h0.installCmd,V=a=>"/dashboard/endpoint"===a?"/dashboard"===f||f.startsWith("/dashboard/endpoint"):f.startsWith(a),W=async()=>{try{await navigator.clipboard.writeText(U)}catch{}T(U);let a=l.h0.shutdownCountdownSec;P(a);let b=setInterval(()=>{P(a-=1),a<=0&&(clearInterval(b),fetch("/api/version/shutdown",{method:"POST"}).catch(()=>{}),H(!0))},1e3)},X=async()=>{F(!0);try{await fetch("/api/version/shutdown",{method:"POST"})}catch(a){}F(!1),D(!1),H(!0)};return(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("aside",{className:(0,k.cn)("flex flex-col border-r border-border-subtle bg-vibrancy backdrop-blur-xl transition-all duration-300 min-h-full",b?"w-20":"w-72"),children:[(0,d.jsxs)("div",{className:(0,k.cn)("flex items-center px-6 pt-5 pb-2",b?"justify-center":"justify-between"),children:[!b&&(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("div",{className:"w-3 h-3 rounded-full bg-[#FF5F56]"}),(0,d.jsx)("div",{className:"w-3 h-3 rounded-full bg-[#FFBD2E]"}),(0,d.jsx)("div",{className:"w-3 h-3 rounded-full bg-[#27C93F]"})]}),"function"==typeof c&&(0,d.jsx)("button",{type:"button",onClick:()=>c(!b),className:"flex size-8 items-center justify-center rounded-lg text-text-muted transition-colors hover:bg-surface-2 hover:text-text-main","aria-label":b?"Expand sidebar":"Collapse sidebar",title:b?"Expand sidebar":"Collapse sidebar",children:(0,d.jsx)("span",{className:"material-symbols-outlined text-[20px]",children:b?"left_panel_open":"left_panel_close"})})]}),(0,d.jsxs)("div",{className:(0,k.cn)("py-4 flex flex-col gap-2",b?"px-0 items-center":"px-6"),children:[(0,d.jsxs)(i(),{href:"/dashboard",className:(0,k.cn)("flex items-center",b?"justify-center":"gap-3"),children:[(0,d.jsx)("div",{className:"flex items-center justify-center size-9 rounded-[10px] bg-gradient-to-br from-brand-500 to-brand-700 shadow-[var(--shadow-warm)]",children:(0,d.jsx)("span",{className:"material-symbols-outlined text-white text-[20px]",children:"hub"})}),(0,d.jsxs)("div",{className:(0,k.cn)("flex flex-col",b&&"hidden"),children:[(0,d.jsx)("h1",{className:"text-lg font-semibold tracking-tight text-text-main",children:l.vQ.name}),(0,d.jsxs)("span",{className:"text-xs text-text-muted",children:["v",l.vQ.version]})]})]}),I&&!b&&(0,d.jsxs)("div",{className:"flex flex-col gap-1.5 rounded p-1 -m-1",children:[(0,d.jsxs)("span",{className:"text-xs font-semibold text-green-600 dark:text-amber-500",children:["↑ New version available: v",I.latestVersion]}),(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("button",{onClick:()=>L(!0),className:"px-2 py-1 rounded bg-green-600 hover:bg-green-700 dark:bg-amber-500 dark:hover:bg-amber-600 text-white text-[11px] font-semibold transition-colors cursor-pointer",children:"Update now"}),(0,d.jsx)("button",{onClick:()=>T(U),title:"Copy install command",className:"flex-1 text-left hover:opacity-80 transition-opacity cursor-pointer min-w-0",children:(0,d.jsx)("code",{className:"block text-[10px] text-green-600/80 dark:text-amber-400/70 font-mono truncate",children:S?"✓ copied!":U})})]})]})]}),(0,d.jsxs)("nav",{className:(0,k.cn)("flex-1 py-2 space-y-1 overflow-y-auto custom-scrollbar",b?"px-3":"px-4"),children:[z.map(c=>(0,d.jsxs)(i(),{href:c.href,onClick:a,title:b?c.label:void 0,className:(0,k.cn)("flex items-center rounded-lg transition-all group",b?"justify-center px-0 py-2":"gap-3 px-3 py-1",V(c.href)?"bg-primary/10 text-primary":"text-text-muted hover:bg-surface-2 hover:text-text-main"),children:[(0,d.jsx)("span",{className:(0,k.cn)("material-symbols-outlined text-[18px]",V(c.href)?"fill-1":"group-hover:text-primary transition-colors"),children:c.icon}),(0,d.jsx)("span",{className:(0,k.cn)("text-[13px] font-medium",b&&"hidden"),children:c.label})]},c.href)),g&&(0,d.jsxs)("div",{className:"pt-4 mt-2",children:[(0,d.jsx)("p",{className:(0,k.cn)("px-4 text-xs font-semibold text-text-muted/60 uppercase tracking-wider mb-2",b&&"hidden"),children:"Admin"}),[{href:"/dashboard/admin/users",label:"User Management",icon:"manage_accounts"},{href:"/dashboard/admin/keys",label:"Key Management",icon:"key"}].map(c=>(0,d.jsxs)(i(),{href:c.href,onClick:a,title:b?c.label:void 0,className:(0,k.cn)("flex items-center rounded-lg transition-all group",b?"justify-center px-0 py-2":"gap-3 px-4 py-2",V(c.href)?"bg-primary/10 text-primary":"text-text-muted hover:bg-surface/50 hover:text-text-main"),children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[18px] group-hover:text-primary transition-colors",children:c.icon}),(0,d.jsx)("span",{className:(0,k.cn)("text-sm font-medium",b&&"hidden"),children:c.label})]},c.href))]}),(0,d.jsxs)("div",{className:"pt-3 mt-2 space-y-0.5",children:[(0,d.jsx)("p",{className:(0,k.cn)("px-4 text-xs font-semibold text-text-muted/60 uppercase tracking-wider mb-2",b&&"hidden"),children:"System"}),(0,d.jsxs)("button",{onClick:()=>B(a=>!a),title:b?"Media Providers":void 0,className:(0,k.cn)("w-full flex items-center rounded-lg transition-all group",b?"justify-center px-0 py-2":"gap-3 px-3 py-1",f.startsWith("/dashboard/media-providers")?"bg-primary/10 text-primary":"text-text-muted hover:bg-surface-2 hover:text-text-main"),children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"perm_media"}),(0,d.jsx)("span",{className:(0,k.cn)("text-[13px] font-medium flex-1 text-left",b&&"hidden"),children:"Media Providers"}),(0,d.jsx)("span",{className:(0,k.cn)("material-symbols-outlined text-[14px] transition-transform",b&&"hidden"),style:{transform:A?"rotate(180deg)":"rotate(0deg)"},children:"expand_more"})]}),A&&!b&&(0,d.jsxs)("div",{className:"pl-4",children:[m.rj.filter(a=>r.includes(a.id)).map(b=>(0,d.jsxs)(i(),{href:`/dashboard/media-providers/${b.id}`,onClick:a,className:(0,k.cn)("flex items-center gap-3 px-4 py-1 rounded-lg transition-all group",f.startsWith(`/dashboard/media-providers/${b.id}`)?"bg-primary/10 text-primary":"text-text-muted hover:bg-surface-2 hover:text-text-main"),children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:b.icon}),(0,d.jsx)("span",{className:"text-sm",children:b.label})]},b.id)),(0,d.jsxs)(i(),{href:s,onClick:a,className:(0,k.cn)("flex items-center gap-3 px-4 py-1 rounded-lg transition-all group",f.startsWith(s)?"bg-primary/10 text-primary":"text-text-muted hover:bg-surface-2 hover:text-text-main"),children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"travel_explore"}),(0,d.jsx)("span",{className:"text-sm",children:"Web Fetch & Search"})]},"web")]}),v.map(c=>(0,d.jsxs)(i(),{href:c.href,onClick:a,title:b?c.label:void 0,className:(0,k.cn)("flex items-center rounded-lg transition-all group",b?"justify-center px-0 py-2":"gap-3 px-3 py-1",V(c.href)?"bg-primary/10 text-primary":"text-text-muted hover:bg-surface-2 hover:text-text-main"),children:[(0,d.jsx)("span",{className:(0,k.cn)("material-symbols-outlined text-[18px]",V(c.href)?"fill-1":"group-hover:text-primary transition-colors"),children:c.icon}),(0,d.jsx)("span",{className:(0,k.cn)("text-[13px] font-medium",b&&"hidden"),children:c.label})]},c.href)),u.map(c=>"/dashboard/translator"!==c.href||Q?(0,d.jsxs)(i(),{href:c.href,onClick:a,title:b?c.label:void 0,className:(0,k.cn)("flex items-center rounded-lg transition-all group",b?"justify-center px-0 py-2":"gap-3 px-4 py-2",V(c.href)?"bg-primary/10 text-primary":"text-text-muted hover:bg-surface/50 hover:text-text-main"),children:[(0,d.jsx)("span",{className:(0,k.cn)("material-symbols-outlined text-[18px]",V(c.href)?"fill-1":"group-hover:text-primary transition-colors"),children:c.icon}),(0,d.jsx)("span",{className:(0,k.cn)("text-sm font-medium",b&&"hidden"),children:c.label})]},c.href):null),(0,d.jsxs)(i(),{href:"/dashboard/profile",onClick:a,title:b?"Settings":void 0,className:(0,k.cn)("flex items-center rounded-lg transition-all group",b?"justify-center px-0 py-2":"gap-3 px-3 py-1",V("/dashboard/profile")?"bg-primary/10 text-primary":"text-text-muted hover:bg-surface-2 hover:text-text-main"),children:[(0,d.jsx)("span",{className:(0,k.cn)("material-symbols-outlined text-[18px]",V("/dashboard/profile")?"fill-1":"group-hover:text-primary transition-colors"),children:"settings"}),(0,d.jsx)("span",{className:(0,k.cn)("text-[13px] font-medium",b&&"hidden"),children:"Settings"})]})]})]}),(0,d.jsx)("div",{className:"p-3 border-t border-border-subtle",children:b?(0,d.jsx)("button",{type:"button",onClick:()=>D(!0),className:"flex size-10 w-full items-center justify-center rounded-lg border border-red-200 text-red-500 transition-colors hover:bg-red-50 hover:border-red-300","aria-label":"Shutdown",title:"Shutdown",children:(0,d.jsx)("span",{className:"material-symbols-outlined text-[20px]",children:"power_settings_new"})}):(0,d.jsx)(p.default,{variant:"outline",fullWidth:!0,icon:"power_settings_new",onClick:()=>D(!0),className:"text-red-500 border-red-200 hover:bg-red-50 hover:border-red-300",children:"Shutdown"})})]}),(0,d.jsx)(q.ConfirmModal,{isOpen:C,onClose:()=>D(!1),onConfirm:X,title:"Close Proxy",message:"Are you sure you want to close the proxy server?",confirmText:"Close",cancelText:"Cancel",variant:"danger",loading:E}),(0,d.jsx)(q.ConfirmModal,{isOpen:K,onClose:()=>L(!1),onConfirm:()=>{L(!1),N(!0)},title:"Update OpenrouterX",message:`Show install command for v${I?.latestVersion||""}? You can copy it and shutdown to install manually.`,confirmText:"Show Command",cancelText:"Cancel",variant:"primary"}),(G||M)&&(0,d.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/80 backdrop-blur-sm p-6",children:M?(0,d.jsx)(x,{latestVersion:I?.latestVersion,installCmd:U,copied:S,onCopyAndShutdown:W,onCancel:()=>{N(!1),P(0)},countdown:O,isDisconnected:G}):(0,d.jsxs)("div",{className:"text-center p-8",children:[(0,d.jsx)("div",{className:"flex items-center justify-center size-16 rounded-full bg-red-500/20 text-red-500 mx-auto mb-4",children:(0,d.jsx)("span",{className:"material-symbols-outlined text-[32px]",children:"power_off"})}),(0,d.jsx)("h2",{className:"text-xl font-semibold text-white mb-2",children:"Server Disconnected"}),(0,d.jsx)("p",{className:"text-text-muted mb-6",children:"The proxy server has been stopped."}),(0,d.jsx)(p.default,{variant:"secondary",onClick:()=>globalThis.location.reload(),children:"Reload Page"})]})})]})}function x({latestVersion:a,installCmd:b,copied:c,onCopyAndShutdown:e,onCancel:f,countdown:g,isDisconnected:h}){let i=g>0;return(0,d.jsxs)("div",{className:"w-full max-w-lg rounded-xl bg-neutral-900/95 border border-white/10 p-6 text-white",children:[(0,d.jsxs)("div",{className:"flex items-center gap-3 mb-4",children:[(0,d.jsx)("div",{className:"flex items-center justify-center size-11 rounded-full bg-amber-500/20 text-amber-400",children:(0,d.jsx)("span",{className:"material-symbols-outlined text-[24px]",children:"content_copy"})}),(0,d.jsxs)("div",{children:[(0,d.jsxs)("h2",{className:"text-lg font-semibold",children:["Update OpenrouterX",a?` to v${a}`:""]}),(0,d.jsx)("p",{className:"text-xs text-white/60",children:h?"Server stopped. Paste the command into a terminal to install.":i?`Command copied. Server will stop in ${g}s...`:"Click the button below to copy the install command and shutdown."})]})]}),(0,d.jsx)("p",{className:"text-sm text-white/80 mb-2",children:"Install command:"}),(0,d.jsx)("div",{className:"w-full px-3 py-2 rounded bg-white/5 mb-4",children:(0,d.jsx)("code",{className:"text-xs font-mono text-amber-400 break-all",children:b})}),(0,d.jsxs)("ol",{className:"text-xs text-white/70 space-y-1 list-decimal list-inside mb-4",children:[(0,d.jsxs)("li",{children:["Click ",(0,d.jsx)("strong",{children:"Copy & Shutdown"})," below."]}),(0,d.jsx)("li",{children:"Paste the command into your terminal and press Enter."}),(0,d.jsxs)("li",{children:["Run ",(0,d.jsx)("code",{className:"px-1 rounded bg-white/10 text-green-400",children:"openrouterX"})," again after install."]})]}),h?(0,d.jsx)(p.default,{variant:"secondary",fullWidth:!0,onClick:()=>globalThis.location.reload(),children:"Reload Page"}):(0,d.jsxs)("div",{className:"flex gap-2",children:[(0,d.jsx)(p.default,{variant:"secondary",onClick:f,disabled:i,children:"Cancel"}),(0,d.jsx)(p.default,{variant:"primary",fullWidth:!0,onClick:e,disabled:i,children:c?"✓ Copied — shutting down...":i?`Shutting down in ${g}s`:"Copy & Shutdown"})]})]})}w.propTypes={onClose:g().func,collapsed:g().bool,onCollapsedChange:g().func},x.propTypes={latestVersion:g().string,installCmd:g().string.isRequired,copied:g().bool,onCopyAndShutdown:g().func.isRequired,onCancel:g().func.isRequired,countdown:g().number,isDisconnected:g().bool}},43182:(a,b,c)=>{c.d(b,{default:()=>j});var d=c(48249),e=c(67484),f=c(49885),g=c.n(f),h=c(50412);let i="https://gitlab.com";function j({isOpen:a,providerInfo:b,onSuccess:c,onClose:f}){let[g,k]=(0,e.useState)(null),[l,m]=(0,e.useState)(i),[n,o]=(0,e.useState)(""),[p,q]=(0,e.useState)(""),[r,s]=(0,e.useState)(""),[t,u]=(0,e.useState)(!1),[v,w]=(0,e.useState)(null),[x,y]=(0,e.useState)(!1),[z,A]=(0,e.useState)(null),B=()=>{k(null),m(i),o(""),q(""),s(""),w(null),u(!1),y(!1),A(null),f()},C=async()=>{if(!r.trim())return void w("Personal Access Token is required");u(!0),w(null);try{let a=await fetch("/api/oauth/gitlab/pat",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({token:r.trim(),baseUrl:l.trim()||i})}),b=await a.json();if(!a.ok)throw Error(b.error||"Authentication failed");c?.(),B()}catch(a){w(a.message)}finally{u(!1)}};return a?x&&z?(0,d.jsx)(h.LF,{isOpen:!0,provider:"gitlab",providerInfo:b,oauthMeta:z,onSuccess:()=>{c?.(),B()},onClose:()=>{y(!1),A(null)}}):(0,d.jsx)(h.aF,{isOpen:a,title:"Connect GitLab Duo",onClose:B,size:"lg",children:(0,d.jsxs)("div",{className:"flex flex-col gap-4",children:[!g&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("p",{className:"text-sm text-text-muted",children:"Choose how to authenticate with GitLab Duo:"}),(0,d.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,d.jsxs)("button",{onClick:()=>k("oauth"),className:"flex flex-col items-center gap-2 p-4 rounded-lg border border-border hover:border-primary hover:bg-primary/5 transition-colors text-left",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-2xl text-primary",children:"lock_open"}),(0,d.jsxs)("div",{children:[(0,d.jsx)("p",{className:"text-sm font-medium",children:"OAuth App"}),(0,d.jsx)("p",{className:"text-xs text-text-muted",children:"Use a GitLab OAuth application"})]})]}),(0,d.jsxs)("button",{onClick:()=>k("pat"),className:"flex flex-col items-center gap-2 p-4 rounded-lg border border-border hover:border-primary hover:bg-primary/5 transition-colors text-left",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-2xl text-primary",children:"key"}),(0,d.jsxs)("div",{children:[(0,d.jsx)("p",{className:"text-sm font-medium",children:"Personal Access Token"}),(0,d.jsx)("p",{className:"text-xs text-text-muted",children:"Use a GitLab PAT with api scope"})]})]})]})]}),"oauth"===g&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("p",{className:"text-xs text-text-muted",children:["Create an OAuth app at"," ",(0,d.jsx)("a",{href:`${l.trim()||i}/-/profile/applications`,target:"_blank",rel:"noreferrer",className:"text-primary underline",children:"GitLab Applications"})," ","with redirect URI"," ",(0,d.jsx)("code",{className:"bg-sidebar px-1 rounded text-xs",children:"http://localhost/callback"})]}),(0,d.jsx)(h.pd,{label:"GitLab Base URL",value:l,onChange:a=>m(a.target.value),placeholder:i}),(0,d.jsx)(h.pd,{label:"Client ID",value:n,onChange:a=>o(a.target.value),placeholder:"Your OAuth application client ID"}),(0,d.jsx)(h.pd,{label:"Client Secret (optional for PKCE)",value:p,onChange:a=>q(a.target.value),placeholder:"Leave empty for public PKCE app"}),v&&(0,d.jsx)("p",{className:"text-sm text-red-500",children:v}),(0,d.jsxs)("div",{className:"flex gap-2",children:[(0,d.jsx)(h.$n,{onClick:()=>{n.trim()?(w(null),A({baseUrl:l.trim()||i,clientId:n.trim(),clientSecret:p.trim()}),y(!0)):w("Client ID is required")},fullWidth:!0,disabled:!n.trim(),children:"Authorize"}),(0,d.jsx)(h.$n,{onClick:()=>{k(null),w(null)},variant:"ghost",fullWidth:!0,children:"Back"})]})]}),"pat"===g&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("p",{className:"text-xs text-text-muted",children:["Create a PAT at"," ",(0,d.jsx)("a",{href:`${l.trim()||i}/-/user_settings/personal_access_tokens`,target:"_blank",rel:"noreferrer",className:"text-primary underline",children:"GitLab Access Tokens"})," ","with scopes: ",(0,d.jsx)("code",{className:"bg-sidebar px-1 rounded text-xs",children:"api"}),","," ",(0,d.jsx)("code",{className:"bg-sidebar px-1 rounded text-xs",children:"read_user"}),", and"," ",(0,d.jsx)("code",{className:"bg-sidebar px-1 rounded text-xs",children:"ai_features"}),"."]}),(0,d.jsx)(h.pd,{label:"GitLab Base URL",value:l,onChange:a=>m(a.target.value),placeholder:i}),(0,d.jsx)(h.pd,{label:"Personal Access Token",value:r,onChange:a=>s(a.target.value),placeholder:"glpat-xxxxxxxxxxxxxxxxxxxx",type:"password"}),v&&(0,d.jsx)("p",{className:"text-sm text-red-500",children:v}),(0,d.jsxs)("div",{className:"flex gap-2",children:[(0,d.jsx)(h.$n,{onClick:C,fullWidth:!0,disabled:!r.trim()||t,loading:t,children:"Connect"}),(0,d.jsx)(h.$n,{onClick:()=>{k(null),w(null)},variant:"ghost",fullWidth:!0,children:"Back"})]})]})]})}):null}j.propTypes={isOpen:g().bool.isRequired,providerInfo:g().shape({name:g().string}),onSuccess:g().func,onClose:g().func.isRequired}},45390:(a,b,c)=>{c.d(b,{Sq:()=>n,rk:()=>o});let d="openai-compatible",e="anthropic-compatible",f="custom-image";function g(a=""){return String(a).trim().replace(/\/+$/,"")}function h(a){try{return new URL(String(a).trim())}catch{return null}}function i(a,b=d){let c=h(a);if(!c)return g(a);let j=b===e?function(a=""){let b=g(a);for(let a of["/messages","/models"])if(b.endsWith(a)){b=b.slice(0,-a.length);break}return b||""}(c.pathname):b===f?function(a=""){let b=g(a);for(let a of["/images/generations","/images/edits"])if(b.endsWith(a)){b=b.slice(0,-a.length);break}return b||""}(c.pathname):function(a=""){let b=g(a);for(let a of["/chat/completions","/responses","/models"])if(b.endsWith(a)){b=b.slice(0,-a.length);break}return b||""}(c.pathname);return`${c.origin}${j}`.replace(/\/+$/,"")}function j(a){let b=[],c="",d=null,e=!1,f=()=>{c&&(b.push(c),c="")};for(let b=0;b<a.length;b+=1){let g=a[b];if(e){c+=g,e=!1;continue}if("'"===d){"'"===g?d=null:c+=g;continue}if('"'===d||"`"===d){g===d?d=null:"\\"===g&&'"'===d?e=!0:c+=g;continue}if("\\"===g&&b+1<a.length){e=!0;continue}if("'"===g||'"'===g||"`"===g){d=g;continue}if(/\s/.test(g)){f();continue}c+=g}return f(),b}function k(a=""){let b=a.indexOf(":");if(-1===b)return null;let c=a.slice(0,b).trim(),d=a.slice(b+1).trim();return c?{key:c,value:d}:null}function l(a){if(!a)return null;try{return JSON.parse(a)}catch{return null}}function m(a="",b=d){let c=String(a).toLowerCase().replace(/^api\./,"").replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||"compatible";return b===e?`ac-${c}`:b===f?`img-${c}`:`oc-${c}`}function n(a){let b=String(a||"").trim();if(!b)throw Error("cURL command is required");let c=j(b.replace(/\\\s*\n/g," ").replace(/\r?\n/g," ").trim());if(0===c.length||"curl"!==c[0])throw Error("Please paste a valid curl command");let f="GET",n="",o="",p={};for(let a=1;a<c.length;a+=1){let b=c[a];if(("-X"===b||"--request"===b)&&c[a+1]){f=c[a+1].toUpperCase(),a+=1;continue}if(("--url"===b||"--location"===b||"--url-query"===b)&&c[a+1]){"--url"===b&&(n=c[a+1]),a+=1;continue}if(("-H"===b||"--header"===b)&&c[a+1]){let b=k(c[a+1]);b&&(p[b.key.toLowerCase()]=b.value),a+=1;continue}if(("-d"===b||"--data"===b||"--data-raw"===b||"--data-binary"===b||"--data-ascii"===b)&&c[a+1]){o=c[a+1],a+=1;continue}!n&&/^https?:\/\//i.test(b)&&(n=b)}if(!n)throw Error("Could not find request URL in curl command");o&&"GET"===f&&(f="POST");let q=l(o),r=h(n),s=g(r?.pathname||""),t=p["anthropic-version"]||s.endsWith("/messages")?e:d,u=t===d?function({url:a="",body:b=null}={}){let c=h(a),d=g(c?.pathname||"");if(d.endsWith("/responses"))return"responses";if(d.endsWith("/chat/completions"))return"chat";if(b&&"object"==typeof b){if(!Array.isArray(b.messages)&&void 0!==b.input)return"responses";Array.isArray(b.messages)}return"chat"}({url:n,body:q}):null,v=p.authorization?.match(/^Bearer\s+(.+)$/i)?.[1]||p["x-api-key"]||"",w=q?.model?String(q.model):"",x=i(n,t),y=r?.hostname||"",z=`${y||"Imported"} ${t===e?"Anthropic":"OpenAI"} Compatible`;return{method:f,url:n,headers:p,body:q,type:t,apiType:u,apiKey:v,modelId:w,baseUrl:x,defaultName:z,defaultPrefix:m(y,t),defaultConnectionName:"Imported Key"}}function o(a){let b=String(a||"").trim();if(!b)throw Error("cURL command is required");let c=j(b.replace(/\\\s*\n/g," ").replace(/\r?\n/g," ").trim());if(0===c.length||"curl"!==c[0])throw Error("Please paste a valid curl command");let d="GET",e="",n="",o={};for(let a=1;a<c.length;a+=1){let b=c[a];if(("-X"===b||"--request"===b)&&c[a+1]){d=c[a+1].toUpperCase(),a+=1;continue}if(("--url"===b||"--location"===b)&&c[a+1]){"--url"===b&&(e=c[a+1]),a+=1;continue}if(("-H"===b||"--header"===b)&&c[a+1]){let b=k(c[a+1]);b&&(o[b.key.toLowerCase()]=b.value),a+=1;continue}if(("-d"===b||"--data"===b||"--data-raw"===b||"--data-binary"===b||"--data-ascii"===b)&&c[a+1]){n=c[a+1],a+=1;continue}!e&&/^https?:\/\//i.test(b)&&(e=b)}if(!e)throw Error("Could not find request URL in curl command");n&&"GET"===d&&(d="POST");let p=l(n),q=h(e),r=q?.hostname||"",s=o.authorization?.match(/^Bearer\s+(.+)$/i)?.[1]||o["x-api-key"]||"",t=p?.model?String(p.model):"";return{method:d,url:e,headers:o,body:p,type:f,apiKey:s,modelId:t,imageSize:p?.size?String(p.size):"",baseUrl:i(e,f),apiPath:function({url:a=""}={}){let b=h(a);return g(b?.pathname||"").endsWith("/images/edits")?"/images/edits":"/images/generations"}({url:e}),defaultName:`${r||"Imported"} Image Provider`,defaultPrefix:m(r,f),defaultConnectionName:"Imported Key"}}},48781:(a,b,c)=>{c.d(b,{default:()=>k});var d=c(48249),e=c(2116),f=c.n(e),g=c(12020);let h=[{label:"Features",href:"#features"},{label:"Pricing",href:"#pricing"},{label:"Changelog",href:"#"}],i=[{label:"Documentation",href:"#"},{label:"API Reference",href:"#"},{label:"Help Center",href:"#"}],j=[{label:"About",href:"#"},{label:"Blog",href:"#"},{label:"Contact",href:"#"}];function k(){return(0,d.jsx)("footer",{className:"bg-bg border-t border-border pt-16 pb-12",children:(0,d.jsxs)("div",{className:"container mx-auto px-4 sm:px-6 lg:px-8",children:[(0,d.jsxs)("div",{className:"grid grid-cols-2 md:grid-cols-4 lg:grid-cols-5 gap-10 mb-12",children:[(0,d.jsxs)("div",{className:"col-span-2 lg:col-span-2",children:[(0,d.jsxs)("div",{className:"flex items-center gap-2 mb-6",children:[(0,d.jsx)("div",{className:"size-6 text-primary",children:(0,d.jsx)("svg",{className:"w-full h-full",fill:"currentColor",viewBox:"0 0 48 48",children:(0,d.jsx)("path",{clipRule:"evenodd",d:"M12.0799 24L4 19.2479L9.95537 8.75216L18.04 13.4961L18.0446 4H29.9554L29.96 13.4961L38.0446 8.75216L44 19.2479L35.92 24L44 28.7521L38.0446 39.2479L29.96 34.5039L29.9554 44H18.0446L18.04 34.5039L9.95537 39.2479L4 28.7521L12.0799 24Z",fillRule:"evenodd"})})}),(0,d.jsx)("span",{className:"text-xl font-bold text-text-main",children:g.vQ.name})]}),(0,d.jsx)("p",{className:"text-text-muted mb-6 max-w-sm font-light",children:"The unified interface for modern AI infrastructure. Secure, observable, and scalable."}),(0,d.jsxs)("div",{className:"flex gap-4",children:[(0,d.jsx)("a",{href:"#",className:"text-gray-400 hover:text-primary transition-colors","aria-label":"Twitter",children:(0,d.jsx)("svg",{className:"w-5 h-5",fill:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{d:"M22.46 6c-.77.35-1.6.58-2.46.69.88-.53 1.56-1.37 1.88-2.38-.83.5-1.75.85-2.72 1.05C18.37 4.5 17.26 4 16 4c-2.35 0-4.27 1.92-4.27 4.29 0 .34.04.67.11.98C8.28 9.09 5.11 7.38 3 4.79c-.37.63-.58 1.37-.58 2.15 0 1.49.75 2.81 1.91 3.56-.71 0-1.37-.2-1.95-.5v.03c0 2.08 1.48 3.82 3.44 4.21a4.22 4.22 0 0 1-1.93.07 4.28 4.28 0 0 0 4 2.98 8.521 8.521 0 0 1-5.33 1.84c-.34 0-.68-.02-1.02-.06C3.44 20.29 5.7 21 8.12 21 16 21 20.33 14.46 20.33 8.79c0-.19 0-.37-.01-.56.84-.6 1.56-1.36 2.14-2.23z"})})}),(0,d.jsx)("a",{href:"#",className:"text-gray-400 hover:text-primary transition-colors","aria-label":"GitHub",children:(0,d.jsx)("svg",{className:"w-5 h-5",fill:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{d:"M12 2C6.477 2 2 6.484 2 12.017c0 4.425 2.865 8.18 6.839 9.504.5.092.682-.217.682-.483 0-.237-.008-.868-.013-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.029-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0 1 12 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.202 2.398.1 2.651.64.7 1.028 1.595 1.028 2.688 0 3.848-2.339 4.695-4.566 4.943.359.309.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.019 10.019 0 0 0 22 12.017C22 6.484 17.522 2 12 2z"})})})]})]}),(0,d.jsxs)("div",{children:[(0,d.jsx)("h4",{className:"font-semibold text-text-main mb-4",children:"Product"}),(0,d.jsx)("ul",{className:"flex flex-col gap-3 text-sm text-text-muted font-light",children:h.map(a=>(0,d.jsx)("li",{children:(0,d.jsx)(f(),{href:a.href,className:"hover:text-primary transition-colors",children:a.label})},a.label))})]}),(0,d.jsxs)("div",{children:[(0,d.jsx)("h4",{className:"font-semibold text-text-main mb-4",children:"Resources"}),(0,d.jsx)("ul",{className:"flex flex-col gap-3 text-sm text-text-muted font-light",children:i.map(a=>(0,d.jsx)("li",{children:(0,d.jsx)(f(),{href:a.href,className:"hover:text-primary transition-colors",children:a.label})},a.label))})]}),(0,d.jsxs)("div",{children:[(0,d.jsx)("h4",{className:"font-semibold text-text-main mb-4",children:"Company"}),(0,d.jsx)("ul",{className:"flex flex-col gap-3 text-sm text-text-muted font-light",children:j.map(a=>(0,d.jsx)("li",{children:(0,d.jsx)(f(),{href:a.href,className:"hover:text-primary transition-colors",children:a.label})},a.label))})]})]}),(0,d.jsxs)("div",{className:"border-t border-border pt-8 flex flex-col md:flex-row justify-between items-center gap-4",children:[(0,d.jsxs)("p",{className:"text-sm text-text-muted",children:["\xa9 ",new Date().getFullYear()," ",g.vQ.name," Inc. All rights reserved."]}),(0,d.jsxs)("div",{className:"flex gap-6 text-sm text-text-muted",children:[(0,d.jsx)(f(),{href:"#",className:"hover:text-primary transition-colors",children:"Privacy Policy"}),(0,d.jsx)(f(),{href:"#",className:"hover:text-primary transition-colors",children:"Terms of Service"})]})]})]})})}},50377:(a,b,c)=>{c.d(b,{C:()=>e});var d=c(67484);function e(a=2e3){let[b,c]=(0,d.useState)(null),f=(0,d.useRef)(null);return{copied:b,copy:(0,d.useCallback)((b,d="default")=>{(async()=>{if(navigator?.clipboard?.writeText)await navigator.clipboard.writeText(b);else{let a=document.createElement("textarea");a.value=b,a.style.position="fixed",a.style.opacity="0",document.body.appendChild(a),a.select(),document.execCommand("copy"),document.body.removeChild(a)}})(),c(d),f.current&&clearTimeout(f.current),f.current=setTimeout(()=>{c(null)},a)},[a])}}},50412:(a,b,c)=>{c.d(b,{x0:()=>x.default,VW:()=>y.default,Ex:()=>j.default,$n:()=>d.default,Zp:()=>g.default,Qv:()=>i.CardSkeleton,CK:()=>o.default,uo:()=>h.ConfirmModal,G9:()=>t.default,wI:()=>w.default,vj:()=>v.default,vE:()=>u.default,pd:()=>e.default,Mh:()=>s.default,uR:()=>n.default,Nf:()=>p.default,aF:()=>h.default,rq:()=>m.default,gw:()=>z.default,LF:()=>l.default,Wx:()=>C.default,gM:()=>r.default,Iz:()=>A.default,l6:()=>f.default,lM:()=>k.default,m_:()=>B.default,jK:()=>q.default});var d=c(99070),e=c(83552),f=c(4770),g=c(17660),h=c(95145),i=c(74812);c(25919);var j=c(75171),k=c(95514);c(53845),c(19308),c(42196),c(86739),c(48781);var l=c(79346),m=c(83352),n=c(39645),o=c(62727),p=c(20084),q=c(28403);c(267),c(23048),c(3236),c(11229);var r=c(91809);c(86209);var s=c(5291);c(56110);var t=c(51109),u=c(79488),v=c(43182),w=c(51585),x=c(67738),y=c(31402),z=c(50585),A=c(91099),B=c(32971),C=c(11633);c(85306),c(53838)},50585:(a,b,c)=>{c.d(b,{default:()=>l});var d=c(48249),e=c(67484),f=c(49885),g=c.n(f),h=c(17660),i=c(4770),j=c(75171);let k="__none__";function l({providerId:a}){let[b,c]=(0,e.useState)([]),[f,g]=(0,e.useState)(k),[m,n]=(0,e.useState)(!1),[o,p]=(0,e.useState)(!1),q=async b=>{g(b),n(!0);try{let c=await fetch("/api/settings",{cache:"no-store"}),d=(c.ok?await c.json():{}).providerStrategies||{},e={...d[a]||{}};b===k?delete e.proxyPoolId:e.proxyPoolId=b;let f={...d};0===Object.keys(e).length?delete f[a]:f[a]=e,await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerStrategies:f})}),p(!0),setTimeout(()=>p(!1),1500)}catch(a){console.log("Save proxyPoolId error:",a)}finally{n(!1)}};return(0,d.jsxs)(h.default,{children:[(0,d.jsxs)("div",{className:"flex items-center gap-3 mb-4",children:[(0,d.jsx)("div",{className:"inline-flex items-center justify-center w-10 h-10 rounded-full bg-green-500/10 text-green-500",children:(0,d.jsx)("span",{className:"material-symbols-outlined text-[20px]",children:"lock_open"})}),(0,d.jsxs)("div",{className:"flex-1",children:[(0,d.jsx)("p",{className:"text-sm font-medium",children:"No authentication required"}),(0,d.jsx)("p",{className:"text-xs text-text-muted",children:"This provider is ready to use. Optionally route requests through a proxy pool to bypass IP-based limits."})]}),o&&(0,d.jsx)(j.default,{variant:"success",size:"sm",children:"Saved"})]}),(0,d.jsx)(i.default,{label:"Proxy Pool",value:f,onChange:a=>q(a.target.value),disabled:m,options:[{value:k,label:"None (direct)"},...b.map(a=>({value:a.id,label:a.name}))]})]})}l.propTypes={providerId:g().string.isRequired}},51109:(a,b,c)=>{c.d(b,{default:()=>i});var d=c(48249),e=c(67484),f=c(49885),g=c.n(f),h=c(50412);function i({isOpen:a,onSuccess:b,onClose:c}){let[f,g]=(0,e.useState)(""),[j,k]=(0,e.useState)(""),[l,m]=(0,e.useState)(null),[n,o]=(0,e.useState)(!1),[p,q]=(0,e.useState)(!1),[r,s]=(0,e.useState)(!1),[t,u]=(0,e.useState)(!1),v=async()=>{q(!0),m(null),s(!1),u(!1);try{let a=await fetch("/api/oauth/cursor/auto-import"),b=await a.json();b.found?(g(b.accessToken),k(b.machineId),s(!0)):b.windowsManual?u(!0):m(b.error||"Could not auto-detect tokens")}catch(a){m("Failed to auto-detect tokens")}finally{q(!1)}},w=async()=>{if(!f.trim())return void m("Please enter an access token");if(!j.trim())return void m("Please enter a machine ID");o(!0),m(null);try{let a=await fetch("/api/oauth/cursor/import",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({accessToken:f.trim(),machineId:j.trim()})}),d=await a.json();if(!a.ok)throw Error(d.error||"Import failed");b?.(),c()}catch(a){m(a.message)}finally{o(!1)}};return(0,d.jsx)(h.aF,{isOpen:a,title:"Connect Cursor IDE",onClose:c,children:(0,d.jsxs)("div",{className:"flex flex-col gap-4",children:[p&&(0,d.jsxs)("div",{className:"text-center py-6",children:[(0,d.jsx)("div",{className:"size-16 mx-auto mb-4 rounded-full bg-primary/10 flex items-center justify-center",children:(0,d.jsx)("span",{className:"material-symbols-outlined text-3xl text-primary animate-spin",children:"progress_activity"})}),(0,d.jsx)("h3",{className:"text-lg font-semibold mb-2",children:"Auto-detecting tokens..."}),(0,d.jsx)("p",{className:"text-sm text-text-muted",children:"Reading from Cursor IDE database"})]}),!p&&(0,d.jsxs)(d.Fragment,{children:[r&&(0,d.jsx)("div",{className:"bg-green-50 dark:bg-green-900/20 p-3 rounded-lg border border-green-200 dark:border-green-800",children:(0,d.jsxs)("div",{className:"flex gap-2",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-green-600 dark:text-green-400",children:"check_circle"}),(0,d.jsx)("p",{className:"text-sm text-green-800 dark:text-green-200",children:"Tokens auto-detected from Cursor IDE successfully!"})]})}),t&&(0,d.jsxs)("div",{className:"bg-amber-50 dark:bg-amber-900/20 p-3 rounded-lg border border-amber-200 dark:border-amber-800 flex flex-col gap-2",children:[(0,d.jsxs)("div",{className:"flex gap-2 items-center",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-amber-600 dark:text-amber-400",children:"info"}),(0,d.jsx)("p",{className:"text-sm font-medium text-amber-800 dark:text-amber-200",children:"Could not read Cursor database automatically."})]}),(0,d.jsxs)("p",{className:"text-xs text-amber-700 dark:text-amber-300",children:["Make sure Cursor IDE has been opened at least once, then click ",(0,d.jsx)("strong",{children:"Retry"}),". If the problem persists, paste your tokens manually below."]}),(0,d.jsx)(h.$n,{onClick:v,variant:"outline",fullWidth:!0,children:"Retry"})]}),!r&&!t&&!l&&(0,d.jsx)("div",{className:"bg-blue-50 dark:bg-blue-900/20 p-3 rounded-lg border border-blue-200 dark:border-blue-800",children:(0,d.jsxs)("div",{className:"flex gap-2",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-blue-600 dark:text-blue-400",children:"info"}),(0,d.jsx)("p",{className:"text-sm text-blue-800 dark:text-blue-200",children:"Cursor IDE not detected. Please paste your tokens manually."})]})}),(0,d.jsxs)("div",{children:[(0,d.jsxs)("label",{className:"block text-sm font-medium mb-2",children:["Access Token ",(0,d.jsx)("span",{className:"text-red-500",children:"*"})]}),(0,d.jsx)("textarea",{value:f,onChange:a=>g(a.target.value),placeholder:"Access token will be auto-filled...",rows:3,className:"w-full px-3 py-2 text-sm font-mono border border-border rounded-lg bg-background focus:outline-none focus:border-primary resize-none"})]}),(0,d.jsxs)("div",{children:[(0,d.jsxs)("label",{className:"block text-sm font-medium mb-2",children:["Machine ID ",(0,d.jsx)("span",{className:"text-red-500",children:"*"})]}),(0,d.jsx)(h.pd,{value:j,onChange:a=>k(a.target.value),placeholder:"Machine ID will be auto-filled...",className:"font-mono text-sm"})]}),l&&(0,d.jsx)("div",{className:"bg-red-50 dark:bg-red-900/20 p-3 rounded-lg border border-red-200 dark:border-red-800",children:(0,d.jsx)("p",{className:"text-sm text-red-600 dark:text-red-400",children:l})}),(0,d.jsxs)("div",{className:"flex gap-2",children:[(0,d.jsx)(h.$n,{onClick:w,fullWidth:!0,disabled:n||!f.trim()||!j.trim(),children:n?"Importing...":"Import Token"}),(0,d.jsx)(h.$n,{onClick:c,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})]})})}i.propTypes={isOpen:g().bool.isRequired,onSuccess:g().func,onClose:g().func.isRequired}},51585:(a,b,c)=>{c.d(b,{default:()=>m});var d=c(48249),e=c(67484),f=c(49885),g=c.n(f),h=c(95145),i=c(83552),j=c(99070),k=c(75171),l=c(96919);function m({isOpen:a,connection:b,proxyPools:c,onSave:f,onClose:g}){let[n,o]=(0,e.useState)({name:"",priority:1,apiKey:""}),[p,q]=(0,e.useState)({azureEndpoint:"",apiVersion:"2024-10-01-preview",deployment:"",organization:""}),[r,s]=(0,e.useState)({accountId:""}),[t,u]=(0,e.useState)(!1),[v,w]=(0,e.useState)(null),[x,y]=(0,e.useState)(!1),[z,A]=(0,e.useState)(null),[B,C]=(0,e.useState)(!1),D=b?.authType==="oauth",E=b?.provider==="azure",F=b?.provider==="cloudflare-ai",G=!!b&&((0,l.mq)(b.provider)||(0,l.gb)(b.provider)),H=async()=>{if(b?.provider){u(!0),w(null);try{let a=await fetch(`/api/providers/${b.id}/test`,{method:"POST"}),c=await a.json();w(c.valid?"success":"failed")}catch{w("failed")}finally{u(!1)}}},I=async()=>{if(b?.provider&&n.apiKey){y(!0),A(null);try{let a=await fetch("/api/providers/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:b.provider,apiKey:n.apiKey,...E?{providerSpecificData:p}:{},...F?{providerSpecificData:r}:{}})}),c=await a.json();A(c.valid?"success":"failed")}catch{A("failed")}finally{y(!1)}}},J=async()=>{if(b){C(!0);try{let a={name:n.name,priority:n.priority};if(!D&&n.apiKey){a.apiKey=n.apiKey;let c="success"===z;if(!c)try{y(!0),A(null);let a=await fetch("/api/providers/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:b.provider,apiKey:n.apiKey,...E?{providerSpecificData:p}:{},...F?{providerSpecificData:r}:{}})});c=!!(await a.json()).valid,A(c?"success":"failed")}catch{A("failed")}finally{y(!1)}c&&(a.testStatus="active",a.lastError=null,a.lastErrorAt=null)}E&&(a.providerSpecificData={azureEndpoint:p.azureEndpoint,apiVersion:p.apiVersion,deployment:p.deployment,organization:p.organization}),F&&(a.providerSpecificData={accountId:r.accountId}),await f(a)}finally{C(!1)}}};return b?(0,d.jsx)(h.default,{isOpen:a,title:"Edit Connection",onClose:g,children:(0,d.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,d.jsx)(i.default,{label:"Name",value:n.name,onChange:a=>o({...n,name:a.target.value}),placeholder:D?"Account name":"Production Key"}),D&&b.email&&(0,d.jsxs)("div",{className:"bg-sidebar/50 p-3 rounded-lg",children:[(0,d.jsx)("p",{className:"text-sm text-text-muted mb-1",children:"Email"}),(0,d.jsx)("p",{className:"font-medium",children:b.email})]}),(0,d.jsx)(i.default,{label:"Priority",type:"number",value:n.priority,onChange:a=>o({...n,priority:Number.parseInt(a.target.value,10)||1})}),!D&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("div",{className:"flex gap-2",children:[(0,d.jsx)(i.default,{label:"API Key",type:"password",value:n.apiKey,onChange:a=>o({...n,apiKey:a.target.value}),placeholder:"Enter new API key",hint:"Leave blank to keep the current API key.",className:"flex-1"}),(0,d.jsx)("div",{className:"pt-6",children:(0,d.jsx)(j.default,{onClick:I,disabled:!n.apiKey||x||B,variant:"secondary",children:x?"Checking...":"Check"})})]}),z&&(0,d.jsx)(k.default,{variant:"success"===z?"success":"error",children:"success"===z?"Valid":"Invalid"})]}),E&&(0,d.jsxs)("div",{className:"bg-sidebar/50 p-4 rounded-lg border border-accent/20",children:[(0,d.jsx)("h3",{className:"font-semibold mb-3 text-sm",children:"Azure OpenAI Configuration"}),(0,d.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,d.jsx)(i.default,{label:"Azure Endpoint",value:p.azureEndpoint,onChange:a=>q({...p,azureEndpoint:a.target.value}),placeholder:"https://your-resource.openai.azure.com",hint:"Your Azure OpenAI resource endpoint URL"}),(0,d.jsx)(i.default,{label:"Deployment Name",value:p.deployment,onChange:a=>q({...p,deployment:a.target.value}),placeholder:"gpt-4",hint:"The deployment name in your Azure resource"}),(0,d.jsx)(i.default,{label:"API Version",value:p.apiVersion,onChange:a=>q({...p,apiVersion:a.target.value}),placeholder:"2024-10-01-preview",hint:"Azure OpenAI API version to use"}),(0,d.jsx)(i.default,{label:"Organization",value:p.organization,onChange:a=>q({...p,organization:a.target.value}),placeholder:"Organization ID",hint:"Required for billing"})]})]}),!G&&!E&&!F&&(0,d.jsxs)("div",{className:"flex items-center gap-3",children:[(0,d.jsx)(j.default,{onClick:H,variant:"secondary",disabled:t,children:t?"Testing...":"Test Connection"}),v&&(0,d.jsx)(k.default,{variant:"success"===v?"success":"error",children:"success"===v?"Valid":"Failed"})]}),(0,d.jsxs)("div",{className:"flex gap-2",children:[(0,d.jsx)(j.default,{onClick:J,fullWidth:!0,disabled:B,children:B?"Saving...":"Save"}),(0,d.jsx)(j.default,{onClick:g,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})}):null}m.propTypes={isOpen:g().bool.isRequired,connection:g().shape({id:g().string,name:g().string,email:g().string,priority:g().number,authType:g().string,provider:g().string,providerSpecificData:g().object}),proxyPools:g().arrayOf(g().shape({id:g().string,name:g().string})),onSave:g().func.isRequired,onClose:g().func.isRequired}},53838:(a,b,c)=>{c.d(b,{default:()=>h});var d=c(48249),e=c(49885),f=c.n(e),g=c(53845);function h({children:a}){return(0,d.jsxs)("div",{className:"min-h-screen flex flex-col relative bg-bg transition-colors duration-500 overflow-x-hidden selection:bg-primary/20 selection:text-primary",children:[(0,d.jsx)("div",{className:"fixed top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-[800px] h-[800px] bg-primary/5 dark:bg-primary/5 rounded-full blur-[100px] pointer-events-none z-0"}),(0,d.jsx)("div",{className:"fixed bottom-0 right-0 w-[600px] h-[600px] bg-orange-200/20 dark:bg-orange-900/10 rounded-full blur-[120px] pointer-events-none z-0 translate-y-1/3 translate-x-1/3"}),(0,d.jsx)("div",{className:"absolute top-6 right-6 z-20",children:(0,d.jsx)(g.default,{variant:"card"})}),(0,d.jsx)("main",{className:"flex-1 flex flex-col items-center justify-center p-4 sm:p-6 z-10 w-full h-full",children:a})]})}h.propTypes={children:f().node.isRequired}},53845:(a,b,c)=>{c.d(b,{default:()=>g});var d=c(48249),e=c(42118),f=c(71404);function g({className:a,variant:b="default"}){let{isDark:c,toggleTheme:h}=(0,e.D)(),i={default:(0,f.cn)("flex items-center justify-center size-10 rounded-full","text-text-muted hover:text-text-main","hover:bg-surface-2 transition-colors"),card:(0,f.cn)("flex items-center justify-center size-11 rounded-full","bg-surface/60 hover:bg-surface","border border-border","backdrop-blur-md shadow-sm hover:shadow-[var(--shadow-warm)]","text-text-muted hover:text-brand-500","transition-all group")};return(0,d.jsx)("button",{onClick:h,className:(0,f.cn)(i[b],a),"aria-label":`Switch to ${c?"light":"dark"} mode`,title:`Switch to ${c?"light":"dark"} mode`,children:(0,d.jsx)("span",{className:(0,f.cn)("material-symbols-outlined text-[22px]","card"===b&&"transition-transform duration-300 group-hover:rotate-12"),children:c?"light_mode":"dark_mode"})})}},56110:(a,b,c)=>{c.d(b,{default:()=>j});var d=c(48249),e=c(67484),f=c(49885),g=c.n(f),h=c(50412),i=c(50377);function j({isOpen:a,provider:b,onSuccess:c,onClose:f}){let[g,k]=(0,e.useState)("loading"),[l,m]=(0,e.useState)(""),[n,o]=(0,e.useState)(null),[p,q]=(0,e.useState)(""),[r,s]=(0,e.useState)(null),{copied:t,copy:u}=(0,i.C)(),v=async()=>{try{let a;s(null);try{a=new URL(p)}catch(a){throw Error("Invalid callback URL format")}let d=a.searchParams.get("code");a.searchParams.get("state");let e=a.searchParams.get("error");if(e)throw Error(a.searchParams.get("error_description")||e);if(!d)throw Error("No authorization code found in URL");let f=await fetch("/api/oauth/kiro/social-exchange",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({code:d,codeVerifier:n.codeVerifier,provider:b})}),g=await f.json();if(!f.ok)throw Error(g.error);k("success"),c?.()}catch(a){s(a.message),k("error")}},w="google"===b?"Google":"GitHub";return(0,d.jsx)(h.aF,{isOpen:a,title:`Connect Kiro via ${w}`,onClose:f,size:"lg",children:(0,d.jsxs)("div",{className:"flex flex-col gap-4",children:["loading"===g&&(0,d.jsxs)("div",{className:"text-center py-6",children:[(0,d.jsx)("div",{className:"size-16 mx-auto mb-4 rounded-full bg-primary/10 flex items-center justify-center",children:(0,d.jsx)("span",{className:"material-symbols-outlined text-3xl text-primary animate-spin",children:"progress_activity"})}),(0,d.jsx)("h3",{className:"text-lg font-semibold mb-2",children:"Initializing..."}),(0,d.jsxs)("p",{className:"text-sm text-text-muted",children:["Setting up ",w," authentication"]})]}),"input"===g&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("div",{className:"space-y-4",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("p",{className:"text-sm font-medium mb-2",children:"Step 1: Open this URL in your browser"}),(0,d.jsxs)("div",{className:"flex gap-2",children:[(0,d.jsx)(h.pd,{value:l,readOnly:!0,className:"flex-1 font-mono text-xs"}),(0,d.jsx)(h.$n,{variant:"secondary",icon:"auth_url"===t?"check":"content_copy",onClick:()=>u(l,"auth_url"),children:"Copy"})]})]}),(0,d.jsxs)("div",{children:[(0,d.jsx)("p",{className:"text-sm font-medium mb-2",children:"Step 2: Paste the callback URL here"}),(0,d.jsx)("p",{className:"text-xs text-text-muted mb-2",children:"After authorization, copy the full URL from your browser address bar."}),(0,d.jsx)(h.pd,{value:p,onChange:a=>q(a.target.value),placeholder:"kiro://kiro.kiroAgent/authenticate-success?code=...",className:"font-mono text-xs"})]})]}),(0,d.jsxs)("div",{className:"flex gap-2",children:[(0,d.jsx)(h.$n,{onClick:v,fullWidth:!0,disabled:!p,children:"Connect"}),(0,d.jsx)(h.$n,{onClick:f,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]}),"success"===g&&(0,d.jsxs)("div",{className:"text-center py-6",children:[(0,d.jsx)("div",{className:"size-16 mx-auto mb-4 rounded-full bg-green-100 dark:bg-green-900/30 flex items-center justify-center",children:(0,d.jsx)("span",{className:"material-symbols-outlined text-3xl text-green-600",children:"check_circle"})}),(0,d.jsx)("h3",{className:"text-lg font-semibold mb-2",children:"Connected Successfully!"}),(0,d.jsxs)("p",{className:"text-sm text-text-muted mb-4",children:["Your Kiro account via ",w," has been connected."]}),(0,d.jsx)(h.$n,{onClick:f,fullWidth:!0,children:"Done"})]}),"error"===g&&(0,d.jsxs)("div",{className:"text-center py-6",children:[(0,d.jsx)("div",{className:"size-16 mx-auto mb-4 rounded-full bg-red-100 dark:bg-red-900/30 flex items-center justify-center",children:(0,d.jsx)("span",{className:"material-symbols-outlined text-3xl text-red-600",children:"error"})}),(0,d.jsx)("h3",{className:"text-lg font-semibold mb-2",children:"Connection Failed"}),(0,d.jsx)("p",{className:"text-sm text-red-600 mb-4",children:r}),(0,d.jsxs)("div",{className:"flex gap-2",children:[(0,d.jsx)(h.$n,{onClick:()=>k("input"),variant:"secondary",fullWidth:!0,children:"Try Again"}),(0,d.jsx)(h.$n,{onClick:f,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})]})})}j.propTypes={isOpen:g().bool.isRequired,provider:g().oneOf(["google","github"]).isRequired,onSuccess:g().func,onClose:g().func.isRequired}},62727:(a,b,c)=>{c.d(b,{default:()=>l});var d=c(48249),e=c(67484),f=c(95145),g=c(83552),h=c(99070),i=c(83352);let j=/^[a-zA-Z0-9_.\-]+$/;function k({index:a,model:b,isFirst:c,isLast:f,onEdit:g,onMoveUp:h,onMoveDown:i,onRemove:j}){let[l,m]=(0,e.useState)(!1),[n,o]=(0,e.useState)(b),p=()=>{let a=n.trim();a&&a!==b?g(a):o(b),m(!1)};return(0,d.jsxs)("div",{className:"group flex min-w-0 items-center gap-1.5 rounded-md bg-black/[0.02] px-2 py-1 transition-colors hover:bg-black/[0.04] dark:bg-white/[0.02] dark:hover:bg-white/[0.04]",children:[(0,d.jsx)("span",{className:"text-[10px] font-medium text-text-muted w-3 text-center shrink-0",children:a+1}),l?(0,d.jsx)("input",{autoFocus:!0,value:n,onChange:a=>o(a.target.value),onBlur:p,onKeyDown:a=>{"Enter"===a.key&&p(),"Escape"===a.key&&(o(b),m(!1))},className:"min-w-0 flex-1 rounded border border-primary/40 bg-white px-1.5 py-0.5 font-mono text-xs text-text-main outline-none dark:bg-black/20"}):(0,d.jsx)("div",{className:"min-w-0 flex-1 cursor-text truncate rounded px-1.5 py-0.5 font-mono text-xs text-text-main hover:bg-black/5 dark:hover:bg-white/5",onClick:()=>m(!0),title:"Click to edit",children:b}),(0,d.jsxs)("div",{className:"flex shrink-0 items-center gap-0.5",children:[(0,d.jsx)("button",{onClick:h,disabled:c,className:`p-0.5 rounded ${c?"text-text-muted/20 cursor-not-allowed":"text-text-muted hover:text-primary hover:bg-black/5 dark:hover:bg-white/5"}`,title:"Move up",children:(0,d.jsx)("span",{className:"material-symbols-outlined text-[12px]",children:"arrow_upward"})}),(0,d.jsx)("button",{onClick:i,disabled:f,className:`p-0.5 rounded ${f?"text-text-muted/20 cursor-not-allowed":"text-text-muted hover:text-primary hover:bg-black/5 dark:hover:bg-white/5"}`,title:"Move down",children:(0,d.jsx)("span",{className:"material-symbols-outlined text-[12px]",children:"arrow_downward"})})]}),(0,d.jsx)("button",{onClick:j,className:"p-0.5 hover:bg-red-500/10 rounded text-text-muted hover:text-red-500 transition-all",title:"Remove",children:(0,d.jsx)("span",{className:"material-symbols-outlined text-[12px]",children:"close"})})]})}function l({isOpen:a,combo:b,onClose:c,onSave:m,activeProviders:n,kindFilter:o=null,forcePrefix:p="",title:q}){let r=b?.name?p&&b.name.startsWith(p)?b.name.slice(p.length):b.name:"",[s,t]=(0,e.useState)(r),[u,v]=(0,e.useState)(b?.models||[]),[w,x]=(0,e.useState)(!1),[y,z]=(0,e.useState)(!1),[A,B]=(0,e.useState)(""),[C,D]=(0,e.useState)({}),E=a=>{if(!a.trim())return B("Name is required"),!1;let b=p+a;return j.test(b)?(B(""),!0):(B("Only letters, numbers, -, _ and . allowed"),!1)},F=a=>{let b=a.target.value;p&&b.startsWith(p)&&(b=b.slice(p.length)),t(b),b?E(b):B("")},G=async()=>{E(s)&&(z(!0),await m({name:p+s.trim(),models:u}),z(!1))},H=!!b;return(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(f.default,{isOpen:a,onClose:c,title:q||(H?"Edit Combo":"Create Combo"),children:(0,d.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,d.jsxs)("div",{children:[p?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("label",{className:"text-sm font-medium mb-1 block",children:"Combo Name"}),(0,d.jsxs)("div",{className:"flex items-stretch",children:[(0,d.jsx)("span",{className:"inline-flex items-center px-2 rounded-l border border-r-0 border-black/10 dark:border-white/10 bg-black/[0.04] dark:bg-white/[0.04] text-text-muted font-mono text-sm",children:p}),(0,d.jsx)("input",{value:s,onChange:F,placeholder:"my-combo",className:"flex-1 min-w-0 rounded-r border border-black/10 dark:border-white/10 bg-white dark:bg-black/20 px-2 py-1.5 font-mono text-sm outline-none focus:border-primary"})]}),A&&(0,d.jsx)("p",{className:"text-[11px] text-red-500 mt-0.5",children:A})]}):(0,d.jsx)(g.default,{label:"Combo Name",value:s,onChange:F,placeholder:"my-combo",error:A}),(0,d.jsxs)("p",{className:"text-[10px] text-text-muted mt-0.5",children:[p?`Auto-prefixed with "${p}". `:"","Only letters, numbers, -, _ and . allowed"]})]}),(0,d.jsxs)("div",{children:[(0,d.jsx)("label",{className:"text-sm font-medium mb-1.5 block",children:"Models"}),0===u.length?(0,d.jsxs)("div",{className:"text-center py-4 border border-dashed border-black/10 dark:border-white/10 rounded-lg bg-black/[0.01] dark:bg-white/[0.01]",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-text-muted text-xl mb-1",children:"layers"}),(0,d.jsx)("p",{className:"text-xs text-text-muted",children:"No models added yet"})]}):(0,d.jsx)("div",{className:"flex max-h-[55vh] min-w-0 flex-col gap-1 overflow-y-auto sm:max-h-[350px]",children:u.map((a,b)=>(0,d.jsx)(k,{index:b,model:a,isFirst:0===b,isLast:b===u.length-1,onEdit:a=>{let c=[...u];c[b]=a,v(c)},onMoveUp:()=>(a=>{if(0===a)return;let b=[...u];[b[a-1],b[a]]=[b[a],b[a-1]],v(b)})(b),onMoveDown:()=>(a=>{if(a===u.length-1)return;let b=[...u];[b[a],b[a+1]]=[b[a+1],b[a]],v(b)})(b),onRemove:()=>v(u.filter((a,c)=>c!==b))},b))}),(0,d.jsxs)("button",{onClick:()=>x(!0),className:"w-full mt-2 py-2 border border-dashed border-black/10 dark:border-white/10 rounded-lg text-xs text-primary font-medium hover:text-primary hover:border-primary/50 transition-colors flex items-center justify-center gap-1",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"add"}),"Add Model"]})]}),(0,d.jsxs)("div",{className:"flex flex-col gap-2 pt-1 sm:flex-row",children:[(0,d.jsx)(h.default,{onClick:c,variant:"ghost",fullWidth:!0,size:"sm",children:"Cancel"}),(0,d.jsx)(h.default,{onClick:G,fullWidth:!0,size:"sm",disabled:!s.trim()||!!A||y,children:y?"Saving...":H?"Save":"Create"})]})]})}),(0,d.jsx)(i.default,{isOpen:w,onClose:()=>x(!1),onSelect:a=>{u.includes(a.value)||v([...u,a.value])},onDeselect:a=>{v(u.filter(b=>b!==a.value))},activeProviders:n,modelAliases:C,title:"Add Model to Combo",kindFilter:o,addedModelValues:u,closeOnSelect:!1})]})}},66828:(a,b,c)=>{c.d(b,{z:()=>d});let d=["1664x2496","2496x1664","1760x2368","2368x1760","1824x2272","2272x1824","2048x2048","2752x1536","1536x2752","3072x1376","1344x3136"]},67738:(a,b,c)=>{c.d(b,{default:()=>i});var d=c(48249),e=c(67484),f=c(49885),g=c.n(f),h=c(50412);function i({isOpen:a,onClose:b,onCreated:c,onSaved:f,node:g}){let j=!!g,[k,l]=(0,e.useState)({name:"",prefix:"",baseUrl:"https://api.openai.com/v1"}),[m,n]=(0,e.useState)(!1),[o,p]=(0,e.useState)(""),[q,r]=(0,e.useState)(""),[s,t]=(0,e.useState)(!1),[u,v]=(0,e.useState)(null),w=async()=>{if(k.name.trim()&&k.prefix.trim()&&k.baseUrl.trim()){n(!0);try{let a=j?`/api/provider-nodes/${g.id}`:"/api/provider-nodes",b={name:k.name,prefix:k.prefix,baseUrl:k.baseUrl};j||(b.type="custom-embedding");let d=await fetch(a,{method:j?"PUT":"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(b)}),e=await d.json();d.ok&&(j?f?.(e.node):c?.(e.node))}catch(a){console.log("Error saving custom embedding node:",a)}finally{n(!1)}}},x=async()=>{t(!0);try{let a=await fetch("/api/provider-nodes/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({baseUrl:k.baseUrl,apiKey:o,type:"custom-embedding",modelId:q.trim()||void 0})}),b=await a.json();v(b)}catch{v({valid:!1,error:"Network error"})}finally{t(!1)}};return(0,d.jsx)(h.aF,{isOpen:a,title:j?"Edit Custom Embedding":"Add Custom Embedding",onClose:b,children:(0,d.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,d.jsx)(h.pd,{label:"Name",value:k.name,onChange:a=>l({...k,name:a.target.value}),placeholder:"Voyage AI",hint:"Required. A friendly label for this embedding provider."}),(0,d.jsx)(h.pd,{label:"Prefix",value:k.prefix,onChange:a=>l({...k,prefix:a.target.value}),placeholder:"voyage",hint:"Required. Used as the provider prefix for model IDs (e.g. voyage/voyage-3)."}),(0,d.jsx)(h.pd,{label:"Base URL",value:k.baseUrl,onChange:a=>l({...k,baseUrl:a.target.value}),placeholder:"https://api.voyageai.com/v1",hint:"Most embedding APIs are OpenAI-compatible: Voyage, Cohere, Jina, Mistral, Together..."}),(0,d.jsx)(h.pd,{label:"API Key (for Check)",type:"password",value:o,onChange:a=>p(a.target.value)}),(0,d.jsx)(h.pd,{label:"Model ID (for Check)",value:q,onChange:a=>r(a.target.value),placeholder:"e.g. voyage-3, embed-english-v3.0, text-embedding-3-small",hint:"Required for validation. Will send a test embeddings request."}),(0,d.jsxs)("div",{className:"flex items-center gap-3",children:[(0,d.jsx)(h.$n,{onClick:x,disabled:!o||!q.trim()||s||!k.baseUrl.trim(),variant:"secondary",children:s?"Checking...":"Check"}),(()=>{if(!u)return null;let{valid:a,error:b,dimensions:c}=u;return a?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(h.Ex,{variant:"success",children:"Valid"}),c&&(0,d.jsxs)("span",{className:"text-sm text-text-muted",children:[c," dims"]})]}):(0,d.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,d.jsx)(h.Ex,{variant:"error",children:"Invalid"}),b&&(0,d.jsx)("span",{className:"text-sm text-red-500",children:b})]})})()]}),(0,d.jsxs)("div",{className:"flex gap-2",children:[(0,d.jsx)(h.$n,{onClick:w,fullWidth:!0,disabled:!k.name.trim()||!k.prefix.trim()||!k.baseUrl.trim()||m,children:m?j?"Saving...":"Creating...":j?"Save":"Create"}),(0,d.jsx)(h.$n,{onClick:b,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})})}i.propTypes={isOpen:g().bool.isRequired,onClose:g().func.isRequired,onCreated:g().func,onSaved:g().func,node:g().shape({id:g().string,name:g().string,prefix:g().string,baseUrl:g().string})}},71404:(a,b,c)=>{c.d(b,{cn:()=>d});function d(...a){return a.filter(Boolean).join(" ").replace(/\s+/g," ").trim()}},72738:(a,b,c)=>{c.d(b,{A:()=>h});var d=c(48249),e=c(67484),f=c(49885),g=c.n(f);function h({src:a,alt:b,size:c=32,className:f="",fallbackText:g="?",fallbackColor:i}){let[j,k]=(0,e.useState)(!1);return!a||j?(0,d.jsx)("span",{className:`inline-flex items-center justify-center font-bold rounded-lg ${f}`.trim(),style:{width:c,height:c,color:i,fontSize:Math.max(10,Math.floor(.38*c))},children:g}):(0,d.jsx)("img",{src:a,alt:b,width:c,height:c,className:f,onError:()=>k(!0)})}h.propTypes={src:g().string,alt:g().string,size:g().number,className:g().string,fallbackText:g().string,fallbackColor:g().string}},74812:(a,b,c)=>{c.d(b,{CardSkeleton:()=>i,PageLoading:()=>g,Skeleton:()=>h,Spinner:()=>f,default:()=>j});var d=c(48249),e=c(71404);function f({size:a="md",className:b}){return(0,d.jsx)("span",{className:(0,e.cn)("material-symbols-outlined animate-spin text-brand-500",{sm:"size-4",md:"size-6",lg:"size-8",xl:"size-12"}[a],b),children:"progress_activity"})}function g({message:a="Loading..."}){return(0,d.jsxs)("div",{className:"fixed inset-0 z-50 flex flex-col items-center justify-center bg-bg",children:[(0,d.jsx)(f,{size:"xl"}),(0,d.jsx)("p",{className:"mt-4 text-text-muted",children:a})]})}function h({className:a,...b}){return(0,d.jsx)("div",{className:(0,e.cn)("animate-pulse rounded-[10px] bg-surface-2",a),...b})}function i(){return(0,d.jsxs)("div",{className:"p-6 rounded-[14px] border border-border-subtle bg-surface shadow-[var(--shadow-soft)]",children:[(0,d.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,d.jsx)(h,{className:"h-4 w-24"}),(0,d.jsx)(h,{className:"size-10 rounded-[10px]"})]}),(0,d.jsx)(h,{className:"h-8 w-16 mb-2"}),(0,d.jsx)(h,{className:"h-3 w-20"})]})}function j({type:a="spinner",...b}){switch(a){case"page":return(0,d.jsx)(g,{...b});case"skeleton":return(0,d.jsx)(h,{...b});case"card":return(0,d.jsx)(i,{...b});default:return(0,d.jsx)(f,{...b})}}},75171:(a,b,c)=>{c.d(b,{default:()=>h});var d=c(48249),e=c(71404);let f={default:"bg-surface-2 text-text-muted",primary:"bg-brand-500/10 text-brand-600 dark:text-brand-300",success:"bg-green-500/10 text-green-600 dark:text-green-400",warning:"bg-yellow-500/10 text-yellow-600 dark:text-yellow-400",error:"bg-red-500/10 text-red-600 dark:text-red-400",info:"bg-blue-500/10 text-blue-600 dark:text-blue-400"},g={sm:"px-2 py-0.5 text-[10px]",md:"px-2.5 py-1 text-xs",lg:"px-3 py-1.5 text-sm"};function h({children:a,variant:b="default",size:c="md",dot:i=!1,icon:j,className:k}){return(0,d.jsxs)("span",{className:(0,e.cn)("inline-flex items-center gap-1.5 rounded-full font-semibold",f[b],g[c],k),children:[i&&(0,d.jsx)("span",{className:(0,e.cn)("size-1.5 rounded-full","success"===b&&"bg-green-500","warning"===b&&"bg-yellow-500","error"===b&&"bg-red-500","info"===b&&"bg-blue-500","primary"===b&&"bg-brand-500","default"===b&&"bg-gray-500")}),j&&(0,d.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:j}),a]})}},79346:(a,b,c)=>{c.d(b,{default:()=>j});var d=c(48249),e=c(67484),f=c(49885),g=c.n(f),h=c(50412),i=c(50377);function j({isOpen:a,provider:b,providerInfo:c,onSuccess:f,onClose:g,oauthMeta:k,idcConfig:l}){let[m,n]=(0,e.useState)("waiting"),[o,p]=(0,e.useState)(null),[q,r]=(0,e.useState)(""),[s,t]=(0,e.useState)(""),[u,v]=(0,e.useState)(null),[w,x]=(0,e.useState)(!1),[y,z]=(0,e.useState)(null),[A,B]=(0,e.useState)(!1),C=(0,e.useRef)(null),D=(0,e.useRef)(!1),{copied:E,copy:F}=(0,i.C)(),[G,H]=(0,e.useState)(!1),[I,J]=(0,e.useState)("/callback?code=...");(0,e.useRef)(!1);let K=(0,e.useCallback)(async(a,c)=>{if(o)try{let d=await fetch(`/api/oauth/${b}/exchange`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({code:a,redirectUri:o.redirectUri,codeVerifier:o.codeVerifier,state:c,...k?{meta:k}:{}})}),e=await d.json();if(!d.ok)throw Error(e.error);n("success"),f?.()}catch(a){v(a.message),n("error")}},[o,b,f]),L=(0,e.useCallback)(async(a,c,d,e)=>{D.current=!1,B(!0);for(let g=0;g<60;g++){if(D.current){console.log("[OAuthModal] Polling aborted"),B(!1);return}if(await new Promise(a=>setTimeout(a,1e3*d)),D.current){console.log("[OAuthModal] Polling aborted after sleep"),B(!1);return}try{let g=await fetch(`/api/oauth/${b}/poll`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({deviceCode:a,codeVerifier:c,extraData:e})}),h=await g.json();if(h.success){D.current=!0,n("success"),B(!1),f?.();return}if("expired_token"===h.error||"access_denied"===h.error)throw Error(h.errorDescription||h.error);"slow_down"===h.error&&(d=Math.min(d+5,30))}catch(a){v(a.message),n("error"),B(!1);return}}v("Authorization timeout"),n("error"),B(!1)},[b,f]),M=(0,e.useCallback)(async()=>{if(b)try{let a;if(v(null),["github","qwen","kiro","kimi-coding","kilocode","codebuddy"].includes(b)){x(!0),n("waiting");let a=new URL(`/api/oauth/${b}/device-code`,window.location.origin);"kiro"===b&&l?.startUrl&&(a.searchParams.set("start_url",l.startUrl),l.region&&a.searchParams.set("region",l.region),a.searchParams.set("auth_method","idc"));let c=await fetch(a.toString()),d=await c.json();if(!c.ok)throw Error(d.error);z(d);let e=d.verification_uri_complete||d.verification_uri;e&&window.open(e,"_blank","noopener,noreferrer");let f="kiro"===b?{_clientId:d._clientId,_clientSecret:d._clientSecret,_region:d._region,_authMethod:d._authMethod,_startUrl:d._startUrl}:null;L(d.device_code,d.codeVerifier,d.interval||5,f);return}let c=window.location.port||("https:"===window.location.protocol?"443":"80");a="codex"===b?"http://localhost:1455/auth/callback":`http://localhost:${c}/callback`;let d=new URL(`/api/oauth/${b}/authorize`,window.location.origin);d.searchParams.set("redirect_uri",a),k&&Object.entries(k).forEach(([a,b])=>{b&&d.searchParams.set(a,b)});let e=await fetch(d.toString()),f=await e.json();if(!e.ok)throw Error(f.error);let g=!1,h=!1;if("codex"===b)try{let b=new URL("/api/oauth/codex/start-proxy",window.location.origin);b.searchParams.set("app_port",c),b.searchParams.set("state",f.state),b.searchParams.set("code_verifier",f.codeVerifier),b.searchParams.set("redirect_uri",a);let d=await fetch(b.toString()),e=await d.json();g=e.success,h=!!e.serverSide}catch{g=!1}p({...f,redirectUri:a,codexServerSide:h}),"codex"===b&&g||G&&"codex"!==b?(n("waiting"),C.current=window.open(f.authUrl,"oauth_popup","width=600,height=700"),C.current||n("input")):(n("input"),window.open(f.authUrl,"_blank"))}catch(a){v(a.message),n("error")}},[b,G,L,k,l]),N=async()=>{try{v(null);let a=q.trim(),b=new URL(a),c=b.searchParams.get("code"),d=b.searchParams.get("state"),e=b.searchParams.get("error");if(e)throw Error(b.searchParams.get("error_description")||e);if(!c)throw Error("No authorization code found in URL");await K(c,d)}catch(a){v(a.message),n("error")}},O=async()=>{try{let a;v(null);let c=s.trim();if(!c)throw Error("Please paste the session JSON first");try{a=JSON.parse(c)}catch(a){throw Error("Invalid JSON format")}if(!a.accessToken||!a.sessionToken)throw Error("JSON must contain accessToken and sessionToken");let d=await fetch(`/api/oauth/${b}/import-session`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)}),e=await d.json();if(!d.ok)throw Error(e.error);n("success"),f?.()}catch(a){v(a.message),n("error")}},P=(0,e.useCallback)(()=>{"codex"===b&&fetch("/api/oauth/codex/stop-proxy").catch(()=>{}),g()},[g,b]);if(!b||!c)return null;let Q=y?.verification_uri_complete||y?.verification_uri||"";return(0,d.jsx)(h.aF,{isOpen:a,title:`Connect ${c.name}`,onClose:P,size:"lg",children:(0,d.jsxs)("div",{className:"flex flex-col gap-4",children:["waiting"===m&&!w&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2 border border-border rounded-lg bg-sidebar/50",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-base text-primary animate-spin",children:"progress_activity"}),(0,d.jsx)("span",{className:"text-sm",children:"Waiting for popup authorization…"})]}),(0,d.jsx)("h3",{className:"text-lg font-semibold mb-2",children:"Waiting for Authorization"}),(0,d.jsx)("p",{className:"text-sm text-text-muted mb-4",children:"Complete the authorization in the popup window."}),(0,d.jsx)(h.$n,{variant:"ghost",onClick:()=>n("input"),children:"codex"===b?"Popup blocked or use Session JSON?":"Popup blocked? Enter URL manually"})]}),"waiting"===m&&w&&y&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("div",{className:"text-center py-4",children:[(0,d.jsx)("p",{className:"text-sm text-text-muted mb-4",children:"Visit the login URL below and authorize:"}),(0,d.jsxs)("div",{className:"bg-sidebar p-4 rounded-lg mb-4",children:[(0,d.jsx)("p",{className:"text-xs text-text-muted mb-1",children:"Login URL"}),(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("code",{className:"flex-1 text-sm break-all",children:Q}),(0,d.jsx)(h.$n,{size:"sm",variant:"ghost",icon:"login_url"===E?"check":"content_copy",onClick:()=>F(Q,"login_url"),disabled:!Q}),(0,d.jsx)(h.$n,{size:"sm",variant:"ghost",icon:"open_in_new",onClick:()=>window.open(Q,"_blank","noopener,noreferrer"),disabled:!Q,children:"Open"})]})]}),(0,d.jsxs)("div",{className:"bg-primary/10 p-4 rounded-lg",children:[(0,d.jsx)("p",{className:"text-xs text-text-muted mb-1",children:"Your Code"}),(0,d.jsxs)("div",{className:"flex items-center justify-center gap-2",children:[(0,d.jsx)("p",{className:"text-2xl font-mono font-bold text-primary",children:y.user_code}),(0,d.jsx)(h.$n,{size:"sm",variant:"ghost",icon:"user_code"===E?"check":"content_copy",onClick:()=>F(y.user_code,"user_code")})]})]})]}),A&&(0,d.jsxs)("div",{className:"flex items-center justify-center gap-2 text-sm text-text-muted",children:[(0,d.jsx)("span",{className:"material-symbols-outlined animate-spin",children:"progress_activity"}),"Waiting for authorization..."]})]}),"input"===m&&!w&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("div",{className:"space-y-4",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("p",{className:"text-sm font-medium mb-2",children:"Step 1: Open this URL in your browser"}),(0,d.jsxs)("div",{className:"flex gap-2",children:[(0,d.jsx)(h.pd,{value:o?.authUrl||"",readOnly:!0,className:"flex-1 font-mono text-xs"}),(0,d.jsx)(h.$n,{variant:"secondary",icon:"auth_url"===E?"check":"content_copy",onClick:()=>F(o?.authUrl,"auth_url"),children:"Copy"})]})]}),(0,d.jsxs)("div",{children:[(0,d.jsx)("p",{className:"text-sm font-medium mb-2",children:"Step 2: Paste the callback URL here"}),(0,d.jsx)("p",{className:"text-xs text-text-muted mb-2",children:"After authorization, copy the full URL from your browser."}),(0,d.jsx)(h.pd,{value:q,onChange:a=>r(a.target.value),placeholder:I,className:"font-mono text-xs"}),(0,d.jsx)(h.$n,{onClick:N,fullWidth:!0,disabled:!q,className:"mt-3",children:"Connect"})]}),"codex"===b&&(0,d.jsxs)("div",{className:"pt-4 border-t border-border",children:[(0,d.jsx)("p",{className:"text-sm font-medium mb-2",children:"Alternative: Session JSON"}),(0,d.jsxs)("p",{className:"text-xs text-text-muted mb-2",children:["Visit ",(0,d.jsx)("a",{href:"https://chatgpt.com/api/auth/session",target:"_blank",rel:"noreferrer",className:"text-primary hover:underline",children:"https://chatgpt.com/api/auth/session"})," and paste the JSON response below."]}),(0,d.jsx)("textarea",{value:s,onChange:a=>t(a.target.value),placeholder:'{ "accessToken": "...", "user": {...} }',className:"w-full h-24 py-2 px-3 text-xs font-mono text-text-main bg-white dark:bg-white/5 border border-black/10 dark:border-white/10 rounded-md placeholder-text-muted/60 focus:ring-1 focus:ring-primary/30 focus:border-primary/50 focus:outline-none transition-all shadow-inner resize-none"}),(0,d.jsx)(h.$n,{onClick:O,fullWidth:!0,disabled:!s,className:"mt-2",variant:"secondary",children:"Parse and Connect"})]})]}),(0,d.jsx)("div",{className:"flex gap-2",children:(0,d.jsx)(h.$n,{onClick:P,variant:"ghost",fullWidth:!0,children:"Cancel"})})]}),"success"===m&&(0,d.jsxs)("div",{className:"text-center py-6",children:[(0,d.jsx)("div",{className:"size-16 mx-auto mb-4 rounded-full bg-green-100 dark:bg-green-900/30 flex items-center justify-center",children:(0,d.jsx)("span",{className:"material-symbols-outlined text-3xl text-green-600",children:"check_circle"})}),(0,d.jsx)("h3",{className:"text-lg font-semibold mb-2",children:"Connected Successfully!"}),(0,d.jsxs)("p",{className:"text-sm text-text-muted mb-4",children:["Your ",c.name," account has been connected."]}),(0,d.jsx)(h.$n,{onClick:P,fullWidth:!0,children:"Done"})]}),"error"===m&&(0,d.jsxs)("div",{className:"text-center py-6",children:[(0,d.jsx)("div",{className:"size-16 mx-auto mb-4 rounded-full bg-red-100 dark:bg-red-900/30 flex items-center justify-center",children:(0,d.jsx)("span",{className:"material-symbols-outlined text-3xl text-red-600",children:"error"})}),(0,d.jsx)("h3",{className:"text-lg font-semibold mb-2",children:"Connection Failed"}),(0,d.jsx)("p",{className:"text-sm text-red-600 mb-4",children:u}),(0,d.jsxs)("div",{className:"flex gap-2",children:[(0,d.jsx)(h.$n,{onClick:M,variant:"secondary",fullWidth:!0,children:"Try Again"}),(0,d.jsx)(h.$n,{onClick:P,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})]})})}j.propTypes={isOpen:g().bool.isRequired,provider:g().string,providerInfo:g().shape({name:g().string}),onSuccess:g().func,onClose:g().func.isRequired,oauthMeta:g().object,idcConfig:g().shape({startUrl:g().string,region:g().string})}},79488:(a,b,c)=>{c.d(b,{default:()=>i});var d=c(48249),e=c(67484),f=c(49885),g=c.n(f),h=c(50412);function i({isOpen:a,onSuccess:b,onClose:c}){let[f,g]=(0,e.useState)(""),[j,k]=(0,e.useState)(!1),[l,m]=(0,e.useState)(null),[n,o]=(0,e.useState)(!1),p=async()=>{if(!f.trim())return void m("Please paste your cookie");k(!0),m(null);try{let a=await fetch("/api/oauth/iflow/cookie",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cookie:f.trim()})}),c=await a.json();if(!a.ok)throw Error(c.error||"Authentication failed");o(!0),setTimeout(()=>{b?.(),q()},1500)}catch(a){m(a.message)}finally{k(!1)}},q=()=>{g(""),m(null),o(!1),c?.()};return(0,d.jsx)(h.aF,{isOpen:a,onClose:q,title:"iFlow Cookie Authentication",children:(0,d.jsx)("div",{className:"space-y-4",children:n?(0,d.jsxs)("div",{className:"text-center py-8",children:[(0,d.jsx)("div",{className:"text-6xl mb-4",children:"✅"}),(0,d.jsx)("p",{className:"text-lg font-medium text-text-primary",children:"Authentication Successful!"}),(0,d.jsx)("p",{className:"text-sm text-text-muted mt-2",children:"Fresh API key obtained"})]}):(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("div",{className:"space-y-2",children:[(0,d.jsxs)("p",{className:"text-sm text-text-muted",children:["To get a fresh API key, paste your browser cookie from"," ",(0,d.jsx)("a",{href:"https://platform.iflow.cn",target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:"platform.iflow.cn"})]}),(0,d.jsxs)("div",{className:"bg-surface-secondary p-3 rounded-lg text-xs space-y-2",children:[(0,d.jsx)("p",{className:"font-medium text-text-primary",children:"How to get cookie:"}),(0,d.jsxs)("ol",{className:"list-decimal list-inside space-y-1 text-text-muted",children:[(0,d.jsx)("li",{children:"Open platform.iflow.cn in your browser"}),(0,d.jsx)("li",{children:"Login to your account"}),(0,d.jsx)("li",{children:"Open DevTools (F12) → Application/Storage → Cookies"}),(0,d.jsx)("li",{children:"Copy the entire cookie string (must include BXAuth)"}),(0,d.jsx)("li",{children:"Paste it below"})]})]})]}),(0,d.jsxs)("div",{className:"space-y-2",children:[(0,d.jsx)("label",{className:"block text-sm font-medium text-text-primary",children:"Cookie String"}),(0,d.jsx)("textarea",{value:f,onChange:a=>g(a.target.value),placeholder:"BXAuth=xxx; ...",className:"w-full px-3 py-2 bg-surface-secondary border border-border rounded-lg text-sm text-text-primary placeholder-text-muted focus:outline-none focus:ring-2 focus:ring-primary resize-none",rows:4,disabled:j})]}),l&&(0,d.jsx)("div",{className:"p-3 bg-error/10 border border-error/20 rounded-lg",children:(0,d.jsx)("p",{className:"text-sm text-error",children:l})}),(0,d.jsxs)("div",{className:"flex gap-3 pt-2",children:[(0,d.jsx)(h.$n,{variant:"secondary",onClick:q,disabled:j,fullWidth:!0,children:"Cancel"}),(0,d.jsx)(h.$n,{onClick:p,loading:j,fullWidth:!0,children:"Authenticate"})]})]})})})}i.propTypes={isOpen:g().bool.isRequired,onSuccess:g().func,onClose:g().func}},83021:(a,b,c)=>{c.d(b,{A:()=>i});var d=c(48249),e=c(49885),f=c.n(e),g=c(17660);let h=a=>new Intl.NumberFormat().format(a||0);function i({stats:a}){let b;return(0,d.jsxs)("div",{className:"grid min-w-0 grid-cols-1 gap-3 sm:grid-cols-2 md:grid-cols-4 sm:gap-4",children:[(0,d.jsxs)(g.default,{className:"flex min-w-0 flex-col gap-1 px-4 py-3",children:[(0,d.jsx)("span",{className:"text-text-muted text-sm uppercase font-semibold",children:"Total Requests"}),(0,d.jsx)("span",{className:"truncate text-2xl font-bold",children:h(a.totalRequests)})]}),(0,d.jsxs)(g.default,{className:"flex min-w-0 flex-col gap-1 px-4 py-3",children:[(0,d.jsx)("span",{className:"text-text-muted text-sm uppercase font-semibold",children:"Total Input Tokens"}),(0,d.jsx)("span",{className:"truncate text-2xl font-bold text-primary",children:h(a.totalPromptTokens)})]}),(0,d.jsxs)(g.default,{className:"flex min-w-0 flex-col gap-1 px-4 py-3",children:[(0,d.jsx)("span",{className:"text-text-muted text-sm uppercase font-semibold",children:"Output Tokens"}),(0,d.jsx)("span",{className:"truncate text-2xl font-bold text-success",children:h(a.totalCompletionTokens)})]}),(0,d.jsxs)(g.default,{className:"flex min-w-0 flex-col gap-1 px-4 py-3",children:[(0,d.jsx)("span",{className:"text-text-muted text-sm uppercase font-semibold",children:"Est. Cost"}),(0,d.jsxs)("span",{className:"truncate text-2xl font-bold text-warning",children:["~",(b=a.totalCost,`$${(b||0).toFixed(2)}`)]})]})]})}i.propTypes={stats:f().object.isRequired}},83352:(a,b,c)=>{c.d(b,{default:()=>n});var d=c(48249),e=c(67484),f=c(49885),g=c.n(f),h=c(95145),i=c(72738),j=c(91431),k=c(96919);let l=[...Object.keys(k.zN),...Object.keys(k.IS),...Object.keys(k.nJ),...Object.keys(k.fg)],m=Object.keys(k.IS).filter(a=>k.IS[a].noAuth);function n({isOpen:a,onClose:b,onSelect:c,onDeselect:f,selectedModel:g,activeProviders:o=[],title:p="Select Model",modelAliases:q={},kindFilter:r=null,addedModelValues:s=[],closeOnSelect:t=!0}){let u=(0,e.useMemo)(()=>r?o.filter(a=>{let b=k.Q2[a.provider];return(b?.serviceKinds||["llm"]).includes(r)}):o,[o,r]),[v,w]=(0,e.useState)(""),[x,y]=(0,e.useState)([]),[z,A]=(0,e.useState)([]),[B,C]=(0,e.useState)([]),[D,E]=(0,e.useState)({}),F=(0,e.useMemo)(()=>({...k.zN,...k.IS,...k.nJ,...k.fg}),[]),G=(0,e.useMemo)(()=>{let a={},b=new Set(["webSearch","webFetch"]),c=new Set(["image","tts","stt","embedding","imageToText"]),d=new Set(["tts","image","webFetch"]);return[...new Set([...u.map(a=>a.provider),...r?m.filter(a=>(k.Q2[a]?.serviceKinds||["llm"]).includes(r)):m])].sort((a,b)=>{let c=l.indexOf(a),d=l.indexOf(b);return(-1===c?999:c)-(-1===d?999:d)}).forEach(e=>{let f=(0,k.wG)(e),g=F[e]||{name:e,color:"#666"},h=(0,k.mq)(e)||(0,k.gb)(e);if(r&&b.has(r)){a[e]={name:g.name,alias:f,color:g.color,models:[{id:e,name:g.name,value:e}]};return}if(g.passthroughModels){let b=Object.entries(q).filter(([,a])=>a.startsWith(`${f}/`)).map(([a,b])=>({id:b.replace(`${f}/`,""),name:a,value:b}));if(r&&c.has(r)&&0===(b=(0,j.KC)(e).filter(a=>a.type===r).map(a=>({id:a.id,name:a.name,value:`${f}/${a.id}`,type:a.type}))).length&&d.has(r)&&(g.serviceKinds||["llm"]).includes(r)&&(b=[{id:e,name:g.name,value:f}]),b.length>0){let c=z.find(a=>a.id===e),d=c?.name||g.name;a[e]={name:d,alias:f,color:g.color,models:b}}}else if(h){if(r&&c.has(r))return;let b=o.find(a=>a.provider===e),d=z.find(a=>a.id===e),f=b?.name||d?.name||g.name,h=b?.providerSpecificData?.prefix||d?.prefix||e,i=Object.entries(q).filter(([,a])=>a.startsWith(`${e}/`)).map(([a,b])=>({id:b.replace(`${e}/`,""),name:a,value:`${h}/${b.replace(`${e}/`,"")}`})),j=i.length>0?i:[{id:`__placeholder__${e}`,name:`${h}/model-id`,value:`${h}/model-id`,isPlaceholder:!0}];a[e]={name:f,alias:h,color:g.color,models:j,isCustom:!0,hasModels:i.length>0}}else{var i;let b=(0,j.KC)(e),h=new Set(b.map(a=>a.id)),k=b.length>0,l=Object.entries(q).filter(([a,b])=>b.startsWith(`${f}/`)&&(!k||a===b.replace(`${f}/`,""))&&!h.has(b.replace(`${f}/`,""))).map(([a,b])=>({id:b.replace(`${f}/`,""),name:a,value:b,isCustom:!0})),m=new Set(l.map(a=>a.id)),n=B.filter(a=>a.providerAlias===f&&!h.has(a.id)&&!m.has(a.id)).map(a=>({id:a.id,name:a.name||a.id,value:`${f}/${a.id}`,isCustom:!0})),o=[...b.map(a=>({id:a.id,name:a.name,value:`${f}/${a.id}`,type:a.type})),...l,...n],p=new Set,s=(i=o.filter(a=>!p.has(a.value)&&(p.add(a.value),!0)),r?c.has(r)?i.filter(a=>a.isPlaceholder||a.type===r):i:i.filter(a=>a.isPlaceholder||!a.type||"llm"===a.type));0===s.length&&r&&d.has(r)&&(g.serviceKinds||["llm"]).includes(r)&&(s=[{id:e,name:g.name,value:f}]),s.length>0&&(a[e]={name:g.name,alias:f,color:g.color,models:s})}}),Object.entries(a).forEach(([b,c])=>{let d=new Set([...D[(0,k.wG)(b)]||[],...D[b]||[]]);0!==d.size&&(c.models=c.models.filter(a=>!d.has(a.id)),0===c.models.length&&delete a[b])}),a},[u,q,F,z,B,D,r,o]),H=(0,e.useMemo)(()=>{if(r)return[];if(!v.trim())return x;let a=v.toLowerCase();return x.filter(b=>b.name.toLowerCase().includes(a))},[x,v,r]),I=(0,e.useMemo)(()=>{let a=v.trim().toLowerCase(),b={};return Object.entries(G).forEach(([c,d])=>{var e;let f=d.models;if(a){let b=d.name.toLowerCase().includes(a);if(0===(f=f.filter(b=>b.name.toLowerCase().includes(a)||b.id.toLowerCase().includes(a))).length&&!b)return}b[c]={...d,models:[...(e=f).filter(a=>s.includes(a.value)).sort((a,b)=>a.name.localeCompare(b.name)),...e.filter(a=>!s.includes(a.value)).sort((a,b)=>a.name.localeCompare(b.name))]}}),b},[G,v,s]),J=a=>{let d=a?.value||a?.name||a;s.includes(d)&&f?f(a):c(a),t&&(b(),w(""))};return(0,d.jsxs)(h.default,{isOpen:a,onClose:()=>{b(),w("")},title:p,size:"md",className:"p-4!",footer:null,children:[(0,d.jsxs)("div",{className:"flex items-center gap-2 mb-3 px-2.5 py-2 bg-primary/8 border border-primary/20 rounded-lg text-xs text-text-muted",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-primary shrink-0",style:{fontSize:"14px"},children:"info"}),(0,d.jsx)("span",{children:"Click to add, click again to remove. Changes are saved automatically."})]}),(0,d.jsx)("div",{className:"mb-3",children:(0,d.jsxs)("div",{className:"relative",children:[(0,d.jsx)("span",{className:"material-symbols-outlined absolute left-2.5 top-1/2 -translate-y-1/2 text-text-muted text-[16px]",children:"search"}),(0,d.jsx)("input",{type:"text",placeholder:"Search...",value:v,onChange:a=>w(a.target.value),className:"w-full pl-8 pr-3 py-1.5 bg-surface border border-border rounded text-xs focus:outline-none focus:ring-1 focus:ring-primary/50"})]})}),(0,d.jsxs)("div",{className:"max-h-[400px] overflow-y-auto space-y-3",children:[H.length>0&&(0,d.jsxs)("div",{children:[(0,d.jsxs)("div",{className:"flex items-center gap-1.5 mb-1.5 sticky top-0 bg-surface py-0.5",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-primary text-[14px]",children:"layers"}),(0,d.jsx)("span",{className:"text-xs font-medium text-primary",children:"Combos"}),(0,d.jsxs)("span",{className:"text-[10px] text-text-muted",children:["(",H.length,")"]})]}),(0,d.jsx)("div",{className:"flex flex-wrap gap-1.5",children:H.map(a=>{let b=g===a.name;return(0,d.jsxs)("button",{onClick:()=>J({id:a.name,name:a.name,value:a.name}),className:`
|
|
1
|
+
"use strict";exports.id=412,exports.ids=[412],exports.modules={267:(a,b,c)=>{c.d(b,{default:()=>j});var d=c(48249),e=c(67484),f=c(74429),g=c(51126),h=c(99258);let i=a=>({en:{name:"English",flag:"\uD83C\uDDFA\uD83C\uDDF8"},vi:{name:"Tiếng Việt",flag:"\uD83C\uDDFB\uD83C\uDDF3"},"zh-CN":{name:"简体中文",flag:"\uD83C\uDDE8\uD83C\uDDF3"},"zh-TW":{name:"繁體中文",flag:"\uD83C\uDDF9\uD83C\uDDFC"},ja:{name:"日本語",flag:"\uD83C\uDDEF\uD83C\uDDF5"},"pt-BR":{name:"Portugu\xeas (Brasil)",flag:"\uD83C\uDDE7\uD83C\uDDF7"},"pt-PT":{name:"Portugu\xeas (Portugal)",flag:"\uD83C\uDDF5\uD83C\uDDF9"},ko:{name:"한국어",flag:"\uD83C\uDDF0\uD83C\uDDF7"},es:{name:"Espa\xf1ol",flag:"\uD83C\uDDEA\uD83C\uDDF8"},de:{name:"Deutsch",flag:"\uD83C\uDDE9\uD83C\uDDEA"},fr:{name:"Fran\xe7ais",flag:"\uD83C\uDDEB\uD83C\uDDF7"},he:{name:"עברית",flag:"\uD83C\uDDEE\uD83C\uDDF1"},ar:{name:"العربية",flag:"\uD83C\uDDF8\uD83C\uDDE6"},ru:{name:"Русский",flag:"\uD83C\uDDF7\uD83C\uDDFA"},pl:{name:"Polski",flag:"\uD83C\uDDF5\uD83C\uDDF1"},cs:{name:"Čeština",flag:"\uD83C\uDDE8\uD83C\uDDFF"},nl:{name:"Nederlands",flag:"\uD83C\uDDF3\uD83C\uDDF1"},tr:{name:"T\xfcrk\xe7e",flag:"\uD83C\uDDF9\uD83C\uDDF7"},uk:{name:"Українська",flag:"\uD83C\uDDFA\uD83C\uDDE6"},tl:{name:"Tagalog",flag:"\uD83C\uDDF5\uD83C\uDDED"},id:{name:"Indonesia",flag:"\uD83C\uDDEE\uD83C\uDDE9"},th:{name:"ไทย",flag:"\uD83C\uDDF9\uD83C\uDDED"},hi:{name:"हिन्दी",flag:"\uD83C\uDDEE\uD83C\uDDF3"},bn:{name:"বাংলা",flag:"\uD83C\uDDE7\uD83C\uDDE9"},ur:{name:"اردو",flag:"\uD83C\uDDF5\uD83C\uDDF0"},ro:{name:"Rom\xe2nă",flag:"\uD83C\uDDF7\uD83C\uDDF4"},sv:{name:"Svenska",flag:"\uD83C\uDDF8\uD83C\uDDEA"},it:{name:"Italiano",flag:"\uD83C\uDDEE\uD83C\uDDF9"},el:{name:"Ελληνικά",flag:"\uD83C\uDDEC\uD83C\uDDF7"},hu:{name:"Magyar",flag:"\uD83C\uDDED\uD83C\uDDFA"},fi:{name:"Suomi",flag:"\uD83C\uDDEB\uD83C\uDDEE"},da:{name:"Dansk",flag:"\uD83C\uDDE9\uD83C\uDDF0"},no:{name:"Norsk",flag:"\uD83C\uDDF3\uD83C\uDDF4"}})[a]||{name:a,flag:"\uD83C\uDF10"};function j({className:a="",isOpen:b,onClose:c,hideTrigger:k=!1}){let[l,m]=(0,e.useState)("en"),[n,o]=(0,e.useState)(!1),[p,q]=(0,e.useState)(!1),r=(0,e.useRef)(null),s="boolean"==typeof b,t=s?b:p,u=a=>{s?!a&&c&&c():q(a)},v=async a=>{if(a!==l&&!n){o(!0),u(!1);try{await fetch("/api/locale",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({locale:a})}),await (0,h.wn)(),m(a)}catch(a){console.error("Failed to set locale:",a)}finally{o(!1)}}};return(0,d.jsxs)("div",{className:a,children:[!k&&(0,d.jsxs)("button",{onClick:()=>u(!t),disabled:n,className:"flex items-center gap-2 px-3 py-2 rounded-lg text-text-muted hover:text-text-main hover:bg-surface/60 transition-colors",title:"Language","data-i18n-skip":"true",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[20px]",children:"language"}),(0,d.jsx)("span",{className:"text-sm font-medium",children:i(l).name}),(0,d.jsx)("span",{className:"text-lg",children:i(l).flag})]}),t&&(0,f.createPortal)((0,d.jsxs)("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4","data-i18n-skip":"true",children:[(0,d.jsx)("div",{className:"absolute inset-0 bg-black/30 backdrop-blur-sm",onClick:()=>u(!1)}),(0,d.jsxs)("div",{ref:r,className:"relative w-full bg-surface border border-black/10 dark:border-white/10 rounded-xl shadow-2xl animate-in fade-in zoom-in-95 duration-200 max-w-2xl flex flex-col max-h-[80vh]",children:[(0,d.jsxs)("div",{className:"flex items-center justify-between p-3 border-b border-black/5 dark:border-white/5",children:[(0,d.jsx)("h2",{className:"text-lg font-semibold text-text-main",children:"Select Language"}),(0,d.jsx)("button",{onClick:()=>u(!1),className:"p-1.5 rounded-lg text-text-muted hover:bg-black/5 dark:hover:bg-white/5 transition-colors","aria-label":"Close",children:(0,d.jsx)("span",{className:"material-symbols-outlined text-[20px]",children:"close"})})]}),(0,d.jsx)("div",{className:"p-6 overflow-y-auto flex-1",children:(0,d.jsx)("div",{className:"grid grid-cols-[repeat(auto-fill,minmax(100px,1fr))] gap-2",children:g.YZ.map(a=>{let b=l===a,c=i(a);return(0,d.jsxs)("button",{onClick:()=>v(a),disabled:n,className:`flex flex-col items-center justify-start gap-1 px-2 py-3 rounded-lg text-xs font-medium transition-colors w-full ${b?"bg-primary/15 text-primary ring-2 ring-primary":"text-text-main hover:bg-black/5 dark:hover:bg-white/5"} ${n?"opacity-70 cursor-wait":""}`,title:c.name,children:[(0,d.jsx)("span",{className:"text-2xl",children:c.flag}),(0,d.jsx)("span",{className:"text-center leading-tight line-clamp-2 h-8 flex items-center",children:c.name}),b&&(0,d.jsx)("span",{className:"material-symbols-outlined text-sm",children:"check"})]},a)})})})]})]}),document.body)]})}},3236:(a,b,c)=>{c.d(b,{default:()=>p});var d=c(48249),e=c(67484),f=c(19099),g=c(49885),h=c.n(g);c(51126);var i=c(42118),j=c(37900),k=c(11229),l=c(97564),m=c(267);let n={en:{name:"English",flag:"\uD83C\uDDFA\uD83C\uDDF8"},vi:{name:"Tiếng Việt",flag:"\uD83C\uDDFB\uD83C\uDDF3"},"zh-CN":{name:"简体中文",flag:"\uD83C\uDDE8\uD83C\uDDF3"},"zh-TW":{name:"繁體中文",flag:"\uD83C\uDDF9\uD83C\uDDFC"},ja:{name:"日本語",flag:"\uD83C\uDDEF\uD83C\uDDF5"},"pt-BR":{name:"Portugu\xeas (BR)",flag:"\uD83C\uDDE7\uD83C\uDDF7"},"pt-PT":{name:"Portugu\xeas (PT)",flag:"\uD83C\uDDF5\uD83C\uDDF9"},ko:{name:"한국어",flag:"\uD83C\uDDF0\uD83C\uDDF7"},es:{name:"Espa\xf1ol",flag:"\uD83C\uDDEA\uD83C\uDDF8"},de:{name:"Deutsch",flag:"\uD83C\uDDE9\uD83C\uDDEA"},fr:{name:"Fran\xe7ais",flag:"\uD83C\uDDEB\uD83C\uDDF7"},he:{name:"עברית",flag:"\uD83C\uDDEE\uD83C\uDDF1"},ar:{name:"العربية",flag:"\uD83C\uDDF8\uD83C\uDDE6"},ru:{name:"Русский",flag:"\uD83C\uDDF7\uD83C\uDDFA"},pl:{name:"Polski",flag:"\uD83C\uDDF5\uD83C\uDDF1"},cs:{name:"Čeština",flag:"\uD83C\uDDE8\uD83C\uDDFF"},nl:{name:"Nederlands",flag:"\uD83C\uDDF3\uD83C\uDDF1"},tr:{name:"T\xfcrk\xe7e",flag:"\uD83C\uDDF9\uD83C\uDDF7"},uk:{name:"Українська",flag:"\uD83C\uDDFA\uD83C\uDDE6"},tl:{name:"Tagalog",flag:"\uD83C\uDDF5\uD83C\uDDED"},id:{name:"Indonesia",flag:"\uD83C\uDDEE\uD83C\uDDE9"},th:{name:"ไทย",flag:"\uD83C\uDDF9\uD83C\uDDED"},hi:{name:"हिन्दी",flag:"\uD83C\uDDEE\uD83C\uDDF3"},bn:{name:"বাংলা",flag:"\uD83C\uDDE7\uD83C\uDDE9"},ur:{name:"اردو",flag:"\uD83C\uDDF5\uD83C\uDDF0"},ro:{name:"Rom\xe2nă",flag:"\uD83C\uDDF7\uD83C\uDDF4"},sv:{name:"Svenska",flag:"\uD83C\uDDF8\uD83C\uDDEA"},it:{name:"Italiano",flag:"\uD83C\uDDEE\uD83C\uDDF9"},el:{name:"Ελληνικά",flag:"\uD83C\uDDEC\uD83C\uDDF7"},hu:{name:"Magyar",flag:"\uD83C\uDDED\uD83C\uDDFA"},fi:{name:"Suomi",flag:"\uD83C\uDDEB\uD83C\uDDEE"},da:{name:"Dansk",flag:"\uD83C\uDDE9\uD83C\uDDF0"},no:{name:"Norsk",flag:"\uD83C\uDDF3\uD83C\uDDF4"}};function o({icon:a,label:b,onClick:c,trailing:e,danger:f}){return(0,d.jsxs)("button",{onClick:c,className:`flex items-center gap-3 w-full px-4 py-2.5 text-sm transition-colors ${f?"text-red-500 hover:bg-red-500/10":"text-text-main hover:bg-black/5 dark:hover:bg-white/5"}`,children:[(0,d.jsx)("span",{className:`material-symbols-outlined text-[20px] ${f?"":"text-text-muted"}`,children:a}),(0,d.jsx)("span",{className:"flex-1 text-left",children:b}),e&&(0,d.jsx)("span",{className:"text-base",children:e})]})}function p({onLogout:a}){let[b,c]=(0,e.useState)(!1),[g,h]=(0,e.useState)(!1),[q,r]=(0,e.useState)(!1),[s,t]=(0,e.useState)(!1),[u,v]=(0,e.useState)("en"),w=(0,f.useRouter)(),{toggleTheme:x,isDark:y}=(0,i.D)(),{role:z}=(0,j.hd)(),[A,B]=(0,e.useState)(null),C=(0,e.useRef)(null),D="sub_user"===(A||z||null);return(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("div",{className:"relative",ref:C,children:[(0,d.jsx)("button",{onClick:()=>c(a=>!a),className:"flex items-center justify-center p-2 rounded-lg text-text-muted hover:text-text-main hover:bg-black/5 dark:hover:bg-white/5 transition-all",title:"Menu",children:(0,d.jsx)("span",{className:"material-symbols-outlined",children:"grid_view"})}),b&&(0,d.jsxs)("div",{className:"absolute right-0 top-full mt-2 w-60 bg-surface border border-black/10 dark:border-white/10 rounded-xl shadow-2xl z-50 animate-in fade-in zoom-in-95 duration-150 overflow-hidden py-1",children:[D&&(0,d.jsx)(o,{icon:"dashboard",label:"Dashboard",onClick:()=>{c(!1),w.push("/dashboard")}}),D&&(0,d.jsx)(o,{icon:"terminal",label:"CLI Tools",onClick:()=>{c(!1),w.push("/dashboard/cli-tools")}}),!D&&(0,d.jsx)(o,{icon:"history",label:"Change Log",onClick:()=>{c(!1),h(!0)}}),(0,d.jsx)(o,{icon:"language",label:n[u]?.name||u,trailing:n[u]?.flag||"\uD83C\uDF10",onClick:()=>{c(!1),t(!0)}}),!D&&(0,d.jsx)(o,{icon:y?"light_mode":"dark_mode",label:"Theme",onClick:()=>{x(),c(!1)}}),!D&&(0,d.jsx)(o,{icon:"computer",label:"Remote",onClick:()=>{c(!1),r(!0)}}),(0,d.jsx)(o,{icon:"logout",label:"Logout",danger:!0,onClick:()=>{c(!1),a()}})]})]}),(0,d.jsx)(k.default,{isOpen:g,onClose:()=>h(!1)}),(0,d.jsx)(l.A,{isOpen:q,onClose:()=>r(!1)}),(0,d.jsx)(m.default,{hideTrigger:!0,isOpen:s,onClose:()=>t(!1)})]})}o.propTypes={icon:h().string.isRequired,label:h().string.isRequired,onClick:h().func.isRequired,trailing:h().node,danger:h().bool},p.propTypes={onLogout:h().func.isRequired}},4770:(a,b,c)=>{c.d(b,{default:()=>f});var d=c(48249),e=c(71404);function f({label:a,options:b=[],children:c,value:g,onChange:h,placeholder:i="Select an option",error:j,hint:k,disabled:l=!1,required:m=!1,className:n,selectClassName:o,...p}){return(0,d.jsxs)("div",{className:(0,e.cn)("flex flex-col gap-1.5",n),children:[a&&(0,d.jsxs)("label",{className:"text-sm font-medium text-text-main",children:[a,m&&(0,d.jsx)("span",{className:"text-red-500 ml-1",children:"*"})]}),(0,d.jsxs)("div",{className:"relative",children:[(0,d.jsx)("select",{value:g,onChange:h,disabled:l,className:(0,e.cn)("w-full py-2.5 px-3 pr-10 text-sm text-text-main","bg-surface-2 border border-transparent rounded-[10px] appearance-none","focus:outline-none focus:ring-2 focus:ring-brand-500/30 focus:border-brand-500/40","transition-all duration-150 disabled:opacity-50 disabled:cursor-not-allowed","text-[16px] sm:text-sm",j&&"ring-1 ring-red-500 focus:ring-2 focus:ring-red-500/40 border-red-500/40",o),...p,children:c||(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("option",{value:"",disabled:!0,children:i}),b.map(a=>(0,d.jsx)("option",{value:a.value,children:a.label},a.value))]})}),(0,d.jsx)("div",{className:"absolute inset-y-0 right-0 flex items-center pr-3 pointer-events-none text-text-muted",children:(0,d.jsx)("span",{className:"material-symbols-outlined text-[20px]",children:"expand_more"})})]}),j&&(0,d.jsxs)("p",{className:"text-xs text-red-500 flex items-center gap-1",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"error"}),j]}),k&&!j&&(0,d.jsx)("p",{className:"text-xs text-text-muted",children:k})]})}},5291:(a,b,c)=>{c.d(b,{default:()=>k});var d=c(48249),e=c(67484),f=c(49885),g=c.n(f),h=c(79346),i=c(86209),j=c(56110);function k({isOpen:a,providerInfo:b,onSuccess:c,onClose:f}){let[g,l]=(0,e.useState)(null),[m,n]=(0,e.useState)(null),[o,p]=(0,e.useState)(null),q=(0,e.useCallback)((a,b)=>{"builder-id"===a?l("builder-id"):"idc"===a?(l("idc"),p(b)):"social"===a?(l("social"),n(b.provider)):"import"===a&&c?.()},[c]),r=()=>{l(null),n(null),p(null)};return g?"builder-id"===g||"idc"===g?(0,d.jsx)(h.default,{isOpen:a,provider:"kiro",providerInfo:b,onSuccess:()=>{l(null),p(null),c?.(),f?.()},onClose:r,idcConfig:o}):"social"===g&&m?(0,d.jsx)(j.default,{isOpen:a,provider:m,onSuccess:()=>{l(null),n(null),c?.(),f?.()},onClose:r}):null:(0,d.jsx)(i.default,{isOpen:a,onMethodSelect:q,onClose:f})}k.propTypes={isOpen:g().bool.isRequired,providerInfo:g().shape({name:g().string}),onSuccess:g().func,onClose:g().func.isRequired}},11229:(a,b,c)=>{c.d(b,{default:()=>j});var d=c(48249),e=c(67484),f=c(74429),g=c(49885),h=c.n(g),i=c(26921);function j({isOpen:a,onClose:b}){let[c,g]=(0,e.useState)(""),[h,i]=(0,e.useState)(!1),[k,l]=(0,e.useState)(""),m=(0,e.useRef)(null);return!a||"u"<typeof document?null:(0,f.createPortal)((0,d.jsxs)("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",children:[(0,d.jsx)("div",{className:"absolute inset-0 bg-black/30 backdrop-blur-sm",onClick:b}),(0,d.jsxs)("div",{ref:m,className:"relative w-full bg-surface border border-black/10 dark:border-white/10 rounded-xl shadow-2xl animate-in fade-in zoom-in-95 duration-200 max-w-3xl flex flex-col max-h-[85vh]",children:[(0,d.jsxs)("div",{className:"flex items-center justify-between p-3 border-b border-black/5 dark:border-white/5",children:[(0,d.jsx)("h2",{className:"text-lg font-semibold text-text-main",children:"Change Log"}),(0,d.jsx)("button",{onClick:b,className:"p-1.5 rounded-lg text-text-muted hover:bg-black/5 dark:hover:bg-white/5 transition-colors","aria-label":"Close",children:(0,d.jsx)("span",{className:"material-symbols-outlined text-[20px]",children:"close"})})]}),(0,d.jsxs)("div",{className:"p-6 overflow-y-auto flex-1",children:[h&&(0,d.jsxs)("div",{className:"flex items-center justify-center py-10 text-text-muted",children:[(0,d.jsx)("span",{className:"material-symbols-outlined animate-spin mr-2",children:"progress_activity"}),"Loading..."]}),k&&(0,d.jsxs)("div",{className:"text-red-500 py-4",children:["Failed to load changelog: ",k]}),!h&&!k&&c&&(0,d.jsx)("div",{className:"changelog-body text-text-main",dangerouslySetInnerHTML:{__html:c}})]})]})]}),document.body)}c(12020),i.xI.setOptions({gfm:!0,breaks:!0}),j.propTypes={isOpen:h().bool.isRequired,onClose:h().func.isRequired}},11633:(a,b,c)=>{c.d(b,{default:()=>g});var d=c(48249),e=c(17660);let f={mode:{label:"Mode",format:a=>a},defaultModel:{label:"Model",format:a=>a,mono:!0},baseUrl:{label:"Endpoint",format:a=>a,isLink:!0,mono:!0},costPerQuery:{label:"Cost / call",format:a=>0===a?"Free":`$${a.toFixed(4)}`},pricingUrl:{label:"Pricing",format:()=>"View pricing",isLink:!0},freeTier:{label:"Free tier",format:a=>a},freeMonthlyQuota:{label:"Free quota",format:a=>0===a?"—":a>=999999?"Unlimited":`${a.toLocaleString()} / mo`},searchTypes:{label:"Types",format:a=>a.join(", ")},formats:{label:"Formats",format:a=>a.join(", ")},maxMaxResults:{label:"Max results",format:a=>a},maxCharacters:{label:"Max chars",format:a=>a.toLocaleString()}};function g({config:a,provider:b,title:c="Provider Info"}){if(!a)return null;let h=Object.entries(f).filter(([b])=>void 0!==a[b]&&null!==a[b]&&""!==a[b]).map(([b,c])=>({key:b,label:c.label,value:c.format(a[b]),isLink:c.isLink,mono:c.mono,raw:a[b]})),i=b?.notice?.apiKeyUrl||b?.website,j=b?.notice?.text;return(0,d.jsxs)(e.default,{children:[(0,d.jsxs)("div",{className:"flex items-center justify-between mb-3",children:[(0,d.jsx)("h2",{className:"text-lg font-semibold",children:c}),i&&(0,d.jsxs)("a",{href:i,target:"_blank",rel:"noopener noreferrer",className:"text-xs text-primary hover:underline inline-flex items-center gap-1",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-sm",children:"open_in_new"}),"Get API Key"]})]}),(0,d.jsxs)("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-x-6 gap-y-2",children:[h.map(a=>(0,d.jsxs)("div",{className:"flex items-center gap-3 min-w-0",children:[(0,d.jsx)("span",{className:"text-xs text-text-muted w-28 shrink-0",children:a.label}),a.isLink?(0,d.jsx)("a",{href:a.raw,target:"_blank",rel:"noopener noreferrer",className:`text-sm text-primary hover:underline truncate ${a.mono?"font-mono":""}`,children:a.value}):(0,d.jsx)("span",{className:`text-sm text-text-main truncate ${a.mono?"font-mono":""}`,children:a.value})]},a.key)),j&&(0,d.jsxs)("div",{className:"flex items-start gap-3 min-w-0 sm:col-span-2",children:[(0,d.jsx)("span",{className:"text-xs text-text-muted w-28 shrink-0 mt-0.5",children:"Notice"}),(0,d.jsx)("span",{className:"text-sm text-text-main leading-relaxed",children:j})]})]})]})}},17660:(a,b,c)=>{c.d(b,{default:()=>f});var d=c(48249),e=c(71404);function f({children:a,title:b,subtitle:c,icon:g,action:h,padding:i="md",hover:j=!1,elev:k=!1,className:l,...m}){return(0,d.jsxs)("div",{className:(0,e.cn)("bg-surface border border-border-subtle",k?"rounded-[14px] shadow-[var(--shadow-elev)]":"rounded-[14px] shadow-[var(--shadow-soft)]",j&&"hover:shadow-[var(--shadow-warm)] hover:border-brand-500/30 transition-all cursor-pointer",{none:"",xs:"p-3",sm:"p-4",md:"p-6",lg:"p-8"}[i],l),...m,children:[(b||h)&&(0,d.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,d.jsxs)("div",{className:"flex items-center gap-3",children:[g&&(0,d.jsx)("div",{className:"p-2 rounded-[10px] bg-bg text-text-muted",children:(0,d.jsx)("span",{className:"material-symbols-outlined text-[20px]",children:g})}),(0,d.jsxs)("div",{children:[b&&(0,d.jsx)("h3",{className:"text-text-main font-semibold",children:b}),c&&(0,d.jsx)("p",{className:"text-sm text-text-muted",children:c})]})]}),h]}),a]})}f.Section=function({children:a,className:b,...c}){return(0,d.jsx)("div",{className:(0,e.cn)("p-4 rounded-[10px]","bg-bg border border-border-subtle",b),...c,children:a})},f.Row=function({children:a,className:b,...c}){return(0,d.jsx)("div",{className:(0,e.cn)("p-3 -mx-3 px-3 transition-colors","border-b border-border-subtle last:border-b-0","hover:bg-surface-2/50",b),...c,children:a})},f.ListItem=function({children:a,actions:b,className:c,...f}){return(0,d.jsxs)("div",{className:(0,e.cn)("group flex items-center justify-between p-3 -mx-3 px-3","border-b border-border-subtle last:border-b-0","hover:bg-surface-2/50 transition-colors",c),...f,children:[(0,d.jsx)("div",{className:"flex-1 min-w-0",children:a}),b&&(0,d.jsx)("div",{className:"flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:b})]})}},20084:(a,b,c)=>{c.d(b,{default:()=>g});var d=c(48249),e=c(67484),f=c(95145);function g({isOpen:a,onClose:b,onAdd:c,addedNames:h=[]}){let[i,j]=(0,e.useState)([]),[k,l]=(0,e.useState)(!1),[m,n]=(0,e.useState)(""),[o,p]=(0,e.useState)("all"),[q,r]=(0,e.useState)(null),[s,t]=(0,e.useState)(null),[u,v]=(0,e.useState)({}),[w,x]=(0,e.useState)({}),[y,z]=(0,e.useState)({}),A=(0,e.useMemo)(()=>new Set(h),[h]),B=(0,e.useMemo)(()=>{let a=m.trim().toLowerCase();return i.filter(b=>("authless"!==o||!b.oauth)&&("oauth"!==o||!!b.oauth)&&(!a||(b.title||"").toLowerCase().includes(a)||(b.description||"").toLowerCase().includes(a)||(b.name||"").toLowerCase().includes(a)))},[i,m,o]),C=async a=>{if(!u[a.url]){x(b=>({...b,[a.url]:!0}));try{let b=await fetch("/api/cli-tools/cowork-mcp-tools",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:a.url})}),c=await b.json(),d=c.tools||[],e=Array.isArray(a.toolNames)?a.toolNames:[],f=d.length>0?d.map(a=>a.name):e;v(b=>({...b,[a.url]:{tools:d,requiresAuth:!!c.requiresAuth,error:c.error}})),z(b=>({...b,[a.url]:Object.fromEntries(f.map(a=>[a,!0]))}))}catch(b){v(c=>({...c,[a.url]:{tools:[],error:b.message}}))}finally{x(b=>({...b,[a.url]:!1}))}}},D=(a,b)=>{let c=y[a]||{};z(d=>({...d,[a]:Object.fromEntries(Object.keys(c).map(a=>[a,b]))}))};return(0,d.jsx)(f.default,{isOpen:a,onClose:b,title:"Browse MCP Marketplace",size:"lg",children:(0,d.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("input",{type:"text",value:m,onChange:a=>n(a.target.value),placeholder:"Search by name or description...",className:"flex-1 px-2 py-1.5 bg-surface rounded text-xs border border-border focus:outline-none focus:ring-1 focus:ring-primary/50"}),(0,d.jsxs)("select",{value:o,onChange:a=>p(a.target.value),className:"px-2 py-1.5 bg-surface rounded text-xs border border-border focus:outline-none focus:ring-1 focus:ring-primary/50",children:[(0,d.jsx)("option",{value:"all",children:"All"}),(0,d.jsx)("option",{value:"authless",children:"Authless"}),(0,d.jsx)("option",{value:"oauth",children:"OAuth"})]})]}),q&&(0,d.jsx)("div",{className:"px-2 py-1.5 rounded text-xs bg-red-500/10 text-red-600",children:q}),k&&(0,d.jsxs)("div",{className:"flex items-center gap-2 text-text-muted text-xs py-4 justify-center",children:[(0,d.jsx)("span",{className:"material-symbols-outlined animate-spin text-[18px]",children:"progress_activity"}),(0,d.jsx)("span",{children:"Loading registry..."})]}),!k&&(0,d.jsxs)("div",{className:"flex flex-col gap-1 max-h-[60vh] overflow-y-auto",children:[0===B.length&&(0,d.jsx)("div",{className:"text-center text-xs text-text-muted py-6",children:"No servers match filter"}),B.map(a=>{let b=A.has(a.slug||a.name),e=s===a.url,f=u[a.url],g=w[a.url],h=y[a.url]||{},i=Object.keys(h),j=Object.values(h).filter(Boolean).length;return(0,d.jsxs)("div",{className:"rounded border border-transparent hover:border-border",children:[(0,d.jsxs)("div",{className:"flex items-start gap-2 px-2 py-2 hover:bg-black/5 dark:hover:bg-white/5",children:[a.iconUrl?(0,d.jsx)("img",{src:a.iconUrl,alt:"",className:"size-7 rounded shrink-0 object-contain",onError:a=>{a.target.style.display="none"}}):(0,d.jsx)("div",{className:"size-7 rounded bg-surface shrink-0"}),(0,d.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,d.jsxs)("div",{className:"flex items-center gap-1.5 flex-wrap",children:[(0,d.jsx)("span",{className:"font-medium text-xs",children:a.title}),a.oauth?(0,d.jsx)("span",{className:"px-1 py-0.5 text-[9px] rounded bg-amber-500/10 text-amber-600",children:"OAuth"}):(0,d.jsx)("span",{className:"px-1 py-0.5 text-[9px] rounded bg-green-500/10 text-green-600",children:"Authless"}),a.toolCount>0&&(0,d.jsxs)("span",{className:"text-[10px] text-text-muted",children:[a.toolCount," tools"]})]}),a.description&&(0,d.jsx)("p",{className:"text-[10px] text-text-muted line-clamp-2 mt-0.5",children:a.description})]}),(0,d.jsx)("button",{onClick:()=>b?null:void(s===a.url?t(null):(t(a.url),C(a))),disabled:b,className:`shrink-0 px-2 py-1 rounded text-[10px] font-medium transition-colors ${b?"bg-green-500/10 text-green-600 cursor-default":e?"bg-surface border border-border text-text-muted hover:bg-black/5":"bg-primary/10 border border-primary/40 text-primary hover:bg-primary/20"}`,children:b?"Added":e?"Cancel":"+ Add"})]}),e&&(0,d.jsxs)("div",{className:"px-3 py-2 bg-surface/40 border-t border-border flex flex-col gap-2",children:[g&&(0,d.jsxs)("div",{className:"flex items-center gap-2 text-text-muted text-[10px] py-1",children:[(0,d.jsx)("span",{className:"material-symbols-outlined animate-spin text-[14px]",children:"progress_activity"}),(0,d.jsx)("span",{children:"Probing server for tools..."})]}),!g&&f?.requiresAuth&&(0,d.jsx)("p",{className:"text-[10px] text-amber-600 bg-amber-500/10 px-2 py-1 rounded",children:"\uD83D\uDD10 OAuth required. Add now and authenticate after Apply; tool list will be discovered after first connect."}),!g&&f?.error&&!f?.requiresAuth&&(0,d.jsxs)("p",{className:"text-[10px] text-red-600 bg-red-500/10 px-2 py-1 rounded",children:["Probe failed: ",f.error]}),!g&&0===i.length&&!f?.requiresAuth&&!f?.error&&(0,d.jsx)("p",{className:"text-[10px] text-text-muted",children:"No tools advertised by server."}),!g&&i.length>0&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("div",{className:"flex items-center justify-between",children:[(0,d.jsxs)("span",{className:"text-[10px] text-text-muted",children:[j,"/",i.length," tools enabled"]}),(0,d.jsxs)("div",{className:"flex gap-1",children:[(0,d.jsx)("button",{onClick:()=>D(a.url,!0),className:"text-[10px] text-primary hover:underline",children:"All"}),(0,d.jsx)("span",{className:"text-[10px] text-text-muted",children:"\xb7"}),(0,d.jsx)("button",{onClick:()=>D(a.url,!1),className:"text-[10px] text-primary hover:underline",children:"None"})]})]}),(0,d.jsx)("div",{className:"grid grid-cols-2 gap-1 max-h-40 overflow-y-auto",children:i.map(b=>(0,d.jsxs)("label",{className:"flex items-center gap-1.5 text-[10px] cursor-pointer hover:bg-black/5 dark:hover:bg-white/5 px-1 rounded",children:[(0,d.jsx)("input",{type:"checkbox",checked:!!h[b],onChange:()=>{var c;return c=a.url,void z(a=>({...a,[c]:{...a[c],[b]:!a[c]?.[b]}}))},className:"size-3"}),(0,d.jsx)("span",{className:"truncate",children:b})]},b))})]}),(0,d.jsx)("button",{onClick:()=>{let b,d;return d=Object.keys(b=y[a.url]||{}).filter(a=>b[a]),void(c?.({name:a.slug||a.name,title:a.title,description:a.description,url:a.url,transport:a.transport,oauth:a.oauth,toolNames:d}),t(null))},className:"self-end px-2 py-1 rounded text-[10px] font-medium bg-primary text-white hover:bg-primary/90",children:"✓ Confirm Add"})]})]},a.url)})]}),(0,d.jsxs)("div",{className:"text-[10px] text-text-muted text-right",children:[B.length," of ",i.length," servers"]})]})})}},23048:(a,b,c)=>{c.d(b,{default:()=>g});var d=c(48249),e=c(67484),f=c(97564);function g(){let[a,b]=(0,e.useState)(!1);return(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("button",{onClick:()=>b(!0),className:"relative flex items-center gap-1.5 px-2.5 py-1.5 rounded-lg transition-all text-text-muted hover:text-text-main hover:bg-black/5 dark:hover:bg-white/5",title:"9Remote",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"computer"}),(0,d.jsx)("span",{className:"text-xs font-medium",children:"Remote"})]}),(0,d.jsx)(f.A,{isOpen:a,onClose:()=>b(!1)})]})}},25919:(a,b,c)=>{c.d(b,{default:()=>f});var d=c(48249),e=c(71404);function f({src:a,alt:b="Avatar",name:c,size:g="md",className:h}){let i={xs:"size-6 text-xs",sm:"size-8 text-sm",md:"size-10 text-base",lg:"size-12 text-lg",xl:"size-16 text-xl"};return a?(0,d.jsx)("div",{className:(0,e.cn)("rounded-full bg-cover bg-center bg-no-repeat","ring-2 ring-white dark:ring-surface-dark shadow-sm",i[g],h),style:{backgroundImage:`url(${a})`},role:"img","aria-label":b}):(0,d.jsx)("div",{className:(0,e.cn)("rounded-full flex items-center justify-center font-semibold text-white","ring-2 ring-white dark:ring-surface-dark shadow-sm",i[g],(a=>{if(!a)return"bg-primary";let b=["bg-red-500","bg-orange-500","bg-amber-500","bg-yellow-500","bg-lime-500","bg-green-500","bg-emerald-500","bg-teal-500","bg-cyan-500","bg-sky-500","bg-blue-500","bg-indigo-500","bg-violet-500","bg-purple-500","bg-fuchsia-500","bg-pink-500","bg-rose-500"],c=a.charCodeAt(0)%b.length;return b[c]})(c),h),role:"img","aria-label":b,children:(a=>{if(!a)return"?";let b=a.split(" ");return b.length>=2?`${b[0][0]}${b[1][0]}`.toUpperCase():a.substring(0,2).toUpperCase()})(c)})}},28403:(a,b,c)=>{c.d(b,{default:()=>S});var d=c(48249),e=c(67484),f=c(19099),g=c(96919),h=c(75171),i=c(17660),j=c(83021),k=c(49885),l=c.n(k);let m=a=>new Intl.NumberFormat().format(a||0),n=a=>`$${(a||0).toFixed(2)}`;function o(a){if(!a)return"Never";let b=Math.floor((Date.now()-new Date(a))/6e4);return b<1?"Just now":b<60?`${b}m ago`:b<1440?`${Math.floor(b/60)}h ago`:new Date(a).toLocaleDateString()}function p({field:a,currentSort:b,currentOrder:c}){return b!==a?(0,d.jsx)("span",{className:"ml-1 opacity-20",children:"↕"}):(0,d.jsx)("span",{className:"ml-1",children:"asc"===c?"↑":"↓"})}function q({item:a,viewMode:b,isSummary:c=!1}){return"tokens"===b?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("td",{className:"px-6 py-3 text-right text-text-muted",children:c&&void 0===a.promptTokens?"—":m(a.promptTokens)}),(0,d.jsx)("td",{className:"px-6 py-3 text-right text-text-muted",children:c&&void 0===a.completionTokens?"—":m(a.completionTokens)}),(0,d.jsx)("td",{className:"px-6 py-3 text-right font-medium",children:m(a.totalTokens)})]}):(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("td",{className:"px-6 py-3 text-right text-text-muted",children:c&&void 0===a.inputCost?"—":n(a.inputCost)}),(0,d.jsx)("td",{className:"px-6 py-3 text-right text-text-muted",children:c&&void 0===a.outputCost?"—":n(a.outputCost)}),(0,d.jsx)("td",{className:"px-6 py-3 text-right font-medium text-warning",children:n(a.totalCost||a.cost)})]})}function r({title:a,columns:b,groupedData:c,tableType:f,sortBy:g,sortOrder:h,onToggleSort:j,viewMode:k,storageKey:l,renderDetailCells:m,renderSummaryCells:n,emptyMessage:o}){let[s,t]=(0,e.useState)(new Set),u=(0,e.useCallback)(a=>{t(b=>{let c=new Set(b);return c.has(a)?c.delete(a):c.add(a),c})},[]),v=(0,e.useMemo)(()=>"tokens"===k?[{field:"promptTokens",label:"Input Tokens"},{field:"completionTokens",label:"Output Tokens"},{field:"totalTokens",label:"Total Tokens"}]:[{field:"promptTokens",label:"Input Cost"},{field:"completionTokens",label:"Output Cost"},{field:"cost",label:"Total Cost"}],[k]),w=b.length+v.length;return(0,d.jsxs)(i.default,{className:"overflow-hidden",children:[(0,d.jsx)("div",{className:"p-4 border-b border-border bg-bg-subtle/50",children:(0,d.jsx)("h3",{className:"font-semibold",children:a})}),(0,d.jsx)("div",{className:"overflow-x-auto",children:(0,d.jsxs)("table",{className:"w-full text-sm text-left",children:[(0,d.jsx)("thead",{className:"bg-bg-subtle/30 text-text-muted uppercase text-xs",children:(0,d.jsxs)("tr",{children:[b.map(a=>(0,d.jsxs)("th",{className:`px-6 py-3 cursor-pointer hover:bg-bg-subtle/50 ${"right"===a.align?"text-right":""}`,onClick:()=>j(f,a.field),children:[a.label," ",(0,d.jsx)(p,{field:a.field,currentSort:g,currentOrder:h})]},a.field)),v.map(a=>(0,d.jsxs)("th",{className:"px-6 py-3 text-right cursor-pointer hover:bg-bg-subtle/50",onClick:()=>j(f,a.field),children:[a.label," ",(0,d.jsx)(p,{field:a.field,currentSort:g,currentOrder:h})]},a.field))]})}),(0,d.jsxs)("tbody",{className:"divide-y divide-border",children:[c.map(a=>(0,d.jsxs)(e.Fragment,{children:[(0,d.jsxs)("tr",{className:"group-summary cursor-pointer hover:bg-bg-subtle/50 transition-colors",onClick:()=>u(a.groupKey),children:[(0,d.jsx)("td",{className:"px-6 py-3",children:(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("span",{className:`material-symbols-outlined text-[18px] text-text-muted transition-transform ${s.has(a.groupKey)?"rotate-90":""}`,children:"chevron_right"}),(0,d.jsx)("span",{className:`font-medium transition-colors ${a.summary.pending>0?"text-primary":""}`,children:a.groupKey})]})}),n(a),(0,d.jsx)(q,{item:a.summary,viewMode:k,isSummary:!0})]}),s.has(a.groupKey)&&a.items.map(a=>(0,d.jsxs)("tr",{className:"group-detail hover:bg-bg-subtle/20 transition-colors",children:[m(a),(0,d.jsx)(q,{item:a,viewMode:k})]},`detail-${a.key}`))]},a.groupKey)),0===c.length&&(0,d.jsx)("tr",{children:(0,d.jsx)("td",{colSpan:w,className:"px-6 py-8 text-center text-text-muted",children:o})})]})]})})]})}p.propTypes={field:l().string.isRequired,currentSort:l().string.isRequired,currentOrder:l().string.isRequired},q.propTypes={item:l().object.isRequired,viewMode:l().string.isRequired,isSummary:l().bool},r.propTypes={title:l().string.isRequired,columns:l().arrayOf(l().shape({field:l().string.isRequired,label:l().string.isRequired,align:l().string})).isRequired,groupedData:l().array.isRequired,tableType:l().string.isRequired,sortBy:l().string.isRequired,sortOrder:l().string.isRequired,onToggleSort:l().func.isRequired,viewMode:l().string.isRequired,storageKey:l().string.isRequired,renderDetailCells:l().func.isRequired,renderSummaryCells:l().func.isRequired,emptyMessage:l().string.isRequired};var s=c(96103),t=c(22805);function u({data:a}){let{label:b,color:c,imageUrl:f,textIcon:g,active:h}=a,[i,j]=(0,e.useState)(!1);return(0,d.jsxs)("div",{className:"flex items-center gap-2.5 px-4 py-2.5 rounded-lg border-2 transition-all duration-300 bg-bg",style:{borderColor:h?c:"var(--color-border)",boxShadow:h?`0 0 16px ${c}40`:"none",minWidth:"150px"},children:[(0,d.jsx)(s.h7,{type:"target",position:t.yX.Top,id:"top",className:"!bg-transparent !border-0 !w-0 !h-0"}),(0,d.jsx)(s.h7,{type:"target",position:t.yX.Bottom,id:"bottom",className:"!bg-transparent !border-0 !w-0 !h-0"}),(0,d.jsx)(s.h7,{type:"target",position:t.yX.Left,id:"left",className:"!bg-transparent !border-0 !w-0 !h-0"}),(0,d.jsx)(s.h7,{type:"target",position:t.yX.Right,id:"right",className:"!bg-transparent !border-0 !w-0 !h-0"}),(0,d.jsx)("div",{className:"w-8 h-8 rounded-md flex items-center justify-center shrink-0",style:{backgroundColor:`${c}15`},children:i?(0,d.jsx)("span",{className:"text-sm font-bold",style:{color:c},children:g}):(0,d.jsx)("img",{src:f,alt:b,className:"w-6 h-6 rounded-sm object-contain",onError:()=>j(!0)})}),(0,d.jsx)("span",{className:"text-base font-medium truncate",style:{color:h?c:"var(--color-text)"},children:b}),h&&(0,d.jsxs)("span",{className:"relative flex h-2 w-2 shrink-0",children:[(0,d.jsx)("span",{className:"animate-ping absolute inline-flex h-full w-full rounded-full opacity-75",style:{backgroundColor:c}}),(0,d.jsx)("span",{className:"relative inline-flex rounded-full h-2 w-2",style:{backgroundColor:c}})]})]})}function v({data:a}){return(0,d.jsxs)("div",{className:"flex items-center justify-center px-5 py-3 rounded-xl border-2 border-primary bg-primary/5 shadow-md min-w-[130px]",children:[(0,d.jsx)(s.h7,{type:"source",position:t.yX.Top,id:"top",className:"!bg-transparent !border-0 !w-0 !h-0"}),(0,d.jsx)(s.h7,{type:"source",position:t.yX.Bottom,id:"bottom",className:"!bg-transparent !border-0 !w-0 !h-0"}),(0,d.jsx)(s.h7,{type:"source",position:t.yX.Left,id:"left",className:"!bg-transparent !border-0 !w-0 !h-0"}),(0,d.jsx)(s.h7,{type:"source",position:t.yX.Right,id:"right",className:"!bg-transparent !border-0 !w-0 !h-0"}),(0,d.jsx)("img",{src:"/favicon.svg",alt:"openrouterx",className:"w-6 h-6 mr-2"}),(0,d.jsx)("span",{className:"text-sm font-bold text-primary",children:"openrouterx"}),a.activeCount>0&&(0,d.jsx)("span",{className:"ml-2 px-1.5 py-0.5 rounded-full bg-primary text-white text-xs font-bold",children:a.activeCount})]})}c(71763),u.propTypes={data:l().object.isRequired},v.propTypes={data:l().object.isRequired};let w={provider:u,router:v};function x({providers:a=[],activeRequests:b=[],lastProvider:c="",errorProvider:f=""}){let h=(0,e.useMemo)(()=>b.map(a=>a.provider?.toLowerCase()).filter(Boolean).sort().join(","),[b]),i=c?.toLowerCase()||"",j=f?.toLowerCase()||"",k=(0,e.useMemo)(()=>new Set(h?h.split(","):[]),[h]),l=(0,e.useMemo)(()=>new Set(i?[i]:[]),[i]),m=(0,e.useMemo)(()=>new Set(j?[j]:[]),[j]),n=(0,e.useRef)({}),[o,p]=(0,e.useState)(0),q=(0,e.useMemo)(()=>{let a=Date.now(),b=new Set;for(let c of k){let d=n.current[c];(!d||a-d<6e4)&&b.add(c)}return b},[k,o]),{nodes:r,edges:t}=(0,e.useMemo)(()=>(function(a,b,c,d){let e=a.length,f=Math.max(320,204*e/(2*Math.PI)),h=Math.max(200,.55*f);if(0===e)return{nodes:[{id:"router",type:"router",position:{x:0,y:0},data:{activeCount:0},draggable:!1}],edges:[]};let i=[],j=[];return i.push({id:"router",type:"router",position:{x:-60,y:-22},data:{activeCount:b.size},draggable:!1}),a.forEach((a,k)=>{var l,m;let n,o,p=(l=a.provider,g.Q2[l]||{color:"#6b7280",name:l}),q=b.has(a.provider?.toLowerCase()),r=!q&&c.has(a.provider?.toLowerCase()),s=!q&&d.has(a.provider?.toLowerCase()),t=`provider-${a.provider}`,u={label:(p.name!==a.provider?p.name:null)||a.name||a.provider,color:p.color||"#6b7280",imageUrl:(m=a.provider,`/providers/${m}.png`),textIcon:p.textIcon||(a.provider||"?").slice(0,2).toUpperCase(),active:q},v=-Math.PI/2+2*Math.PI*k/e,w=f*Math.cos(v),x=h*Math.sin(v);Math.abs(v+Math.PI/2)<Math.PI/4||Math.abs(v-3*Math.PI/2)<Math.PI/4?(n="top",o="bottom"):Math.abs(v-Math.PI/2)<Math.PI/4?(n="bottom",o="top"):w>0?(n="right",o="left"):(n="left",o="right"),i.push({id:t,type:"provider",position:{x:w-90,y:x-15},data:u,draggable:!1}),j.push({id:`e-${t}`,source:"router",sourceHandle:n,target:t,targetHandle:o,animated:q,style:(p.color,s?{stroke:"#ef4444",strokeWidth:2.5,opacity:.9}:q?{stroke:"#22c55e",strokeWidth:2.5,opacity:.9}:r?{stroke:"#f59e0b",strokeWidth:2,opacity:.7}:{stroke:"var(--color-border)",strokeWidth:1,opacity:.3})})}),{nodes:i,edges:j}})(a,q,l,m),[a,q,i,j]),u=(0,e.useMemo)(()=>a.map(a=>a.provider).sort().join(","),[a]),v=(0,e.useRef)(null),y=(0,e.useRef)(null),z={padding:.2,duration:200},A=(0,e.useCallback)(a=>{v.current=a,setTimeout(()=>a.fitView(z),50)},[]);return(0,d.jsx)("div",{ref:y,className:"h-[320px] w-full min-w-0 rounded-lg border border-border bg-bg-subtle/30 sm:h-[480px]",children:0===a.length?(0,d.jsx)("div",{className:"h-full flex items-center justify-center text-text-muted text-sm",children:"No providers connected"}):(0,d.jsx)(s.Gc,{nodes:r,edges:t,nodeTypes:w,fitView:!0,fitViewOptions:z,minZoom:.1,maxZoom:2,onInit:A,proOptions:{hideAttribution:!0},panOnDrag:!0,zoomOnScroll:!0,zoomOnPinch:!0,zoomOnDoubleClick:!0,preventScrolling:!1,nodesDraggable:!1,nodesConnectable:!1,elementsSelectable:!1,children:(0,d.jsx)(s.H2,{showInteractive:!1,className:"react-flow-controls-custom"})},u)})}x.propTypes={providers:l().arrayOf(l().shape({id:l().string,provider:l().string,name:l().string})),activeRequests:l().arrayOf(l().shape({provider:l().string,model:l().string,account:l().string})),lastProvider:l().string,errorProvider:l().string};var y=c(80322),z=c(70452),A=c(28946),B=c(22393),C=c(54206),D=c(83954),E=c(44780);let F=a=>a>=1e6?`${(a/1e6).toFixed(1)}M`:a>=1e3?`${(a/1e3).toFixed(1)}K`:String(a||0),G=a=>`$${(a||0).toFixed(4)}`;function H({period:a="24h"}){let[b,c]=(0,e.useState)([]),[f,g]=(0,e.useState)(!0),[h,j]=(0,e.useState)("tokens");(0,e.useCallback)(async()=>{g(!0);try{let b=await fetch(`/api/usage/chart?period=${a}`);if(b.ok){let a=await b.json();c(a)}}catch(a){console.error("Failed to fetch chart data:",a)}finally{g(!1)}},[a]);let k=b.some(a=>a.tokens>0||a.cost>0);return(0,d.jsxs)(i.default,{className:"flex min-w-0 flex-col gap-3 p-3 sm:p-4",children:[(0,d.jsxs)("div",{className:"grid w-full grid-cols-2 items-center gap-1 rounded-lg border border-border bg-bg-subtle p-1 sm:w-auto sm:self-start",children:[(0,d.jsx)("button",{onClick:()=>j("tokens"),className:`px-3 py-1 rounded-md text-sm font-medium transition-colors ${"tokens"===h?"bg-primary text-white shadow-sm":"text-text-muted hover:text-text hover:bg-bg-hover"}`,children:"Tokens"}),(0,d.jsx)("button",{onClick:()=>j("cost"),className:`px-3 py-1 rounded-md text-sm font-medium transition-colors ${"cost"===h?"bg-primary text-white shadow-sm":"text-text-muted hover:text-text hover:bg-bg-hover"}`,children:"Cost"})]}),f?(0,d.jsx)("div",{className:"h-48 flex items-center justify-center text-text-muted text-sm",children:"Loading..."}):k?(0,d.jsx)(y.u,{width:"100%",height:220,children:(0,d.jsxs)(z.Q,{data:b,margin:{top:4,right:8,left:0,bottom:0},children:[(0,d.jsxs)("defs",{children:[(0,d.jsxs)("linearGradient",{id:"gradTokens",x1:"0",y1:"0",x2:"0",y2:"1",children:[(0,d.jsx)("stop",{offset:"5%",stopColor:"#6366f1",stopOpacity:.25}),(0,d.jsx)("stop",{offset:"95%",stopColor:"#6366f1",stopOpacity:0})]}),(0,d.jsxs)("linearGradient",{id:"gradCost",x1:"0",y1:"0",x2:"0",y2:"1",children:[(0,d.jsx)("stop",{offset:"5%",stopColor:"#f59e0b",stopOpacity:.25}),(0,d.jsx)("stop",{offset:"95%",stopColor:"#f59e0b",stopOpacity:0})]})]}),(0,d.jsx)(A.d,{strokeDasharray:"3 3",strokeOpacity:.1}),(0,d.jsx)(B.W,{dataKey:"label",tick:{fontSize:10,fill:"currentColor",fillOpacity:.5},tickLine:!1,axisLine:!1,interval:"preserveStartEnd"}),(0,d.jsx)(C.h,{tick:{fontSize:10,fill:"currentColor",fillOpacity:.5},tickLine:!1,axisLine:!1,tickFormatter:"tokens"===h?F:G,width:50}),(0,d.jsx)(D.m,{contentStyle:{backgroundColor:"var(--color-bg)",border:"1px solid var(--color-border)",borderRadius:"8px",fontSize:"12px"},formatter:(a,b)=>"tokens"===b?[F(a),"Tokens"]:[G(a),"Cost"]}),"tokens"===h?(0,d.jsx)(E.Gk,{type:"monotone",dataKey:"tokens",stroke:"#6366f1",strokeWidth:2,fill:"url(#gradTokens)",dot:!1,activeDot:{r:4}}):(0,d.jsx)(E.Gk,{type:"monotone",dataKey:"cost",stroke:"#f59e0b",strokeWidth:2,fill:"url(#gradCost)",dot:!1,activeDot:{r:4}})]})}):(0,d.jsx)("div",{className:"h-48 flex items-center justify-center text-text-muted text-sm",children:"No data for this period"})]})}function I({timestamp:a}){let b,[,c]=(0,e.useState)(0);return(0,d.jsx)(d.Fragment,{children:(b=Math.floor((Date.now()-new Date(a))/1e3))<60?`${b}s ago`:b<3600?`${Math.floor(b/60)}m ago`:b<86400?`${Math.floor(b/3600)}h ago`:`${Math.floor(b/86400)}d ago`})}function J({requests:a=[]}){return(0,d.jsxs)(i.default,{className:"flex min-w-0 flex-col overflow-hidden",padding:"sm",style:{height:480},children:[(0,d.jsx)("div",{className:"px-1 py-2 border-b border-border shrink-0",children:(0,d.jsx)("span",{className:"text-xs font-semibold text-text-muted uppercase tracking-wide",children:"Recent Requests"})}),a.length?(0,d.jsx)("div",{className:"flex-1 overflow-y-auto",children:(0,d.jsxs)("table",{className:"w-full min-w-[300px] border-collapse text-xs",children:[(0,d.jsx)("thead",{className:"sticky top-0 bg-bg z-10",children:(0,d.jsxs)("tr",{className:"border-b border-border",children:[(0,d.jsx)("th",{className:"py-1.5 text-left font-semibold text-text-muted w-2"}),(0,d.jsx)("th",{className:"py-1.5 text-left font-semibold text-text-muted",children:"Model"}),(0,d.jsx)("th",{className:"py-1.5 text-right font-semibold text-text-muted whitespace-nowrap",children:"In / Out"}),(0,d.jsx)("th",{className:"py-1.5 text-right font-semibold text-text-muted",children:"When"})]})}),(0,d.jsx)("tbody",{className:"divide-y divide-border/50",children:a.map((a,b)=>{let c=!a.status||"ok"===a.status||"success"===a.status;return(0,d.jsxs)("tr",{className:"hover:bg-bg-subtle transition-colors",children:[(0,d.jsx)("td",{className:"py-1.5",children:(0,d.jsx)("span",{className:`block w-1.5 h-1.5 rounded-full ${c?"bg-success":"bg-error"}`})}),(0,d.jsx)("td",{className:"py-1.5 font-mono truncate max-w-[120px]",title:a.model,children:a.model}),(0,d.jsxs)("td",{className:"py-1.5 text-right whitespace-nowrap",children:[(0,d.jsxs)("span",{className:"text-primary",children:[m(a.promptTokens),"↑"]})," ",(0,d.jsxs)("span",{className:"text-success",children:[m(a.completionTokens),"↓"]})]}),(0,d.jsx)("td",{className:"py-1.5 text-right text-text-muted whitespace-nowrap",children:(0,d.jsx)(I,{timestamp:a.timestamp})})]},b)})})]})}):(0,d.jsx)("div",{className:"flex-1 flex items-center justify-center text-text-muted text-sm",children:"No requests yet."})]})}function K(a,b={},c,d){return Object.entries(a||{}).map(([a,c])=>{let d=(c.promptTokens||0)+(c.completionTokens||0),e=c.cost||0,f=d>0?(c.promptTokens||0)*(e/d):0,g=d>0?(c.completionTokens||0)*(e/d):0;return{...c,key:a,totalTokens:d,totalCost:e,inputCost:f,outputCost:g,pending:b[a]||0}}).sort((a,b)=>{let e=a[c],f=b[c];return("string"==typeof e&&(e=e.toLowerCase()),"string"==typeof f&&(f=f.toLowerCase()),e<f)?"asc"===d?-1:1:e>f?"asc"===d?1:-1:0})}function L(a,b){if(!Array.isArray(a))return[];let c={};return a.forEach(a=>{let d=function(a,b){switch(b){case"rawModel":return a.rawModel||"Unknown Model";case"accountName":return a.accountName||`Account ${a.connectionId?.slice(0,8)}...`||"Unknown Account";case"keyName":return a.keyName||"Unknown Key";case"endpoint":return a.endpoint||"Unknown Endpoint";default:return a[b]||"Unknown"}}(a,b);c[d]||(c[d]={groupKey:d,summary:{requests:0,promptTokens:0,completionTokens:0,totalTokens:0,cost:0,inputCost:0,outputCost:0,lastUsed:null,pending:0},items:[]});let e=c[d].summary;e.requests+=a.requests||0,e.promptTokens+=a.promptTokens||0,e.completionTokens+=a.completionTokens||0,e.totalTokens+=a.totalTokens||0,e.cost+=a.cost||0,e.inputCost+=a.inputCost||0,e.outputCost+=a.outputCost||0,e.pending+=a.pending||0,a.lastUsed&&(!e.lastUsed||new Date(a.lastUsed)>new Date(e.lastUsed))&&(e.lastUsed=a.lastUsed),c[d].items.push(a)}),Object.values(c)}H.propTypes={period:l().string};let M=[{field:"rawModel",label:"Model"},{field:"provider",label:"Provider"},{field:"requests",label:"Requests",align:"right"},{field:"lastUsed",label:"Last Used",align:"right"}],N=[{field:"rawModel",label:"Model"},{field:"provider",label:"Provider"},{field:"accountName",label:"Account"},{field:"requests",label:"Requests",align:"right"},{field:"lastUsed",label:"Last Used",align:"right"}],O=[{field:"keyName",label:"API Key Name"},{field:"rawModel",label:"Model"},{field:"provider",label:"Provider"},{field:"requests",label:"Requests",align:"right"},{field:"lastUsed",label:"Last Used",align:"right"}],P=[{field:"endpoint",label:"Endpoint"},{field:"rawModel",label:"Model"},{field:"provider",label:"Provider"},{field:"requests",label:"Requests",align:"right"},{field:"lastUsed",label:"Last Used",align:"right"}],Q=[{value:"model",label:"Usage by Model"},{value:"account",label:"Usage by Account"},{value:"apiKey",label:"Usage by API Key"},{value:"endpoint",label:"Usage by Endpoint"}],R=[{value:"today",label:"Today"},{value:"24h",label:"24h"},{value:"7d",label:"7D"},{value:"30d",label:"30D"},{value:"60d",label:"60D"}];function S({period:a,setPeriod:b,hidePeriodSelector:c=!1}={}){let g=(0,f.useRouter)(),i=(0,f.useSearchParams)(),k=i.get("sortBy")||"rawModel",l=i.get("sortOrder")||"asc",[n,p]=(0,e.useState)(null),[q,s]=(0,e.useState)(!0),[t,u]=(0,e.useState)(!1),[v,w]=(0,e.useState)("model"),[y,z]=(0,e.useState)("costs"),[A,B]=(0,e.useState)([]),[C,D]=(0,e.useState)("today"),E=a??C,F=b??D,[G,I]=(0,e.useState)(null),[T,U]=(0,e.useState)(!1),V="sub_user"===G,W=V?"apiKey":v,X=(0,e.useCallback)((a,b)=>{let c=new URLSearchParams(i.toString());c.get("sortBy")===b?c.set("sortOrder","asc"===c.get("sortOrder")?"desc":"asc"):(c.set("sortBy",b),c.set("sortOrder","asc")),g.replace(`?${c.toString()}`,{scroll:!1})},[i,g]),Y=(0,e.useMemo)(()=>{if(!n)return null;switch(W){case"model":{let a=n.pending?.byModel||{};return{columns:M,groupedData:L(K(n.byModel,a,k,l),"rawModel"),storageKey:"usage-stats:expanded-models",emptyMessage:"No usage recorded yet.",renderSummaryCells:a=>(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("td",{className:"px-6 py-3 text-text-muted",children:"—"}),(0,d.jsx)("td",{className:"px-6 py-3 text-right",children:m(a.summary.requests)}),(0,d.jsx)("td",{className:"px-6 py-3 text-right text-text-muted whitespace-nowrap",children:o(a.summary.lastUsed)})]}),renderDetailCells:a=>(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("td",{className:`px-6 py-3 font-medium transition-colors ${a.pending>0?"text-primary":""}`,children:a.rawModel}),(0,d.jsx)("td",{className:"px-6 py-3",children:(0,d.jsx)(h.default,{variant:a.pending>0?"primary":"neutral",size:"sm",children:a.provider})}),(0,d.jsx)("td",{className:"px-6 py-3 text-right",children:m(a.requests)}),(0,d.jsx)("td",{className:"px-6 py-3 text-right text-text-muted whitespace-nowrap",children:o(a.lastUsed)})]})}}case"account":{let a={};return n?.pending?.byAccount&&Object.entries(n.byAccount||{}).forEach(([b,c])=>{let d=n.pending.byAccount[c.connectionId];if(d){let e=c.provider?`${c.rawModel} (${c.provider})`:c.rawModel;a[b]=d[e]||0}}),{columns:N,groupedData:L(K(n.byAccount,a,k,l),"accountName"),storageKey:"usage-stats:expanded-accounts",emptyMessage:"No account-specific usage recorded yet.",renderSummaryCells:a=>(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("td",{className:"px-6 py-3 text-text-muted",children:"—"}),(0,d.jsx)("td",{className:"px-6 py-3 text-text-muted",children:"—"}),(0,d.jsx)("td",{className:"px-6 py-3 text-right",children:m(a.summary.requests)}),(0,d.jsx)("td",{className:"px-6 py-3 text-right text-text-muted whitespace-nowrap",children:o(a.summary.lastUsed)})]}),renderDetailCells:a=>(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("td",{className:`px-6 py-3 font-medium transition-colors ${a.pending>0?"text-primary":""}`,children:a.accountName||`Account ${a.connectionId?.slice(0,8)}...`}),(0,d.jsx)("td",{className:`px-6 py-3 font-medium transition-colors ${a.pending>0?"text-primary":""}`,children:a.rawModel}),(0,d.jsx)("td",{className:"px-6 py-3",children:(0,d.jsx)(h.default,{variant:a.pending>0?"primary":"neutral",size:"sm",children:a.provider})}),(0,d.jsx)("td",{className:"px-6 py-3 text-right",children:m(a.requests)}),(0,d.jsx)("td",{className:"px-6 py-3 text-right text-text-muted whitespace-nowrap",children:o(a.lastUsed)})]})}}case"apiKey":return{columns:O,groupedData:L(K(n.byApiKey,{},k,l),"keyName"),storageKey:"usage-stats:expanded-apikeys",emptyMessage:"No API key usage recorded yet.",renderSummaryCells:a=>(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("td",{className:"px-6 py-3 text-text-muted",children:"—"}),(0,d.jsx)("td",{className:"px-6 py-3 text-text-muted",children:"—"}),(0,d.jsx)("td",{className:"px-6 py-3 text-right",children:m(a.summary.requests)}),(0,d.jsx)("td",{className:"px-6 py-3 text-right text-text-muted whitespace-nowrap",children:o(a.summary.lastUsed)})]}),renderDetailCells:a=>(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("td",{className:"px-6 py-3 font-medium",children:a.keyName}),(0,d.jsx)("td",{className:"px-6 py-3",children:a.rawModel}),(0,d.jsx)("td",{className:"px-6 py-3",children:(0,d.jsx)(h.default,{variant:"neutral",size:"sm",children:a.provider})}),(0,d.jsx)("td",{className:"px-6 py-3 text-right",children:m(a.requests)}),(0,d.jsx)("td",{className:"px-6 py-3 text-right text-text-muted whitespace-nowrap",children:o(a.lastUsed)})]})};default:return{columns:P,groupedData:L(K(n.byEndpoint,{},k,l),"endpoint"),storageKey:"usage-stats:expanded-endpoints",emptyMessage:"No endpoint usage recorded yet.",renderSummaryCells:a=>(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("td",{className:"px-6 py-3 text-text-muted",children:"—"}),(0,d.jsx)("td",{className:"px-6 py-3 text-text-muted",children:"—"}),(0,d.jsx)("td",{className:"px-6 py-3 text-right",children:m(a.summary.requests)}),(0,d.jsx)("td",{className:"px-6 py-3 text-right text-text-muted whitespace-nowrap",children:o(a.summary.lastUsed)})]}),renderDetailCells:a=>(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("td",{className:"px-6 py-3 font-medium font-mono text-sm",children:a.endpoint}),(0,d.jsx)("td",{className:"px-6 py-3",children:a.rawModel}),(0,d.jsx)("td",{className:"px-6 py-3",children:(0,d.jsx)(h.default,{variant:"neutral",size:"sm",children:a.provider})}),(0,d.jsx)("td",{className:"px-6 py-3 text-right",children:m(a.requests)}),(0,d.jsx)("td",{className:"px-6 py-3 text-right text-text-muted whitespace-nowrap",children:o(a.lastUsed)})]})}}},[n,W,k,l]);if(!n&&!q)return(0,d.jsx)("div",{className:"text-text-muted",children:"Failed to load usage statistics."});let Z=(0,d.jsx)("div",{className:"flex items-center justify-center py-12 text-text-muted",children:(0,d.jsx)("span",{className:"material-symbols-outlined text-[32px] animate-spin",children:"progress_activity"})});return(0,d.jsxs)("div",{className:"flex min-w-0 flex-col gap-6",children:[!c&&(0,d.jsxs)("div",{className:"flex w-full items-center gap-2 sm:w-auto sm:self-end",children:[(0,d.jsx)("div",{className:"grid flex-1 grid-cols-5 items-center gap-1 rounded-lg border border-border bg-bg-subtle p-1 sm:flex sm:flex-none",children:R.map(a=>(0,d.jsx)("button",{onClick:()=>F(a.value),disabled:t,className:`rounded-md px-3 py-1 text-sm font-medium transition-colors ${E===a.value?"bg-primary text-white shadow-sm":"text-text-muted hover:bg-bg-hover hover:text-text"}`,children:a.label},a.value))}),t&&(0,d.jsx)("span",{className:"material-symbols-outlined text-[16px] text-text-muted animate-spin",children:"progress_activity"})]}),q?Z:(0,d.jsx)(j.A,{stats:n}),!T||V||q?null:(0,d.jsxs)("div",{className:"grid min-w-0 grid-cols-1 items-stretch gap-2 lg:grid-cols-[minmax(0,2fr)_minmax(280px,1fr)]",children:[(0,d.jsx)(x,{providers:A,activeRequests:n.activeRequests||[],lastProvider:n.recentRequests?.[0]?.provider||"",errorProvider:n.errorProvider||""}),(0,d.jsx)(J,{requests:n.recentRequests||[]})]}),q?Z:(0,d.jsx)(H,{period:E}),(0,d.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,d.jsxs)("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between",children:[T?V?(0,d.jsx)("div",{className:"w-full rounded-lg border border-border bg-bg-subtle px-3 py-1.5 text-sm font-medium text-text sm:w-auto",children:"Usage by API Key"}):(0,d.jsx)("select",{value:v,onChange:a=>w(a.target.value),className:"w-full rounded-lg border border-border bg-bg-subtle px-3 py-1.5 text-sm font-medium text-text focus:outline-none focus:ring-2 focus:ring-primary/50 sm:w-auto",children:Q.map(a=>(0,d.jsx)("option",{value:a.value,children:a.label},a.value))}):(0,d.jsx)("div",{className:"h-[38px]"}),(0,d.jsxs)("div",{className:"grid grid-cols-2 items-center gap-1 rounded-lg border border-border bg-bg-subtle p-1 sm:flex",children:[(0,d.jsx)("button",{onClick:()=>z("costs"),className:`px-3 py-1 rounded-md text-sm font-medium transition-colors ${"costs"===y?"bg-primary text-white shadow-sm":"text-text-muted hover:text-text hover:bg-bg-hover"}`,children:"Costs"}),(0,d.jsx)("button",{onClick:()=>z("tokens"),className:`px-3 py-1 rounded-md text-sm font-medium transition-colors ${"tokens"===y?"bg-primary text-white shadow-sm":"text-text-muted hover:text-text hover:bg-bg-hover"}`,children:"Tokens"})]})]}),q?Z:Y&&(0,d.jsx)(r,{title:"",columns:Y.columns,groupedData:Y.groupedData,tableType:W,sortBy:k,sortOrder:l,onToggleSort:X,viewMode:y,storageKey:Y.storageKey,renderSummaryCells:Y.renderSummaryCells,renderDetailCells:Y.renderDetailCells,emptyMessage:Y.emptyMessage})]})]})}},31402:(a,b,c)=>{c.d(b,{default:()=>k});var d=c(48249),e=c(67484),f=c(49885),g=c.n(f),h=c(50412),i=c(66828),j=c(45390);function k({isOpen:a,onClose:b,onCreated:c,onSaved:f,node:g}){let l=!!g,[m,n]=(0,e.useState)({name:"",prefix:"",baseUrl:"https://api.openai.com/v1",defaultSize:""}),[o,p]=(0,e.useState)(""),[q,r]=(0,e.useState)(""),[s,t]=(0,e.useState)(!1),[u,v]=(0,e.useState)(""),[w,x]=(0,e.useState)(""),[y,z]=(0,e.useState)(!1),[A,B]=(0,e.useState)(null),C=async()=>{if(m.name.trim()&&m.prefix.trim()&&m.baseUrl.trim()){t(!0);try{let a=l?`/api/provider-nodes/${g.id}`:"/api/provider-nodes",b={name:m.name,prefix:m.prefix,baseUrl:m.baseUrl,defaultSize:m.defaultSize.trim()};l||(b.type="custom-image");let d=await fetch(a,{method:l?"PUT":"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(b)}),e=await d.json();d.ok&&(l?f?.(e.node):c?.(e.node))}catch(a){console.log("Error saving custom image node:",a)}finally{t(!1)}}},D=async()=>{z(!0);try{let a=await fetch("/api/provider-nodes/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({baseUrl:m.baseUrl,apiKey:u,type:"custom-image",modelId:w.trim()||void 0,imageSize:m.defaultSize.trim()||void 0})}),b=await a.json();b.normalizedBaseUrl&&n(a=>({...a,baseUrl:b.normalizedBaseUrl})),B(b)}catch{B({valid:!1,error:"Network error"})}finally{z(!1)}};return(0,d.jsx)(h.aF,{isOpen:a,title:l?"Edit Custom Image":"Add Custom Image",onClose:b,children:(0,d.jsxs)("div",{className:"flex flex-col gap-4",children:[!l&&(0,d.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,d.jsx)("label",{className:"text-sm font-medium text-text-main",children:"Import From cURL"}),(0,d.jsx)("textarea",{value:o,onChange:a=>p(a.target.value),placeholder:'curl https://api.example.com/v1/images/generations -H "Authorization: Bearer sk-xxx" -H "Content-Type: application/json" -d \'{"model":"gpt-image-1","prompt":"A cute cat","size":"1024x1024","n":1}\'',className:"min-h-32 w-full rounded-lg border border-border bg-surface px-3 py-2 text-sm focus:outline-none focus:ring-1 focus:ring-primary/50"}),(0,d.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,d.jsx)("p",{className:"text-xs text-text-muted",children:"Paste a working OpenAI-compatible image curl command to auto-fill fields."}),(0,d.jsx)(h.$n,{onClick:()=>{try{let a=(0,j.rk)(o);n({name:a.defaultName,prefix:a.defaultPrefix,baseUrl:a.baseUrl,defaultSize:a.imageSize||""}),v(a.apiKey||""),x(a.modelId||""),r("")}catch(a){r(a.message||"Failed to parse curl")}},variant:"secondary",children:"Parse cURL"})]}),q&&(0,d.jsx)("p",{className:"text-sm text-red-500",children:q})]}),(0,d.jsx)(h.pd,{label:"Name",value:m.name,onChange:a=>n({...m,name:a.target.value}),placeholder:"SenseNova Image",hint:"Required. A friendly label for this image provider."}),(0,d.jsx)(h.pd,{label:"Prefix",value:m.prefix,onChange:a=>n({...m,prefix:a.target.value}),placeholder:"sensenova",hint:"Required. Used as the provider prefix for model IDs (e.g. sensenova/sensenova-u1-fast)."}),(0,d.jsx)(h.pd,{label:"Base URL",value:m.baseUrl,onChange:a=>n({...m,baseUrl:a.target.value}),placeholder:"https://token.sensenova.cn/v1",hint:"The app will append /images/generations automatically."}),(0,d.jsxs)("div",{children:[(0,d.jsx)("label",{className:"text-xs text-text-muted mb-1 block",children:"Default Size"}),(0,d.jsxs)("select",{className:"w-full px-3 py-2 text-sm border border-border rounded-lg bg-background focus:outline-none focus:border-primary",value:m.defaultSize,onChange:a=>n({...m,defaultSize:a.target.value}),children:[(0,d.jsx)("option",{value:"",children:"Use fallback"}),i.z.filter(a=>"auto"!==a).map(a=>(0,d.jsx)("option",{value:a,children:a},a))]}),(0,d.jsx)("p",{className:"mt-1 text-xs text-text-muted",children:"Used by model test and request example for vendors with restricted sizes."})]}),(0,d.jsx)(h.pd,{label:"API Key (for Check)",type:"password",value:u,onChange:a=>v(a.target.value)}),(0,d.jsx)(h.pd,{label:"Model ID (for Check)",value:w,onChange:a=>x(a.target.value),placeholder:"e.g. sensenova-u1-fast",hint:"Required for validation. Will send a test image generation request."}),(0,d.jsxs)("div",{className:"flex items-center gap-3",children:[(0,d.jsx)(h.$n,{onClick:D,disabled:!u||!w.trim()||y||!m.baseUrl.trim(),variant:"secondary",children:y?"Checking...":"Check"}),(()=>{if(!A)return null;let{valid:a,error:b}=A;return a?(0,d.jsx)(h.Ex,{variant:"success",children:"Valid"}):(0,d.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,d.jsx)(h.Ex,{variant:"error",children:"Invalid"}),b&&(0,d.jsx)("span",{className:"text-sm text-red-500",children:b})]})})()]}),(0,d.jsxs)("div",{className:"flex gap-2",children:[(0,d.jsx)(h.$n,{onClick:C,fullWidth:!0,disabled:!m.name.trim()||!m.prefix.trim()||!m.baseUrl.trim()||s,children:s?l?"Saving...":"Creating...":l?"Save":"Create"}),(0,d.jsx)(h.$n,{onClick:b,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})})}k.propTypes={isOpen:g().bool.isRequired,onClose:g().func.isRequired,onCreated:g().func,onSaved:g().func,node:g().shape({id:g().string,name:g().string,prefix:g().string,baseUrl:g().string,defaultSize:g().string})}},32971:(a,b,c)=>{c.d(b,{default:()=>e});var d=c(48249);function e({text:a,children:b,position:c="top",color:f}){let g=f?"":"bg-gray-900";return(0,d.jsxs)("div",{className:"relative inline-flex group",children:[b,(0,d.jsx)("div",{className:`pointer-events-none absolute ${{top:"bottom-full left-1/2 -translate-x-1/2 mb-1.5",bottom:"top-full left-1/2 -translate-x-1/2 mt-1.5",left:"right-full top-1/2 -translate-y-1/2 mr-1.5",right:"left-full top-1/2 -translate-y-1/2 ml-1.5"}[c]} z-50 w-max max-w-56 rounded px-2 py-1 text-[11px] leading-snug ${g} text-white opacity-0 group-hover:opacity-100 transition-opacity duration-150 whitespace-normal`,style:f?{backgroundColor:f}:{},children:a})]})}},37365:(a,b,c)=>{c.d(b,{C:()=>d});let d=(0,c(31417).v)(a=>({query:"",placeholder:"",visible:!1,setQuery:b=>a({query:b}),register:(b="Search...")=>a({visible:!0,placeholder:b,query:""}),unregister:()=>a({visible:!1,placeholder:"",query:""})}))},37900:(a,b,c)=>{c.d(b,{Od:()=>i,UserRoleProvider:()=>g,hd:()=>h});var d=c(48249),e=c(67484);let f=(0,e.createContext)({role:null,userId:null,displayName:null});function g({role:a,userId:b,displayName:c,children:h}){let[i,j]=(0,e.useState)({role:a,userId:b,displayName:c});return(0,d.jsx)(f.Provider,{value:i,children:h})}function h(){return(0,e.useContext)(f)}function i(){let{role:a}=(0,e.useContext)(f);return"super_admin"===a}},39645:(a,b,c)=>{c.d(b,{default:()=>i});var d=c(48249),e=c(67484),f=c(95145),g=c(99070),h=c(50377);function i({isOpen:a,onClose:b,title:c="Manual Configuration",configs:j=[]}){let{copy:k}=(0,h.C)(),[l,m]=(0,e.useState)(null);return(0,d.jsx)(f.default,{isOpen:a,onClose:b,title:c,size:"xl",children:(0,d.jsx)("div",{className:"flex flex-col gap-4",children:j.map((a,b)=>(0,d.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,d.jsxs)("div",{className:"flex items-center justify-between",children:[(0,d.jsx)("span",{className:"text-sm font-medium text-text-main",children:a.filename}),(0,d.jsxs)(g.default,{variant:"ghost",size:"sm",onClick:()=>{var c;return c=a.content,void(k(c,`manualconfig-${b}`),m(b),setTimeout(()=>m(null),2e3))},children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:l===b?"check":"content_copy"}),l===b?"Copied!":"Copy"]})]}),(0,d.jsx)("pre",{className:"px-3 py-2 bg-black/5 dark:bg-white/5 rounded font-mono text-xs overflow-x-auto whitespace-pre-wrap break-all max-h-60 overflow-y-auto border border-border",children:a.content})]},b))})})}},41371:(a,b,c)=>{c.d(b,{i:()=>f});var d=c(31417);let e=0,f=(0,d.v)((a,b)=>({notifications:[],addNotification:c=>{let d=++e,f={id:d,type:c.type||"info",message:c.message,title:c.title||null,duration:c.duration??5e3,dismissible:c.dismissible??!0,createdAt:Date.now()};return a(a=>({notifications:[...a.notifications,f]})),f.duration>0&&setTimeout(()=>b().removeNotification(d),f.duration),d},removeNotification:b=>{a(a=>({notifications:a.notifications.filter(a=>a.id!==b)}))},clearAll:()=>a({notifications:[]}),success:(a,c)=>b().addNotification({type:"success",message:a,title:c}),error:(a,c)=>b().addNotification({type:"error",message:a,title:c,duration:8e3}),warning:(a,c)=>b().addNotification({type:"warning",message:a,title:c}),info:(a,c)=>b().addNotification({type:"info",message:a,title:c})}))},42118:(a,b,c)=>{c.d(b,{D:()=>i});var d=c(67484),e=c(13033);function f(a){return()=>{}}function g(){return!1}function h(){return!1}function i(){let{theme:a,setTheme:b,toggleTheme:c,initTheme:i}=(0,e.A)(),j=(0,d.useSyncExternalStore)(f,g,h);return{theme:a,setTheme:b,toggleTheme:c,isDark:"dark"===a||"system"===a&&j}}},42196:(a,b,c)=>{c.d(b,{default:()=>w});var d=c(48249),e=c(67484),f=c(49885),g=c.n(f),h=c(2116),i=c.n(h),j=c(19099),k=c(71404),l=c(12020),m=c(96919),n=c(50377),o=c(37900),p=c(99070),q=c(95145);let r=["embedding","image","tts","stt"],s="/dashboard/media-providers/web",t=[{href:"/dashboard/endpoint",label:"Endpoint",icon:"api"},{href:"/dashboard/providers",label:"Providers",icon:"dns"},{href:"/dashboard/combos",label:"Combos",icon:"layers"},{href:"/dashboard/endpoint#auto-routes",label:"Auto Routes",icon:"route"},{href:"/dashboard/usage",label:"Usage",icon:"bar_chart"},{href:"/dashboard/quota",label:"Quota Tracker",icon:"data_usage"},{href:"/dashboard/mitm",label:"MITM",icon:"security"},{href:"/dashboard/focus-ui",label:"Focus UI",icon:"visibility"},{href:"/dashboard/cli-tools",label:"CLI Tools",icon:"terminal"}],u=[{href:"/dashboard/network-analysis",label:"Network Analysis",icon:"network_check"},{href:"/dashboard/console-log",label:"Console Log",icon:"terminal"},{href:"/dashboard/translator",label:"Translator",icon:"translate"}],v=[{href:"/dashboard/proxy-pools",label:"Proxy Pools",icon:"lan"},{href:"/dashboard/skills",label:"Skills",icon:"extension"}];function w({onClose:a,collapsed:b=!1,onCollapsedChange:c}){let f=(0,j.usePathname)(),g=(0,o.Od)(),{permissions:h=[]}=(0,o.hd)(),y=g||h.includes("view_usage"),z=g?t:t.filter(a=>"/dashboard/usage"===a.href?y:!["/dashboard/providers","/dashboard/combos","/dashboard/mitm","/dashboard/focus-ui","/dashboard/cli-tools","/dashboard/proxy-pools","/dashboard/quota","/dashboard/network-analysis"].includes(a.href)),[A,B]=(0,e.useState)(!1),[C,D]=(0,e.useState)(!1),[E,F]=(0,e.useState)(!1),[G,H]=(0,e.useState)(!1),[I,J]=(0,e.useState)(null),[K,L]=(0,e.useState)(!1),[M,N]=(0,e.useState)(!1),[O,P]=(0,e.useState)(0),[Q,R]=(0,e.useState)(!1),{copied:S,copy:T}=(0,n.C)(2e3),U=l.h0.installCmdLatest||l.h0.installCmd,V=a=>"/dashboard/endpoint"===a?"/dashboard"===f||f.startsWith("/dashboard/endpoint"):f.startsWith(a),W=async()=>{try{await navigator.clipboard.writeText(U)}catch{}T(U);let a=l.h0.shutdownCountdownSec;P(a);let b=setInterval(()=>{P(a-=1),a<=0&&(clearInterval(b),fetch("/api/version/shutdown",{method:"POST"}).catch(()=>{}),H(!0))},1e3)},X=async()=>{F(!0);try{await fetch("/api/version/shutdown",{method:"POST"})}catch(a){}F(!1),D(!1),H(!0)};return(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("aside",{className:(0,k.cn)("flex flex-col border-r border-border-subtle bg-vibrancy backdrop-blur-xl transition-all duration-300 min-h-full",b?"w-20":"w-72"),children:[(0,d.jsxs)("div",{className:(0,k.cn)("flex items-center px-6 pt-5 pb-2",b?"justify-center":"justify-between"),children:[!b&&(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("div",{className:"w-3 h-3 rounded-full bg-[#FF5F56]"}),(0,d.jsx)("div",{className:"w-3 h-3 rounded-full bg-[#FFBD2E]"}),(0,d.jsx)("div",{className:"w-3 h-3 rounded-full bg-[#27C93F]"})]}),"function"==typeof c&&(0,d.jsx)("button",{type:"button",onClick:()=>c(!b),className:"flex size-8 items-center justify-center rounded-lg text-text-muted transition-colors hover:bg-surface-2 hover:text-text-main","aria-label":b?"Expand sidebar":"Collapse sidebar",title:b?"Expand sidebar":"Collapse sidebar",children:(0,d.jsx)("span",{className:"material-symbols-outlined text-[20px]",children:b?"left_panel_open":"left_panel_close"})})]}),(0,d.jsxs)("div",{className:(0,k.cn)("py-4 flex flex-col gap-2",b?"px-0 items-center":"px-6"),children:[(0,d.jsxs)(i(),{href:"/dashboard",className:(0,k.cn)("flex items-center",b?"justify-center":"gap-3"),children:[(0,d.jsx)("div",{className:"flex items-center justify-center size-9 rounded-[10px] bg-gradient-to-br from-brand-500 to-brand-700 shadow-[var(--shadow-warm)]",children:(0,d.jsx)("span",{className:"material-symbols-outlined text-white text-[20px]",children:"hub"})}),(0,d.jsxs)("div",{className:(0,k.cn)("flex flex-col",b&&"hidden"),children:[(0,d.jsx)("h1",{className:"text-lg font-semibold tracking-tight text-text-main",children:l.vQ.name}),(0,d.jsxs)("span",{className:"text-xs text-text-muted",children:["v",l.vQ.version]})]})]}),I&&!b&&(0,d.jsxs)("div",{className:"flex flex-col gap-1.5 rounded p-1 -m-1",children:[(0,d.jsxs)("span",{className:"text-xs font-semibold text-green-600 dark:text-amber-500",children:["↑ New version available: v",I.latestVersion]}),(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("button",{onClick:()=>L(!0),className:"px-2 py-1 rounded bg-green-600 hover:bg-green-700 dark:bg-amber-500 dark:hover:bg-amber-600 text-white text-[11px] font-semibold transition-colors cursor-pointer",children:"Update now"}),(0,d.jsx)("button",{onClick:()=>T(U),title:"Copy install command",className:"flex-1 text-left hover:opacity-80 transition-opacity cursor-pointer min-w-0",children:(0,d.jsx)("code",{className:"block text-[10px] text-green-600/80 dark:text-amber-400/70 font-mono truncate",children:S?"✓ copied!":U})})]})]})]}),(0,d.jsxs)("nav",{className:(0,k.cn)("flex-1 py-2 space-y-1 overflow-y-auto custom-scrollbar",b?"px-3":"px-4"),children:[z.map(c=>(0,d.jsxs)(i(),{href:c.href,onClick:a,title:b?c.label:void 0,className:(0,k.cn)("flex items-center rounded-lg transition-all group",b?"justify-center px-0 py-2":"gap-3 px-3 py-1",V(c.href)?"bg-primary/10 text-primary":"text-text-muted hover:bg-surface-2 hover:text-text-main"),children:[(0,d.jsx)("span",{className:(0,k.cn)("material-symbols-outlined text-[18px]",V(c.href)?"fill-1":"group-hover:text-primary transition-colors"),children:c.icon}),(0,d.jsx)("span",{className:(0,k.cn)("text-[13px] font-medium",b&&"hidden"),children:c.label})]},c.href)),g&&(0,d.jsxs)("div",{className:"pt-4 mt-2",children:[(0,d.jsx)("p",{className:(0,k.cn)("px-4 text-xs font-semibold text-text-muted/60 uppercase tracking-wider mb-2",b&&"hidden"),children:"Admin"}),[{href:"/dashboard/admin/users",label:"User Management",icon:"manage_accounts"},{href:"/dashboard/admin/keys",label:"Key Management",icon:"key"}].map(c=>(0,d.jsxs)(i(),{href:c.href,onClick:a,title:b?c.label:void 0,className:(0,k.cn)("flex items-center rounded-lg transition-all group",b?"justify-center px-0 py-2":"gap-3 px-4 py-2",V(c.href)?"bg-primary/10 text-primary":"text-text-muted hover:bg-surface/50 hover:text-text-main"),children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[18px] group-hover:text-primary transition-colors",children:c.icon}),(0,d.jsx)("span",{className:(0,k.cn)("text-sm font-medium",b&&"hidden"),children:c.label})]},c.href))]}),(0,d.jsxs)("div",{className:"pt-3 mt-2 space-y-0.5",children:[(0,d.jsx)("p",{className:(0,k.cn)("px-4 text-xs font-semibold text-text-muted/60 uppercase tracking-wider mb-2",b&&"hidden"),children:"System"}),(0,d.jsxs)("button",{onClick:()=>B(a=>!a),title:b?"Media Providers":void 0,className:(0,k.cn)("w-full flex items-center rounded-lg transition-all group",b?"justify-center px-0 py-2":"gap-3 px-3 py-1",f.startsWith("/dashboard/media-providers")?"bg-primary/10 text-primary":"text-text-muted hover:bg-surface-2 hover:text-text-main"),children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"perm_media"}),(0,d.jsx)("span",{className:(0,k.cn)("text-[13px] font-medium flex-1 text-left",b&&"hidden"),children:"Media Providers"}),(0,d.jsx)("span",{className:(0,k.cn)("material-symbols-outlined text-[14px] transition-transform",b&&"hidden"),style:{transform:A?"rotate(180deg)":"rotate(0deg)"},children:"expand_more"})]}),A&&!b&&(0,d.jsxs)("div",{className:"pl-4",children:[m.rj.filter(a=>r.includes(a.id)).map(b=>(0,d.jsxs)(i(),{href:`/dashboard/media-providers/${b.id}`,onClick:a,className:(0,k.cn)("flex items-center gap-3 px-4 py-1 rounded-lg transition-all group",f.startsWith(`/dashboard/media-providers/${b.id}`)?"bg-primary/10 text-primary":"text-text-muted hover:bg-surface-2 hover:text-text-main"),children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:b.icon}),(0,d.jsx)("span",{className:"text-sm",children:b.label})]},b.id)),(0,d.jsxs)(i(),{href:s,onClick:a,className:(0,k.cn)("flex items-center gap-3 px-4 py-1 rounded-lg transition-all group",f.startsWith(s)?"bg-primary/10 text-primary":"text-text-muted hover:bg-surface-2 hover:text-text-main"),children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"travel_explore"}),(0,d.jsx)("span",{className:"text-sm",children:"Web Fetch & Search"})]},"web")]}),v.map(c=>(0,d.jsxs)(i(),{href:c.href,onClick:a,title:b?c.label:void 0,className:(0,k.cn)("flex items-center rounded-lg transition-all group",b?"justify-center px-0 py-2":"gap-3 px-3 py-1",V(c.href)?"bg-primary/10 text-primary":"text-text-muted hover:bg-surface-2 hover:text-text-main"),children:[(0,d.jsx)("span",{className:(0,k.cn)("material-symbols-outlined text-[18px]",V(c.href)?"fill-1":"group-hover:text-primary transition-colors"),children:c.icon}),(0,d.jsx)("span",{className:(0,k.cn)("text-[13px] font-medium",b&&"hidden"),children:c.label})]},c.href)),u.map(c=>"/dashboard/translator"!==c.href||Q?(0,d.jsxs)(i(),{href:c.href,onClick:a,title:b?c.label:void 0,className:(0,k.cn)("flex items-center rounded-lg transition-all group",b?"justify-center px-0 py-2":"gap-3 px-4 py-2",V(c.href)?"bg-primary/10 text-primary":"text-text-muted hover:bg-surface/50 hover:text-text-main"),children:[(0,d.jsx)("span",{className:(0,k.cn)("material-symbols-outlined text-[18px]",V(c.href)?"fill-1":"group-hover:text-primary transition-colors"),children:c.icon}),(0,d.jsx)("span",{className:(0,k.cn)("text-sm font-medium",b&&"hidden"),children:c.label})]},c.href):null),(0,d.jsxs)(i(),{href:"/dashboard/profile",onClick:a,title:b?"Settings":void 0,className:(0,k.cn)("flex items-center rounded-lg transition-all group",b?"justify-center px-0 py-2":"gap-3 px-3 py-1",V("/dashboard/profile")?"bg-primary/10 text-primary":"text-text-muted hover:bg-surface-2 hover:text-text-main"),children:[(0,d.jsx)("span",{className:(0,k.cn)("material-symbols-outlined text-[18px]",V("/dashboard/profile")?"fill-1":"group-hover:text-primary transition-colors"),children:"settings"}),(0,d.jsx)("span",{className:(0,k.cn)("text-[13px] font-medium",b&&"hidden"),children:"Settings"})]})]})]}),(0,d.jsx)("div",{className:"p-3 border-t border-border-subtle",children:b?(0,d.jsx)("button",{type:"button",onClick:()=>D(!0),className:"flex size-10 w-full items-center justify-center rounded-lg border border-red-200 text-red-500 transition-colors hover:bg-red-50 hover:border-red-300","aria-label":"Shutdown",title:"Shutdown",children:(0,d.jsx)("span",{className:"material-symbols-outlined text-[20px]",children:"power_settings_new"})}):(0,d.jsx)(p.default,{variant:"outline",fullWidth:!0,icon:"power_settings_new",onClick:()=>D(!0),className:"text-red-500 border-red-200 hover:bg-red-50 hover:border-red-300",children:"Shutdown"})})]}),(0,d.jsx)(q.ConfirmModal,{isOpen:C,onClose:()=>D(!1),onConfirm:X,title:"Close Proxy",message:"Are you sure you want to close the proxy server?",confirmText:"Close",cancelText:"Cancel",variant:"danger",loading:E}),(0,d.jsx)(q.ConfirmModal,{isOpen:K,onClose:()=>L(!1),onConfirm:()=>{L(!1),N(!0)},title:"Update OpenrouterX",message:`Show install command for v${I?.latestVersion||""}? You can copy it and shutdown to install manually.`,confirmText:"Show Command",cancelText:"Cancel",variant:"primary"}),(G||M)&&(0,d.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/80 backdrop-blur-sm p-6",children:M?(0,d.jsx)(x,{latestVersion:I?.latestVersion,installCmd:U,copied:S,onCopyAndShutdown:W,onCancel:()=>{N(!1),P(0)},countdown:O,isDisconnected:G}):(0,d.jsxs)("div",{className:"text-center p-8",children:[(0,d.jsx)("div",{className:"flex items-center justify-center size-16 rounded-full bg-red-500/20 text-red-500 mx-auto mb-4",children:(0,d.jsx)("span",{className:"material-symbols-outlined text-[32px]",children:"power_off"})}),(0,d.jsx)("h2",{className:"text-xl font-semibold text-white mb-2",children:"Server Disconnected"}),(0,d.jsx)("p",{className:"text-text-muted mb-6",children:"The proxy server has been stopped."}),(0,d.jsx)(p.default,{variant:"secondary",onClick:()=>globalThis.location.reload(),children:"Reload Page"})]})})]})}function x({latestVersion:a,installCmd:b,copied:c,onCopyAndShutdown:e,onCancel:f,countdown:g,isDisconnected:h}){let i=g>0;return(0,d.jsxs)("div",{className:"w-full max-w-lg rounded-xl bg-neutral-900/95 border border-white/10 p-6 text-white",children:[(0,d.jsxs)("div",{className:"flex items-center gap-3 mb-4",children:[(0,d.jsx)("div",{className:"flex items-center justify-center size-11 rounded-full bg-amber-500/20 text-amber-400",children:(0,d.jsx)("span",{className:"material-symbols-outlined text-[24px]",children:"content_copy"})}),(0,d.jsxs)("div",{children:[(0,d.jsxs)("h2",{className:"text-lg font-semibold",children:["Update OpenrouterX",a?` to v${a}`:""]}),(0,d.jsx)("p",{className:"text-xs text-white/60",children:h?"Server stopped. Paste the command into a terminal to install.":i?`Command copied. Server will stop in ${g}s...`:"Click the button below to copy the install command and shutdown."})]})]}),(0,d.jsx)("p",{className:"text-sm text-white/80 mb-2",children:"Install command:"}),(0,d.jsx)("div",{className:"w-full px-3 py-2 rounded bg-white/5 mb-4",children:(0,d.jsx)("code",{className:"text-xs font-mono text-amber-400 break-all",children:b})}),(0,d.jsxs)("ol",{className:"text-xs text-white/70 space-y-1 list-decimal list-inside mb-4",children:[(0,d.jsxs)("li",{children:["Click ",(0,d.jsx)("strong",{children:"Copy & Shutdown"})," below."]}),(0,d.jsx)("li",{children:"Paste the command into your terminal and press Enter."}),(0,d.jsxs)("li",{children:["Run ",(0,d.jsx)("code",{className:"px-1 rounded bg-white/10 text-green-400",children:"openrouterX"})," again after install."]})]}),h?(0,d.jsx)(p.default,{variant:"secondary",fullWidth:!0,onClick:()=>globalThis.location.reload(),children:"Reload Page"}):(0,d.jsxs)("div",{className:"flex gap-2",children:[(0,d.jsx)(p.default,{variant:"secondary",onClick:f,disabled:i,children:"Cancel"}),(0,d.jsx)(p.default,{variant:"primary",fullWidth:!0,onClick:e,disabled:i,children:c?"✓ Copied — shutting down...":i?`Shutting down in ${g}s`:"Copy & Shutdown"})]})]})}w.propTypes={onClose:g().func,collapsed:g().bool,onCollapsedChange:g().func},x.propTypes={latestVersion:g().string,installCmd:g().string.isRequired,copied:g().bool,onCopyAndShutdown:g().func.isRequired,onCancel:g().func.isRequired,countdown:g().number,isDisconnected:g().bool}},43182:(a,b,c)=>{c.d(b,{default:()=>j});var d=c(48249),e=c(67484),f=c(49885),g=c.n(f),h=c(50412);let i="https://gitlab.com";function j({isOpen:a,providerInfo:b,onSuccess:c,onClose:f}){let[g,k]=(0,e.useState)(null),[l,m]=(0,e.useState)(i),[n,o]=(0,e.useState)(""),[p,q]=(0,e.useState)(""),[r,s]=(0,e.useState)(""),[t,u]=(0,e.useState)(!1),[v,w]=(0,e.useState)(null),[x,y]=(0,e.useState)(!1),[z,A]=(0,e.useState)(null),B=()=>{k(null),m(i),o(""),q(""),s(""),w(null),u(!1),y(!1),A(null),f()},C=async()=>{if(!r.trim())return void w("Personal Access Token is required");u(!0),w(null);try{let a=await fetch("/api/oauth/gitlab/pat",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({token:r.trim(),baseUrl:l.trim()||i})}),b=await a.json();if(!a.ok)throw Error(b.error||"Authentication failed");c?.(),B()}catch(a){w(a.message)}finally{u(!1)}};return a?x&&z?(0,d.jsx)(h.LF,{isOpen:!0,provider:"gitlab",providerInfo:b,oauthMeta:z,onSuccess:()=>{c?.(),B()},onClose:()=>{y(!1),A(null)}}):(0,d.jsx)(h.aF,{isOpen:a,title:"Connect GitLab Duo",onClose:B,size:"lg",children:(0,d.jsxs)("div",{className:"flex flex-col gap-4",children:[!g&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("p",{className:"text-sm text-text-muted",children:"Choose how to authenticate with GitLab Duo:"}),(0,d.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,d.jsxs)("button",{onClick:()=>k("oauth"),className:"flex flex-col items-center gap-2 p-4 rounded-lg border border-border hover:border-primary hover:bg-primary/5 transition-colors text-left",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-2xl text-primary",children:"lock_open"}),(0,d.jsxs)("div",{children:[(0,d.jsx)("p",{className:"text-sm font-medium",children:"OAuth App"}),(0,d.jsx)("p",{className:"text-xs text-text-muted",children:"Use a GitLab OAuth application"})]})]}),(0,d.jsxs)("button",{onClick:()=>k("pat"),className:"flex flex-col items-center gap-2 p-4 rounded-lg border border-border hover:border-primary hover:bg-primary/5 transition-colors text-left",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-2xl text-primary",children:"key"}),(0,d.jsxs)("div",{children:[(0,d.jsx)("p",{className:"text-sm font-medium",children:"Personal Access Token"}),(0,d.jsx)("p",{className:"text-xs text-text-muted",children:"Use a GitLab PAT with api scope"})]})]})]})]}),"oauth"===g&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("p",{className:"text-xs text-text-muted",children:["Create an OAuth app at"," ",(0,d.jsx)("a",{href:`${l.trim()||i}/-/profile/applications`,target:"_blank",rel:"noreferrer",className:"text-primary underline",children:"GitLab Applications"})," ","with redirect URI"," ",(0,d.jsx)("code",{className:"bg-sidebar px-1 rounded text-xs",children:"http://localhost/callback"})]}),(0,d.jsx)(h.pd,{label:"GitLab Base URL",value:l,onChange:a=>m(a.target.value),placeholder:i}),(0,d.jsx)(h.pd,{label:"Client ID",value:n,onChange:a=>o(a.target.value),placeholder:"Your OAuth application client ID"}),(0,d.jsx)(h.pd,{label:"Client Secret (optional for PKCE)",value:p,onChange:a=>q(a.target.value),placeholder:"Leave empty for public PKCE app"}),v&&(0,d.jsx)("p",{className:"text-sm text-red-500",children:v}),(0,d.jsxs)("div",{className:"flex gap-2",children:[(0,d.jsx)(h.$n,{onClick:()=>{n.trim()?(w(null),A({baseUrl:l.trim()||i,clientId:n.trim(),clientSecret:p.trim()}),y(!0)):w("Client ID is required")},fullWidth:!0,disabled:!n.trim(),children:"Authorize"}),(0,d.jsx)(h.$n,{onClick:()=>{k(null),w(null)},variant:"ghost",fullWidth:!0,children:"Back"})]})]}),"pat"===g&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("p",{className:"text-xs text-text-muted",children:["Create a PAT at"," ",(0,d.jsx)("a",{href:`${l.trim()||i}/-/user_settings/personal_access_tokens`,target:"_blank",rel:"noreferrer",className:"text-primary underline",children:"GitLab Access Tokens"})," ","with scopes: ",(0,d.jsx)("code",{className:"bg-sidebar px-1 rounded text-xs",children:"api"}),","," ",(0,d.jsx)("code",{className:"bg-sidebar px-1 rounded text-xs",children:"read_user"}),", and"," ",(0,d.jsx)("code",{className:"bg-sidebar px-1 rounded text-xs",children:"ai_features"}),"."]}),(0,d.jsx)(h.pd,{label:"GitLab Base URL",value:l,onChange:a=>m(a.target.value),placeholder:i}),(0,d.jsx)(h.pd,{label:"Personal Access Token",value:r,onChange:a=>s(a.target.value),placeholder:"glpat-xxxxxxxxxxxxxxxxxxxx",type:"password"}),v&&(0,d.jsx)("p",{className:"text-sm text-red-500",children:v}),(0,d.jsxs)("div",{className:"flex gap-2",children:[(0,d.jsx)(h.$n,{onClick:C,fullWidth:!0,disabled:!r.trim()||t,loading:t,children:"Connect"}),(0,d.jsx)(h.$n,{onClick:()=>{k(null),w(null)},variant:"ghost",fullWidth:!0,children:"Back"})]})]})]})}):null}j.propTypes={isOpen:g().bool.isRequired,providerInfo:g().shape({name:g().string}),onSuccess:g().func,onClose:g().func.isRequired}},45390:(a,b,c)=>{c.d(b,{Sq:()=>n,rk:()=>o});let d="openai-compatible",e="anthropic-compatible",f="custom-image";function g(a=""){return String(a).trim().replace(/\/+$/,"")}function h(a){try{return new URL(String(a).trim())}catch{return null}}function i(a,b=d){let c=h(a);if(!c)return g(a);let j=b===e?function(a=""){let b=g(a);for(let a of["/messages","/models"])if(b.endsWith(a)){b=b.slice(0,-a.length);break}return b||""}(c.pathname):b===f?function(a=""){let b=g(a);for(let a of["/images/generations","/images/edits"])if(b.endsWith(a)){b=b.slice(0,-a.length);break}return b||""}(c.pathname):function(a=""){let b=g(a);for(let a of["/chat/completions","/responses","/models"])if(b.endsWith(a)){b=b.slice(0,-a.length);break}return b||""}(c.pathname);return`${c.origin}${j}`.replace(/\/+$/,"")}function j(a){let b=[],c="",d=null,e=!1,f=()=>{c&&(b.push(c),c="")};for(let b=0;b<a.length;b+=1){let g=a[b];if(e){c+=g,e=!1;continue}if("'"===d){"'"===g?d=null:c+=g;continue}if('"'===d||"`"===d){g===d?d=null:"\\"===g&&'"'===d?e=!0:c+=g;continue}if("\\"===g&&b+1<a.length){e=!0;continue}if("'"===g||'"'===g||"`"===g){d=g;continue}if(/\s/.test(g)){f();continue}c+=g}return f(),b}function k(a=""){let b=a.indexOf(":");if(-1===b)return null;let c=a.slice(0,b).trim(),d=a.slice(b+1).trim();return c?{key:c,value:d}:null}function l(a){if(!a)return null;try{return JSON.parse(a)}catch{return null}}function m(a="",b=d){let c=String(a).toLowerCase().replace(/^api\./,"").replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||"compatible";return b===e?`ac-${c}`:b===f?`img-${c}`:`oc-${c}`}function n(a){let b=String(a||"").trim();if(!b)throw Error("cURL command is required");let c=j(b.replace(/\\\s*\n/g," ").replace(/\r?\n/g," ").trim());if(0===c.length||"curl"!==c[0])throw Error("Please paste a valid curl command");let f="GET",n="",o="",p={};for(let a=1;a<c.length;a+=1){let b=c[a];if(("-X"===b||"--request"===b)&&c[a+1]){f=c[a+1].toUpperCase(),a+=1;continue}if(("--url"===b||"--location"===b||"--url-query"===b)&&c[a+1]){"--url"===b&&(n=c[a+1]),a+=1;continue}if(("-H"===b||"--header"===b)&&c[a+1]){let b=k(c[a+1]);b&&(p[b.key.toLowerCase()]=b.value),a+=1;continue}if(("-d"===b||"--data"===b||"--data-raw"===b||"--data-binary"===b||"--data-ascii"===b)&&c[a+1]){o=c[a+1],a+=1;continue}!n&&/^https?:\/\//i.test(b)&&(n=b)}if(!n)throw Error("Could not find request URL in curl command");o&&"GET"===f&&(f="POST");let q=l(o),r=h(n),s=g(r?.pathname||""),t=p["anthropic-version"]||s.endsWith("/messages")?e:d,u=t===d?function({url:a="",body:b=null}={}){let c=h(a),d=g(c?.pathname||"");if(d.endsWith("/responses"))return"responses";if(d.endsWith("/chat/completions"))return"chat";if(b&&"object"==typeof b){if(!Array.isArray(b.messages)&&void 0!==b.input)return"responses";Array.isArray(b.messages)}return"chat"}({url:n,body:q}):null,v=p.authorization?.match(/^Bearer\s+(.+)$/i)?.[1]||p["x-api-key"]||"",w=q?.model?String(q.model):"",x=i(n,t),y=r?.hostname||"",z=`${y||"Imported"} ${t===e?"Anthropic":"OpenAI"} Compatible`;return{method:f,url:n,headers:p,body:q,type:t,apiType:u,apiKey:v,modelId:w,baseUrl:x,defaultName:z,defaultPrefix:m(y,t),defaultConnectionName:"Imported Key"}}function o(a){let b=String(a||"").trim();if(!b)throw Error("cURL command is required");let c=j(b.replace(/\\\s*\n/g," ").replace(/\r?\n/g," ").trim());if(0===c.length||"curl"!==c[0])throw Error("Please paste a valid curl command");let d="GET",e="",n="",o={};for(let a=1;a<c.length;a+=1){let b=c[a];if(("-X"===b||"--request"===b)&&c[a+1]){d=c[a+1].toUpperCase(),a+=1;continue}if(("--url"===b||"--location"===b)&&c[a+1]){"--url"===b&&(e=c[a+1]),a+=1;continue}if(("-H"===b||"--header"===b)&&c[a+1]){let b=k(c[a+1]);b&&(o[b.key.toLowerCase()]=b.value),a+=1;continue}if(("-d"===b||"--data"===b||"--data-raw"===b||"--data-binary"===b||"--data-ascii"===b)&&c[a+1]){n=c[a+1],a+=1;continue}!e&&/^https?:\/\//i.test(b)&&(e=b)}if(!e)throw Error("Could not find request URL in curl command");n&&"GET"===d&&(d="POST");let p=l(n),q=h(e),r=q?.hostname||"",s=o.authorization?.match(/^Bearer\s+(.+)$/i)?.[1]||o["x-api-key"]||"",t=p?.model?String(p.model):"";return{method:d,url:e,headers:o,body:p,type:f,apiKey:s,modelId:t,imageSize:p?.size?String(p.size):"",baseUrl:i(e,f),apiPath:function({url:a=""}={}){let b=h(a);return g(b?.pathname||"").endsWith("/images/edits")?"/images/edits":"/images/generations"}({url:e}),defaultName:`${r||"Imported"} Image Provider`,defaultPrefix:m(r,f),defaultConnectionName:"Imported Key"}}},48781:(a,b,c)=>{c.d(b,{default:()=>k});var d=c(48249),e=c(2116),f=c.n(e),g=c(12020);let h=[{label:"Features",href:"#features"},{label:"Pricing",href:"#pricing"},{label:"Changelog",href:"#"}],i=[{label:"Documentation",href:"#"},{label:"API Reference",href:"#"},{label:"Help Center",href:"#"}],j=[{label:"About",href:"#"},{label:"Blog",href:"#"},{label:"Contact",href:"#"}];function k(){return(0,d.jsx)("footer",{className:"bg-bg border-t border-border pt-16 pb-12",children:(0,d.jsxs)("div",{className:"container mx-auto px-4 sm:px-6 lg:px-8",children:[(0,d.jsxs)("div",{className:"grid grid-cols-2 md:grid-cols-4 lg:grid-cols-5 gap-10 mb-12",children:[(0,d.jsxs)("div",{className:"col-span-2 lg:col-span-2",children:[(0,d.jsxs)("div",{className:"flex items-center gap-2 mb-6",children:[(0,d.jsx)("div",{className:"size-6 text-primary",children:(0,d.jsx)("svg",{className:"w-full h-full",fill:"currentColor",viewBox:"0 0 48 48",children:(0,d.jsx)("path",{clipRule:"evenodd",d:"M12.0799 24L4 19.2479L9.95537 8.75216L18.04 13.4961L18.0446 4H29.9554L29.96 13.4961L38.0446 8.75216L44 19.2479L35.92 24L44 28.7521L38.0446 39.2479L29.96 34.5039L29.9554 44H18.0446L18.04 34.5039L9.95537 39.2479L4 28.7521L12.0799 24Z",fillRule:"evenodd"})})}),(0,d.jsx)("span",{className:"text-xl font-bold text-text-main",children:g.vQ.name})]}),(0,d.jsx)("p",{className:"text-text-muted mb-6 max-w-sm font-light",children:"The unified interface for modern AI infrastructure. Secure, observable, and scalable."}),(0,d.jsxs)("div",{className:"flex gap-4",children:[(0,d.jsx)("a",{href:"#",className:"text-gray-400 hover:text-primary transition-colors","aria-label":"Twitter",children:(0,d.jsx)("svg",{className:"w-5 h-5",fill:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{d:"M22.46 6c-.77.35-1.6.58-2.46.69.88-.53 1.56-1.37 1.88-2.38-.83.5-1.75.85-2.72 1.05C18.37 4.5 17.26 4 16 4c-2.35 0-4.27 1.92-4.27 4.29 0 .34.04.67.11.98C8.28 9.09 5.11 7.38 3 4.79c-.37.63-.58 1.37-.58 2.15 0 1.49.75 2.81 1.91 3.56-.71 0-1.37-.2-1.95-.5v.03c0 2.08 1.48 3.82 3.44 4.21a4.22 4.22 0 0 1-1.93.07 4.28 4.28 0 0 0 4 2.98 8.521 8.521 0 0 1-5.33 1.84c-.34 0-.68-.02-1.02-.06C3.44 20.29 5.7 21 8.12 21 16 21 20.33 14.46 20.33 8.79c0-.19 0-.37-.01-.56.84-.6 1.56-1.36 2.14-2.23z"})})}),(0,d.jsx)("a",{href:"#",className:"text-gray-400 hover:text-primary transition-colors","aria-label":"GitHub",children:(0,d.jsx)("svg",{className:"w-5 h-5",fill:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{d:"M12 2C6.477 2 2 6.484 2 12.017c0 4.425 2.865 8.18 6.839 9.504.5.092.682-.217.682-.483 0-.237-.008-.868-.013-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.029-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0 1 12 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.202 2.398.1 2.651.64.7 1.028 1.595 1.028 2.688 0 3.848-2.339 4.695-4.566 4.943.359.309.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.019 10.019 0 0 0 22 12.017C22 6.484 17.522 2 12 2z"})})})]})]}),(0,d.jsxs)("div",{children:[(0,d.jsx)("h4",{className:"font-semibold text-text-main mb-4",children:"Product"}),(0,d.jsx)("ul",{className:"flex flex-col gap-3 text-sm text-text-muted font-light",children:h.map(a=>(0,d.jsx)("li",{children:(0,d.jsx)(f(),{href:a.href,className:"hover:text-primary transition-colors",children:a.label})},a.label))})]}),(0,d.jsxs)("div",{children:[(0,d.jsx)("h4",{className:"font-semibold text-text-main mb-4",children:"Resources"}),(0,d.jsx)("ul",{className:"flex flex-col gap-3 text-sm text-text-muted font-light",children:i.map(a=>(0,d.jsx)("li",{children:(0,d.jsx)(f(),{href:a.href,className:"hover:text-primary transition-colors",children:a.label})},a.label))})]}),(0,d.jsxs)("div",{children:[(0,d.jsx)("h4",{className:"font-semibold text-text-main mb-4",children:"Company"}),(0,d.jsx)("ul",{className:"flex flex-col gap-3 text-sm text-text-muted font-light",children:j.map(a=>(0,d.jsx)("li",{children:(0,d.jsx)(f(),{href:a.href,className:"hover:text-primary transition-colors",children:a.label})},a.label))})]})]}),(0,d.jsxs)("div",{className:"border-t border-border pt-8 flex flex-col md:flex-row justify-between items-center gap-4",children:[(0,d.jsxs)("p",{className:"text-sm text-text-muted",children:["\xa9 ",new Date().getFullYear()," ",g.vQ.name," Inc. All rights reserved."]}),(0,d.jsxs)("div",{className:"flex gap-6 text-sm text-text-muted",children:[(0,d.jsx)(f(),{href:"#",className:"hover:text-primary transition-colors",children:"Privacy Policy"}),(0,d.jsx)(f(),{href:"#",className:"hover:text-primary transition-colors",children:"Terms of Service"})]})]})]})})}},50377:(a,b,c)=>{c.d(b,{C:()=>e});var d=c(67484);function e(a=2e3){let[b,c]=(0,d.useState)(null),f=(0,d.useRef)(null);return{copied:b,copy:(0,d.useCallback)((b,d="default")=>{(async()=>{if(navigator?.clipboard?.writeText)await navigator.clipboard.writeText(b);else{let a=document.createElement("textarea");a.value=b,a.style.position="fixed",a.style.opacity="0",document.body.appendChild(a),a.select(),document.execCommand("copy"),document.body.removeChild(a)}})(),c(d),f.current&&clearTimeout(f.current),f.current=setTimeout(()=>{c(null)},a)},[a])}}},50412:(a,b,c)=>{c.d(b,{x0:()=>x.default,VW:()=>y.default,Ex:()=>j.default,$n:()=>d.default,Zp:()=>g.default,Qv:()=>i.CardSkeleton,CK:()=>o.default,uo:()=>h.ConfirmModal,G9:()=>t.default,wI:()=>w.default,vj:()=>v.default,vE:()=>u.default,pd:()=>e.default,Mh:()=>s.default,uR:()=>n.default,Nf:()=>p.default,aF:()=>h.default,rq:()=>m.default,gw:()=>z.default,LF:()=>l.default,Wx:()=>C.default,gM:()=>r.default,Iz:()=>A.default,l6:()=>f.default,lM:()=>k.default,m_:()=>B.default,jK:()=>q.default});var d=c(99070),e=c(83552),f=c(4770),g=c(17660),h=c(95145),i=c(74812);c(25919);var j=c(75171),k=c(95514);c(53845),c(19308),c(42196),c(86739),c(48781);var l=c(79346),m=c(83352),n=c(39645),o=c(62727),p=c(20084),q=c(28403);c(267),c(23048),c(3236),c(11229);var r=c(91809);c(86209);var s=c(5291);c(56110);var t=c(51109),u=c(79488),v=c(43182),w=c(51585),x=c(67738),y=c(31402),z=c(50585),A=c(91099),B=c(32971),C=c(11633);c(85306),c(53838)},50585:(a,b,c)=>{c.d(b,{default:()=>l});var d=c(48249),e=c(67484),f=c(49885),g=c.n(f),h=c(17660),i=c(4770),j=c(75171);let k="__none__";function l({providerId:a}){let[b,c]=(0,e.useState)([]),[f,g]=(0,e.useState)(k),[m,n]=(0,e.useState)(!1),[o,p]=(0,e.useState)(!1),q=async b=>{g(b),n(!0);try{let c=await fetch("/api/settings",{cache:"no-store"}),d=(c.ok?await c.json():{}).providerStrategies||{},e={...d[a]||{}};b===k?delete e.proxyPoolId:e.proxyPoolId=b;let f={...d};0===Object.keys(e).length?delete f[a]:f[a]=e,await fetch("/api/settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerStrategies:f})}),p(!0),setTimeout(()=>p(!1),1500)}catch(a){console.log("Save proxyPoolId error:",a)}finally{n(!1)}};return(0,d.jsxs)(h.default,{children:[(0,d.jsxs)("div",{className:"flex items-center gap-3 mb-4",children:[(0,d.jsx)("div",{className:"inline-flex items-center justify-center w-10 h-10 rounded-full bg-green-500/10 text-green-500",children:(0,d.jsx)("span",{className:"material-symbols-outlined text-[20px]",children:"lock_open"})}),(0,d.jsxs)("div",{className:"flex-1",children:[(0,d.jsx)("p",{className:"text-sm font-medium",children:"No authentication required"}),(0,d.jsx)("p",{className:"text-xs text-text-muted",children:"This provider is ready to use. Optionally route requests through a proxy pool to bypass IP-based limits."})]}),o&&(0,d.jsx)(j.default,{variant:"success",size:"sm",children:"Saved"})]}),(0,d.jsx)(i.default,{label:"Proxy Pool",value:f,onChange:a=>q(a.target.value),disabled:m,options:[{value:k,label:"None (direct)"},...b.map(a=>({value:a.id,label:a.name}))]})]})}l.propTypes={providerId:g().string.isRequired}},51109:(a,b,c)=>{c.d(b,{default:()=>i});var d=c(48249),e=c(67484),f=c(49885),g=c.n(f),h=c(50412);function i({isOpen:a,onSuccess:b,onClose:c}){let[f,g]=(0,e.useState)(""),[j,k]=(0,e.useState)(""),[l,m]=(0,e.useState)(null),[n,o]=(0,e.useState)(!1),[p,q]=(0,e.useState)(!1),[r,s]=(0,e.useState)(!1),[t,u]=(0,e.useState)(!1),v=async()=>{q(!0),m(null),s(!1),u(!1);try{let a=await fetch("/api/oauth/cursor/auto-import"),b=await a.json();b.found?(g(b.accessToken),k(b.machineId),s(!0)):b.windowsManual?u(!0):m(b.error||"Could not auto-detect tokens")}catch(a){m("Failed to auto-detect tokens")}finally{q(!1)}},w=async()=>{if(!f.trim())return void m("Please enter an access token");if(!j.trim())return void m("Please enter a machine ID");o(!0),m(null);try{let a=await fetch("/api/oauth/cursor/import",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({accessToken:f.trim(),machineId:j.trim()})}),d=await a.json();if(!a.ok)throw Error(d.error||"Import failed");b?.(),c()}catch(a){m(a.message)}finally{o(!1)}};return(0,d.jsx)(h.aF,{isOpen:a,title:"Connect Cursor IDE",onClose:c,children:(0,d.jsxs)("div",{className:"flex flex-col gap-4",children:[p&&(0,d.jsxs)("div",{className:"text-center py-6",children:[(0,d.jsx)("div",{className:"size-16 mx-auto mb-4 rounded-full bg-primary/10 flex items-center justify-center",children:(0,d.jsx)("span",{className:"material-symbols-outlined text-3xl text-primary animate-spin",children:"progress_activity"})}),(0,d.jsx)("h3",{className:"text-lg font-semibold mb-2",children:"Auto-detecting tokens..."}),(0,d.jsx)("p",{className:"text-sm text-text-muted",children:"Reading from Cursor IDE database"})]}),!p&&(0,d.jsxs)(d.Fragment,{children:[r&&(0,d.jsx)("div",{className:"bg-green-50 dark:bg-green-900/20 p-3 rounded-lg border border-green-200 dark:border-green-800",children:(0,d.jsxs)("div",{className:"flex gap-2",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-green-600 dark:text-green-400",children:"check_circle"}),(0,d.jsx)("p",{className:"text-sm text-green-800 dark:text-green-200",children:"Tokens auto-detected from Cursor IDE successfully!"})]})}),t&&(0,d.jsxs)("div",{className:"bg-amber-50 dark:bg-amber-900/20 p-3 rounded-lg border border-amber-200 dark:border-amber-800 flex flex-col gap-2",children:[(0,d.jsxs)("div",{className:"flex gap-2 items-center",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-amber-600 dark:text-amber-400",children:"info"}),(0,d.jsx)("p",{className:"text-sm font-medium text-amber-800 dark:text-amber-200",children:"Could not read Cursor database automatically."})]}),(0,d.jsxs)("p",{className:"text-xs text-amber-700 dark:text-amber-300",children:["Make sure Cursor IDE has been opened at least once, then click ",(0,d.jsx)("strong",{children:"Retry"}),". If the problem persists, paste your tokens manually below."]}),(0,d.jsx)(h.$n,{onClick:v,variant:"outline",fullWidth:!0,children:"Retry"})]}),!r&&!t&&!l&&(0,d.jsx)("div",{className:"bg-blue-50 dark:bg-blue-900/20 p-3 rounded-lg border border-blue-200 dark:border-blue-800",children:(0,d.jsxs)("div",{className:"flex gap-2",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-blue-600 dark:text-blue-400",children:"info"}),(0,d.jsx)("p",{className:"text-sm text-blue-800 dark:text-blue-200",children:"Cursor IDE not detected. Please paste your tokens manually."})]})}),(0,d.jsxs)("div",{children:[(0,d.jsxs)("label",{className:"block text-sm font-medium mb-2",children:["Access Token ",(0,d.jsx)("span",{className:"text-red-500",children:"*"})]}),(0,d.jsx)("textarea",{value:f,onChange:a=>g(a.target.value),placeholder:"Access token will be auto-filled...",rows:3,className:"w-full px-3 py-2 text-sm font-mono border border-border rounded-lg bg-background focus:outline-none focus:border-primary resize-none"})]}),(0,d.jsxs)("div",{children:[(0,d.jsxs)("label",{className:"block text-sm font-medium mb-2",children:["Machine ID ",(0,d.jsx)("span",{className:"text-red-500",children:"*"})]}),(0,d.jsx)(h.pd,{value:j,onChange:a=>k(a.target.value),placeholder:"Machine ID will be auto-filled...",className:"font-mono text-sm"})]}),l&&(0,d.jsx)("div",{className:"bg-red-50 dark:bg-red-900/20 p-3 rounded-lg border border-red-200 dark:border-red-800",children:(0,d.jsx)("p",{className:"text-sm text-red-600 dark:text-red-400",children:l})}),(0,d.jsxs)("div",{className:"flex gap-2",children:[(0,d.jsx)(h.$n,{onClick:w,fullWidth:!0,disabled:n||!f.trim()||!j.trim(),children:n?"Importing...":"Import Token"}),(0,d.jsx)(h.$n,{onClick:c,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})]})})}i.propTypes={isOpen:g().bool.isRequired,onSuccess:g().func,onClose:g().func.isRequired}},51585:(a,b,c)=>{c.d(b,{default:()=>m});var d=c(48249),e=c(67484),f=c(49885),g=c.n(f),h=c(95145),i=c(83552),j=c(99070),k=c(75171),l=c(96919);function m({isOpen:a,connection:b,proxyPools:c,onSave:f,onClose:g}){let[n,o]=(0,e.useState)({name:"",priority:1,apiKey:""}),[p,q]=(0,e.useState)({azureEndpoint:"",apiVersion:"2024-10-01-preview",deployment:"",organization:""}),[r,s]=(0,e.useState)({accountId:""}),[t,u]=(0,e.useState)(!1),[v,w]=(0,e.useState)(null),[x,y]=(0,e.useState)(!1),[z,A]=(0,e.useState)(null),[B,C]=(0,e.useState)(!1),D=b?.authType==="oauth",E=b?.provider==="azure",F=b?.provider==="cloudflare-ai",G=!!b&&((0,l.mq)(b.provider)||(0,l.gb)(b.provider)),H=async()=>{if(b?.provider){u(!0),w(null);try{let a=await fetch(`/api/providers/${b.id}/test`,{method:"POST"}),c=await a.json();w(c.valid?"success":"failed")}catch{w("failed")}finally{u(!1)}}},I=async()=>{if(b?.provider&&n.apiKey){y(!0),A(null);try{let a=await fetch("/api/providers/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:b.provider,apiKey:n.apiKey,...E?{providerSpecificData:p}:{},...F?{providerSpecificData:r}:{}})}),c=await a.json();A(c.valid?"success":"failed")}catch{A("failed")}finally{y(!1)}}},J=async()=>{if(b){C(!0);try{let a={name:n.name,priority:n.priority};if(!D&&n.apiKey){a.apiKey=n.apiKey;let c="success"===z;if(!c)try{y(!0),A(null);let a=await fetch("/api/providers/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:b.provider,apiKey:n.apiKey,...E?{providerSpecificData:p}:{},...F?{providerSpecificData:r}:{}})});c=!!(await a.json()).valid,A(c?"success":"failed")}catch{A("failed")}finally{y(!1)}c&&(a.testStatus="active",a.lastError=null,a.lastErrorAt=null)}E&&(a.providerSpecificData={azureEndpoint:p.azureEndpoint,apiVersion:p.apiVersion,deployment:p.deployment,organization:p.organization}),F&&(a.providerSpecificData={accountId:r.accountId}),await f(a)}finally{C(!1)}}};return b?(0,d.jsx)(h.default,{isOpen:a,title:"Edit Connection",onClose:g,children:(0,d.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,d.jsx)(i.default,{label:"Name",value:n.name,onChange:a=>o({...n,name:a.target.value}),placeholder:D?"Account name":"Production Key"}),D&&b.email&&(0,d.jsxs)("div",{className:"bg-sidebar/50 p-3 rounded-lg",children:[(0,d.jsx)("p",{className:"text-sm text-text-muted mb-1",children:"Email"}),(0,d.jsx)("p",{className:"font-medium",children:b.email})]}),(0,d.jsx)(i.default,{label:"Priority",type:"number",value:n.priority,onChange:a=>o({...n,priority:Number.parseInt(a.target.value,10)||1})}),!D&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("div",{className:"flex gap-2",children:[(0,d.jsx)(i.default,{label:"API Key",type:"password",value:n.apiKey,onChange:a=>o({...n,apiKey:a.target.value}),placeholder:"Enter new API key",hint:"Leave blank to keep the current API key.",className:"flex-1"}),(0,d.jsx)("div",{className:"pt-6",children:(0,d.jsx)(j.default,{onClick:I,disabled:!n.apiKey||x||B,variant:"secondary",children:x?"Checking...":"Check"})})]}),z&&(0,d.jsx)(k.default,{variant:"success"===z?"success":"error",children:"success"===z?"Valid":"Invalid"})]}),E&&(0,d.jsxs)("div",{className:"bg-sidebar/50 p-4 rounded-lg border border-accent/20",children:[(0,d.jsx)("h3",{className:"font-semibold mb-3 text-sm",children:"Azure OpenAI Configuration"}),(0,d.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,d.jsx)(i.default,{label:"Azure Endpoint",value:p.azureEndpoint,onChange:a=>q({...p,azureEndpoint:a.target.value}),placeholder:"https://your-resource.openai.azure.com",hint:"Your Azure OpenAI resource endpoint URL"}),(0,d.jsx)(i.default,{label:"Deployment Name",value:p.deployment,onChange:a=>q({...p,deployment:a.target.value}),placeholder:"gpt-4",hint:"The deployment name in your Azure resource"}),(0,d.jsx)(i.default,{label:"API Version",value:p.apiVersion,onChange:a=>q({...p,apiVersion:a.target.value}),placeholder:"2024-10-01-preview",hint:"Azure OpenAI API version to use"}),(0,d.jsx)(i.default,{label:"Organization",value:p.organization,onChange:a=>q({...p,organization:a.target.value}),placeholder:"Organization ID",hint:"Required for billing"})]})]}),!G&&!E&&!F&&(0,d.jsxs)("div",{className:"flex items-center gap-3",children:[(0,d.jsx)(j.default,{onClick:H,variant:"secondary",disabled:t,children:t?"Testing...":"Test Connection"}),v&&(0,d.jsx)(k.default,{variant:"success"===v?"success":"error",children:"success"===v?"Valid":"Failed"})]}),(0,d.jsxs)("div",{className:"flex gap-2",children:[(0,d.jsx)(j.default,{onClick:J,fullWidth:!0,disabled:B,children:B?"Saving...":"Save"}),(0,d.jsx)(j.default,{onClick:g,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})}):null}m.propTypes={isOpen:g().bool.isRequired,connection:g().shape({id:g().string,name:g().string,email:g().string,priority:g().number,authType:g().string,provider:g().string,providerSpecificData:g().object}),proxyPools:g().arrayOf(g().shape({id:g().string,name:g().string})),onSave:g().func.isRequired,onClose:g().func.isRequired}},53838:(a,b,c)=>{c.d(b,{default:()=>h});var d=c(48249),e=c(49885),f=c.n(e),g=c(53845);function h({children:a}){return(0,d.jsxs)("div",{className:"min-h-screen flex flex-col relative bg-bg transition-colors duration-500 overflow-x-hidden selection:bg-primary/20 selection:text-primary",children:[(0,d.jsx)("div",{className:"fixed top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-[800px] h-[800px] bg-primary/5 dark:bg-primary/5 rounded-full blur-[100px] pointer-events-none z-0"}),(0,d.jsx)("div",{className:"fixed bottom-0 right-0 w-[600px] h-[600px] bg-orange-200/20 dark:bg-orange-900/10 rounded-full blur-[120px] pointer-events-none z-0 translate-y-1/3 translate-x-1/3"}),(0,d.jsx)("div",{className:"absolute top-6 right-6 z-20",children:(0,d.jsx)(g.default,{variant:"card"})}),(0,d.jsx)("main",{className:"flex-1 flex flex-col items-center justify-center p-4 sm:p-6 z-10 w-full h-full",children:a})]})}h.propTypes={children:f().node.isRequired}},53845:(a,b,c)=>{c.d(b,{default:()=>g});var d=c(48249),e=c(42118),f=c(71404);function g({className:a,variant:b="default"}){let{isDark:c,toggleTheme:h}=(0,e.D)(),i={default:(0,f.cn)("flex items-center justify-center size-10 rounded-full","text-text-muted hover:text-text-main","hover:bg-surface-2 transition-colors"),card:(0,f.cn)("flex items-center justify-center size-11 rounded-full","bg-surface/60 hover:bg-surface","border border-border","backdrop-blur-md shadow-sm hover:shadow-[var(--shadow-warm)]","text-text-muted hover:text-brand-500","transition-all group")};return(0,d.jsx)("button",{onClick:h,className:(0,f.cn)(i[b],a),"aria-label":`Switch to ${c?"light":"dark"} mode`,title:`Switch to ${c?"light":"dark"} mode`,children:(0,d.jsx)("span",{className:(0,f.cn)("material-symbols-outlined text-[22px]","card"===b&&"transition-transform duration-300 group-hover:rotate-12"),children:c?"light_mode":"dark_mode"})})}},56110:(a,b,c)=>{c.d(b,{default:()=>j});var d=c(48249),e=c(67484),f=c(49885),g=c.n(f),h=c(50412),i=c(50377);function j({isOpen:a,provider:b,onSuccess:c,onClose:f}){let[g,k]=(0,e.useState)("loading"),[l,m]=(0,e.useState)(""),[n,o]=(0,e.useState)(null),[p,q]=(0,e.useState)(""),[r,s]=(0,e.useState)(null),{copied:t,copy:u}=(0,i.C)(),v=async()=>{try{let a;s(null);try{a=new URL(p)}catch(a){throw Error("Invalid callback URL format")}let d=a.searchParams.get("code");a.searchParams.get("state");let e=a.searchParams.get("error");if(e)throw Error(a.searchParams.get("error_description")||e);if(!d)throw Error("No authorization code found in URL");let f=await fetch("/api/oauth/kiro/social-exchange",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({code:d,codeVerifier:n.codeVerifier,provider:b})}),g=await f.json();if(!f.ok)throw Error(g.error);k("success"),c?.()}catch(a){s(a.message),k("error")}},w="google"===b?"Google":"GitHub";return(0,d.jsx)(h.aF,{isOpen:a,title:`Connect Kiro via ${w}`,onClose:f,size:"lg",children:(0,d.jsxs)("div",{className:"flex flex-col gap-4",children:["loading"===g&&(0,d.jsxs)("div",{className:"text-center py-6",children:[(0,d.jsx)("div",{className:"size-16 mx-auto mb-4 rounded-full bg-primary/10 flex items-center justify-center",children:(0,d.jsx)("span",{className:"material-symbols-outlined text-3xl text-primary animate-spin",children:"progress_activity"})}),(0,d.jsx)("h3",{className:"text-lg font-semibold mb-2",children:"Initializing..."}),(0,d.jsxs)("p",{className:"text-sm text-text-muted",children:["Setting up ",w," authentication"]})]}),"input"===g&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("div",{className:"space-y-4",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("p",{className:"text-sm font-medium mb-2",children:"Step 1: Open this URL in your browser"}),(0,d.jsxs)("div",{className:"flex gap-2",children:[(0,d.jsx)(h.pd,{value:l,readOnly:!0,className:"flex-1 font-mono text-xs"}),(0,d.jsx)(h.$n,{variant:"secondary",icon:"auth_url"===t?"check":"content_copy",onClick:()=>u(l,"auth_url"),children:"Copy"})]})]}),(0,d.jsxs)("div",{children:[(0,d.jsx)("p",{className:"text-sm font-medium mb-2",children:"Step 2: Paste the callback URL here"}),(0,d.jsx)("p",{className:"text-xs text-text-muted mb-2",children:"After authorization, copy the full URL from your browser address bar."}),(0,d.jsx)(h.pd,{value:p,onChange:a=>q(a.target.value),placeholder:"kiro://kiro.kiroAgent/authenticate-success?code=...",className:"font-mono text-xs"})]})]}),(0,d.jsxs)("div",{className:"flex gap-2",children:[(0,d.jsx)(h.$n,{onClick:v,fullWidth:!0,disabled:!p,children:"Connect"}),(0,d.jsx)(h.$n,{onClick:f,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]}),"success"===g&&(0,d.jsxs)("div",{className:"text-center py-6",children:[(0,d.jsx)("div",{className:"size-16 mx-auto mb-4 rounded-full bg-green-100 dark:bg-green-900/30 flex items-center justify-center",children:(0,d.jsx)("span",{className:"material-symbols-outlined text-3xl text-green-600",children:"check_circle"})}),(0,d.jsx)("h3",{className:"text-lg font-semibold mb-2",children:"Connected Successfully!"}),(0,d.jsxs)("p",{className:"text-sm text-text-muted mb-4",children:["Your Kiro account via ",w," has been connected."]}),(0,d.jsx)(h.$n,{onClick:f,fullWidth:!0,children:"Done"})]}),"error"===g&&(0,d.jsxs)("div",{className:"text-center py-6",children:[(0,d.jsx)("div",{className:"size-16 mx-auto mb-4 rounded-full bg-red-100 dark:bg-red-900/30 flex items-center justify-center",children:(0,d.jsx)("span",{className:"material-symbols-outlined text-3xl text-red-600",children:"error"})}),(0,d.jsx)("h3",{className:"text-lg font-semibold mb-2",children:"Connection Failed"}),(0,d.jsx)("p",{className:"text-sm text-red-600 mb-4",children:r}),(0,d.jsxs)("div",{className:"flex gap-2",children:[(0,d.jsx)(h.$n,{onClick:()=>k("input"),variant:"secondary",fullWidth:!0,children:"Try Again"}),(0,d.jsx)(h.$n,{onClick:f,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})]})})}j.propTypes={isOpen:g().bool.isRequired,provider:g().oneOf(["google","github"]).isRequired,onSuccess:g().func,onClose:g().func.isRequired}},62727:(a,b,c)=>{c.d(b,{default:()=>l});var d=c(48249),e=c(67484),f=c(95145),g=c(83552),h=c(99070),i=c(83352);let j=/^[a-zA-Z0-9_.\-]+$/;function k({index:a,model:b,isFirst:c,isLast:f,onEdit:g,onMoveUp:h,onMoveDown:i,onRemove:j}){let[l,m]=(0,e.useState)(!1),[n,o]=(0,e.useState)(b),p=()=>{let a=n.trim();a&&a!==b?g(a):o(b),m(!1)};return(0,d.jsxs)("div",{className:"group flex min-w-0 items-center gap-1.5 rounded-md bg-black/[0.02] px-2 py-1 transition-colors hover:bg-black/[0.04] dark:bg-white/[0.02] dark:hover:bg-white/[0.04]",children:[(0,d.jsx)("span",{className:"text-[10px] font-medium text-text-muted w-3 text-center shrink-0",children:a+1}),l?(0,d.jsx)("input",{autoFocus:!0,value:n,onChange:a=>o(a.target.value),onBlur:p,onKeyDown:a=>{"Enter"===a.key&&p(),"Escape"===a.key&&(o(b),m(!1))},className:"min-w-0 flex-1 rounded border border-primary/40 bg-white px-1.5 py-0.5 font-mono text-xs text-text-main outline-none dark:bg-black/20"}):(0,d.jsx)("div",{className:"min-w-0 flex-1 cursor-text truncate rounded px-1.5 py-0.5 font-mono text-xs text-text-main hover:bg-black/5 dark:hover:bg-white/5",onClick:()=>m(!0),title:"Click to edit",children:b}),(0,d.jsxs)("div",{className:"flex shrink-0 items-center gap-0.5",children:[(0,d.jsx)("button",{onClick:h,disabled:c,className:`p-0.5 rounded ${c?"text-text-muted/20 cursor-not-allowed":"text-text-muted hover:text-primary hover:bg-black/5 dark:hover:bg-white/5"}`,title:"Move up",children:(0,d.jsx)("span",{className:"material-symbols-outlined text-[12px]",children:"arrow_upward"})}),(0,d.jsx)("button",{onClick:i,disabled:f,className:`p-0.5 rounded ${f?"text-text-muted/20 cursor-not-allowed":"text-text-muted hover:text-primary hover:bg-black/5 dark:hover:bg-white/5"}`,title:"Move down",children:(0,d.jsx)("span",{className:"material-symbols-outlined text-[12px]",children:"arrow_downward"})})]}),(0,d.jsx)("button",{onClick:j,className:"p-0.5 hover:bg-red-500/10 rounded text-text-muted hover:text-red-500 transition-all",title:"Remove",children:(0,d.jsx)("span",{className:"material-symbols-outlined text-[12px]",children:"close"})})]})}function l({isOpen:a,combo:b,onClose:c,onSave:m,activeProviders:n,kindFilter:o=null,forcePrefix:p="",title:q}){let r=b?.name?p&&b.name.startsWith(p)?b.name.slice(p.length):b.name:"",[s,t]=(0,e.useState)(r),[u,v]=(0,e.useState)(b?.models||[]),[w,x]=(0,e.useState)(!1),[y,z]=(0,e.useState)(!1),[A,B]=(0,e.useState)(""),[C,D]=(0,e.useState)({}),E=a=>{if(!a.trim())return B("Name is required"),!1;let b=p+a;return j.test(b)?(B(""),!0):(B("Only letters, numbers, -, _ and . allowed"),!1)},F=a=>{let b=a.target.value;p&&b.startsWith(p)&&(b=b.slice(p.length)),t(b),b?E(b):B("")},G=async()=>{E(s)&&(z(!0),await m({name:p+s.trim(),models:u}),z(!1))},H=!!b;return(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(f.default,{isOpen:a,onClose:c,title:q||(H?"Edit Combo":"Create Combo"),children:(0,d.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,d.jsxs)("div",{children:[p?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("label",{className:"text-sm font-medium mb-1 block",children:"Combo Name"}),(0,d.jsxs)("div",{className:"flex items-stretch",children:[(0,d.jsx)("span",{className:"inline-flex items-center px-2 rounded-l border border-r-0 border-black/10 dark:border-white/10 bg-black/[0.04] dark:bg-white/[0.04] text-text-muted font-mono text-sm",children:p}),(0,d.jsx)("input",{value:s,onChange:F,placeholder:"my-combo",className:"flex-1 min-w-0 rounded-r border border-black/10 dark:border-white/10 bg-white dark:bg-black/20 px-2 py-1.5 font-mono text-sm outline-none focus:border-primary"})]}),A&&(0,d.jsx)("p",{className:"text-[11px] text-red-500 mt-0.5",children:A})]}):(0,d.jsx)(g.default,{label:"Combo Name",value:s,onChange:F,placeholder:"my-combo",error:A}),(0,d.jsxs)("p",{className:"text-[10px] text-text-muted mt-0.5",children:[p?`Auto-prefixed with "${p}". `:"","Only letters, numbers, -, _ and . allowed"]})]}),(0,d.jsxs)("div",{children:[(0,d.jsx)("label",{className:"text-sm font-medium mb-1.5 block",children:"Models"}),0===u.length?(0,d.jsxs)("div",{className:"text-center py-4 border border-dashed border-black/10 dark:border-white/10 rounded-lg bg-black/[0.01] dark:bg-white/[0.01]",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-text-muted text-xl mb-1",children:"layers"}),(0,d.jsx)("p",{className:"text-xs text-text-muted",children:"No models added yet"})]}):(0,d.jsx)("div",{className:"flex max-h-[55vh] min-w-0 flex-col gap-1 overflow-y-auto sm:max-h-[350px]",children:u.map((a,b)=>(0,d.jsx)(k,{index:b,model:a,isFirst:0===b,isLast:b===u.length-1,onEdit:a=>{let c=[...u];c[b]=a,v(c)},onMoveUp:()=>(a=>{if(0===a)return;let b=[...u];[b[a-1],b[a]]=[b[a],b[a-1]],v(b)})(b),onMoveDown:()=>(a=>{if(a===u.length-1)return;let b=[...u];[b[a],b[a+1]]=[b[a+1],b[a]],v(b)})(b),onRemove:()=>v(u.filter((a,c)=>c!==b))},b))}),(0,d.jsxs)("button",{onClick:()=>x(!0),className:"w-full mt-2 py-2 border border-dashed border-black/10 dark:border-white/10 rounded-lg text-xs text-primary font-medium hover:text-primary hover:border-primary/50 transition-colors flex items-center justify-center gap-1",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"add"}),"Add Model"]})]}),(0,d.jsxs)("div",{className:"flex flex-col gap-2 pt-1 sm:flex-row",children:[(0,d.jsx)(h.default,{onClick:c,variant:"ghost",fullWidth:!0,size:"sm",children:"Cancel"}),(0,d.jsx)(h.default,{onClick:G,fullWidth:!0,size:"sm",disabled:!s.trim()||!!A||y,children:y?"Saving...":H?"Save":"Create"})]})]})}),(0,d.jsx)(i.default,{isOpen:w,onClose:()=>x(!1),onSelect:a=>{u.includes(a.value)||v([...u,a.value])},onDeselect:a=>{v(u.filter(b=>b!==a.value))},activeProviders:n,modelAliases:C,title:"Add Model to Combo",kindFilter:o,addedModelValues:u,closeOnSelect:!1})]})}},66828:(a,b,c)=>{c.d(b,{z:()=>d});let d=["1664x2496","2496x1664","1760x2368","2368x1760","1824x2272","2272x1824","2048x2048","2752x1536","1536x2752","3072x1376","1344x3136"]},67738:(a,b,c)=>{c.d(b,{default:()=>i});var d=c(48249),e=c(67484),f=c(49885),g=c.n(f),h=c(50412);function i({isOpen:a,onClose:b,onCreated:c,onSaved:f,node:g}){let j=!!g,[k,l]=(0,e.useState)({name:"",prefix:"",baseUrl:"https://api.openai.com/v1"}),[m,n]=(0,e.useState)(!1),[o,p]=(0,e.useState)(""),[q,r]=(0,e.useState)(""),[s,t]=(0,e.useState)(!1),[u,v]=(0,e.useState)(null),w=async()=>{if(k.name.trim()&&k.prefix.trim()&&k.baseUrl.trim()){n(!0);try{let a=j?`/api/provider-nodes/${g.id}`:"/api/provider-nodes",b={name:k.name,prefix:k.prefix,baseUrl:k.baseUrl};j||(b.type="custom-embedding");let d=await fetch(a,{method:j?"PUT":"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(b)}),e=await d.json();d.ok&&(j?f?.(e.node):c?.(e.node))}catch(a){console.log("Error saving custom embedding node:",a)}finally{n(!1)}}},x=async()=>{t(!0);try{let a=await fetch("/api/provider-nodes/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({baseUrl:k.baseUrl,apiKey:o,type:"custom-embedding",modelId:q.trim()||void 0})}),b=await a.json();v(b)}catch{v({valid:!1,error:"Network error"})}finally{t(!1)}};return(0,d.jsx)(h.aF,{isOpen:a,title:j?"Edit Custom Embedding":"Add Custom Embedding",onClose:b,children:(0,d.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,d.jsx)(h.pd,{label:"Name",value:k.name,onChange:a=>l({...k,name:a.target.value}),placeholder:"Voyage AI",hint:"Required. A friendly label for this embedding provider."}),(0,d.jsx)(h.pd,{label:"Prefix",value:k.prefix,onChange:a=>l({...k,prefix:a.target.value}),placeholder:"voyage",hint:"Required. Used as the provider prefix for model IDs (e.g. voyage/voyage-3)."}),(0,d.jsx)(h.pd,{label:"Base URL",value:k.baseUrl,onChange:a=>l({...k,baseUrl:a.target.value}),placeholder:"https://api.voyageai.com/v1",hint:"Most embedding APIs are OpenAI-compatible: Voyage, Cohere, Jina, Mistral, Together..."}),(0,d.jsx)(h.pd,{label:"API Key (for Check)",type:"password",value:o,onChange:a=>p(a.target.value)}),(0,d.jsx)(h.pd,{label:"Model ID (for Check)",value:q,onChange:a=>r(a.target.value),placeholder:"e.g. voyage-3, embed-english-v3.0, text-embedding-3-small",hint:"Required for validation. Will send a test embeddings request."}),(0,d.jsxs)("div",{className:"flex items-center gap-3",children:[(0,d.jsx)(h.$n,{onClick:x,disabled:!o||!q.trim()||s||!k.baseUrl.trim(),variant:"secondary",children:s?"Checking...":"Check"}),(()=>{if(!u)return null;let{valid:a,error:b,dimensions:c}=u;return a?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(h.Ex,{variant:"success",children:"Valid"}),c&&(0,d.jsxs)("span",{className:"text-sm text-text-muted",children:[c," dims"]})]}):(0,d.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,d.jsx)(h.Ex,{variant:"error",children:"Invalid"}),b&&(0,d.jsx)("span",{className:"text-sm text-red-500",children:b})]})})()]}),(0,d.jsxs)("div",{className:"flex gap-2",children:[(0,d.jsx)(h.$n,{onClick:w,fullWidth:!0,disabled:!k.name.trim()||!k.prefix.trim()||!k.baseUrl.trim()||m,children:m?j?"Saving...":"Creating...":j?"Save":"Create"}),(0,d.jsx)(h.$n,{onClick:b,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})})}i.propTypes={isOpen:g().bool.isRequired,onClose:g().func.isRequired,onCreated:g().func,onSaved:g().func,node:g().shape({id:g().string,name:g().string,prefix:g().string,baseUrl:g().string})}},71404:(a,b,c)=>{c.d(b,{cn:()=>d});function d(...a){return a.filter(Boolean).join(" ").replace(/\s+/g," ").trim()}},72738:(a,b,c)=>{c.d(b,{A:()=>h});var d=c(48249),e=c(67484),f=c(49885),g=c.n(f);function h({src:a,alt:b,size:c=32,className:f="",fallbackText:g="?",fallbackColor:i}){let[j,k]=(0,e.useState)(!1);return!a||j?(0,d.jsx)("span",{className:`inline-flex items-center justify-center font-bold rounded-lg ${f}`.trim(),style:{width:c,height:c,color:i,fontSize:Math.max(10,Math.floor(.38*c))},children:g}):(0,d.jsx)("img",{src:a,alt:b,width:c,height:c,className:f,onError:()=>k(!0)})}h.propTypes={src:g().string,alt:g().string,size:g().number,className:g().string,fallbackText:g().string,fallbackColor:g().string}},74812:(a,b,c)=>{c.d(b,{CardSkeleton:()=>i,PageLoading:()=>g,Skeleton:()=>h,Spinner:()=>f,default:()=>j});var d=c(48249),e=c(71404);function f({size:a="md",className:b}){return(0,d.jsx)("span",{className:(0,e.cn)("material-symbols-outlined animate-spin text-brand-500",{sm:"size-4",md:"size-6",lg:"size-8",xl:"size-12"}[a],b),children:"progress_activity"})}function g({message:a="Loading..."}){return(0,d.jsxs)("div",{className:"fixed inset-0 z-50 flex flex-col items-center justify-center bg-bg",children:[(0,d.jsx)(f,{size:"xl"}),(0,d.jsx)("p",{className:"mt-4 text-text-muted",children:a})]})}function h({className:a,...b}){return(0,d.jsx)("div",{className:(0,e.cn)("animate-pulse rounded-[10px] bg-surface-2",a),...b})}function i(){return(0,d.jsxs)("div",{className:"p-6 rounded-[14px] border border-border-subtle bg-surface shadow-[var(--shadow-soft)]",children:[(0,d.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,d.jsx)(h,{className:"h-4 w-24"}),(0,d.jsx)(h,{className:"size-10 rounded-[10px]"})]}),(0,d.jsx)(h,{className:"h-8 w-16 mb-2"}),(0,d.jsx)(h,{className:"h-3 w-20"})]})}function j({type:a="spinner",...b}){switch(a){case"page":return(0,d.jsx)(g,{...b});case"skeleton":return(0,d.jsx)(h,{...b});case"card":return(0,d.jsx)(i,{...b});default:return(0,d.jsx)(f,{...b})}}},75171:(a,b,c)=>{c.d(b,{default:()=>h});var d=c(48249),e=c(71404);let f={default:"bg-surface-2 text-text-muted",primary:"bg-brand-500/10 text-brand-600 dark:text-brand-300",success:"bg-green-500/10 text-green-600 dark:text-green-400",warning:"bg-yellow-500/10 text-yellow-600 dark:text-yellow-400",error:"bg-red-500/10 text-red-600 dark:text-red-400",info:"bg-blue-500/10 text-blue-600 dark:text-blue-400"},g={sm:"px-2 py-0.5 text-[10px]",md:"px-2.5 py-1 text-xs",lg:"px-3 py-1.5 text-sm"};function h({children:a,variant:b="default",size:c="md",dot:i=!1,icon:j,className:k}){return(0,d.jsxs)("span",{className:(0,e.cn)("inline-flex items-center gap-1.5 rounded-full font-semibold",f[b],g[c],k),children:[i&&(0,d.jsx)("span",{className:(0,e.cn)("size-1.5 rounded-full","success"===b&&"bg-green-500","warning"===b&&"bg-yellow-500","error"===b&&"bg-red-500","info"===b&&"bg-blue-500","primary"===b&&"bg-brand-500","default"===b&&"bg-gray-500")}),j&&(0,d.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:j}),a]})}},79346:(a,b,c)=>{c.d(b,{default:()=>j});var d=c(48249),e=c(67484),f=c(49885),g=c.n(f),h=c(50412),i=c(50377);function j({isOpen:a,provider:b,providerInfo:c,onSuccess:f,onClose:g,oauthMeta:k,idcConfig:l}){let[m,n]=(0,e.useState)("waiting"),[o,p]=(0,e.useState)(null),[q,r]=(0,e.useState)(""),[s,t]=(0,e.useState)(""),[u,v]=(0,e.useState)(null),[w,x]=(0,e.useState)(!1),[y,z]=(0,e.useState)(null),[A,B]=(0,e.useState)(!1),C=(0,e.useRef)(null),D=(0,e.useRef)(!1),{copied:E,copy:F}=(0,i.C)(),[G,H]=(0,e.useState)(!1),[I,J]=(0,e.useState)("/callback?code=...");(0,e.useRef)(!1);let K=(0,e.useCallback)(async(a,c)=>{if(o)try{let d=await fetch(`/api/oauth/${b}/exchange`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({code:a,redirectUri:o.redirectUri,codeVerifier:o.codeVerifier,state:c,...k?{meta:k}:{}})}),e=await d.json();if(!d.ok)throw Error(e.error);n("success"),f?.()}catch(a){v(a.message),n("error")}},[o,b,f]),L=(0,e.useCallback)(async(a,c,d,e)=>{D.current=!1,B(!0);for(let g=0;g<60;g++){if(D.current){console.log("[OAuthModal] Polling aborted"),B(!1);return}if(await new Promise(a=>setTimeout(a,1e3*d)),D.current){console.log("[OAuthModal] Polling aborted after sleep"),B(!1);return}try{let g=await fetch(`/api/oauth/${b}/poll`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({deviceCode:a,codeVerifier:c,extraData:e})}),h=await g.json();if(h.success){D.current=!0,n("success"),B(!1),f?.();return}if("expired_token"===h.error||"access_denied"===h.error)throw Error(h.errorDescription||h.error);"slow_down"===h.error&&(d=Math.min(d+5,30))}catch(a){v(a.message),n("error"),B(!1);return}}v("Authorization timeout"),n("error"),B(!1)},[b,f]),M=(0,e.useCallback)(async()=>{if(b)try{let a;if(v(null),["github","qwen","kiro","kimi-coding","kilocode","codebuddy"].includes(b)){x(!0),n("waiting");let a=new URL(`/api/oauth/${b}/device-code`,window.location.origin);"kiro"===b&&l?.startUrl&&(a.searchParams.set("start_url",l.startUrl),l.region&&a.searchParams.set("region",l.region),a.searchParams.set("auth_method","idc"));let c=await fetch(a.toString()),d=await c.json();if(!c.ok)throw Error(d.error);z(d);let e=d.verification_uri_complete||d.verification_uri;e&&window.open(e,"_blank","noopener,noreferrer");let f="kiro"===b?{_clientId:d._clientId,_clientSecret:d._clientSecret,_region:d._region,_authMethod:d._authMethod,_startUrl:d._startUrl}:null;L(d.device_code,d.codeVerifier,d.interval||5,f);return}let c=window.location.port||("https:"===window.location.protocol?"443":"80");a="codex"===b?"http://localhost:1455/auth/callback":`http://localhost:${c}/callback`;let d=new URL(`/api/oauth/${b}/authorize`,window.location.origin);d.searchParams.set("redirect_uri",a),k&&Object.entries(k).forEach(([a,b])=>{b&&d.searchParams.set(a,b)});let e=await fetch(d.toString()),f=await e.json();if(!e.ok)throw Error(f.error);let g=!1,h=!1;if("codex"===b)try{let b=new URL("/api/oauth/codex/start-proxy",window.location.origin);b.searchParams.set("app_port",c),b.searchParams.set("state",f.state),b.searchParams.set("code_verifier",f.codeVerifier),b.searchParams.set("redirect_uri",a);let d=await fetch(b.toString()),e=await d.json();g=e.success,h=!!e.serverSide}catch{g=!1}p({...f,redirectUri:a,codexServerSide:h}),"codex"===b&&g||G&&"codex"!==b?(n("waiting"),C.current=window.open(f.authUrl,"oauth_popup","width=600,height=700"),C.current||n("input")):(n("input"),window.open(f.authUrl,"_blank"))}catch(a){v(a.message),n("error")}},[b,G,L,k,l]),N=async()=>{try{v(null);let a=q.trim(),b=new URL(a),c=b.searchParams.get("code"),d=b.searchParams.get("state"),e=b.searchParams.get("error");if(e)throw Error(b.searchParams.get("error_description")||e);if(!c)throw Error("No authorization code found in URL");await K(c,d)}catch(a){v(a.message),n("error")}},O=async()=>{try{let a;v(null);let c=s.trim();if(!c)throw Error("Please paste the session JSON first");try{a=JSON.parse(c)}catch(a){throw Error("Invalid JSON format")}if(!a.accessToken||!a.sessionToken)throw Error("JSON must contain accessToken and sessionToken");let d=await fetch(`/api/oauth/${b}/import-session`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)}),e=await d.json();if(!d.ok)throw Error(e.error);n("success"),f?.()}catch(a){v(a.message),n("error")}},P=(0,e.useCallback)(()=>{"codex"===b&&fetch("/api/oauth/codex/stop-proxy").catch(()=>{}),g()},[g,b]);if(!b||!c)return null;let Q=y?.verification_uri_complete||y?.verification_uri||"";return(0,d.jsx)(h.aF,{isOpen:a,title:`Connect ${c.name}`,onClose:P,size:"lg",children:(0,d.jsxs)("div",{className:"flex flex-col gap-4",children:["waiting"===m&&!w&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2 border border-border rounded-lg bg-sidebar/50",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-base text-primary animate-spin",children:"progress_activity"}),(0,d.jsx)("span",{className:"text-sm",children:"Waiting for popup authorization…"})]}),(0,d.jsx)("h3",{className:"text-lg font-semibold mb-2",children:"Waiting for Authorization"}),(0,d.jsx)("p",{className:"text-sm text-text-muted mb-4",children:"Complete the authorization in the popup window."}),(0,d.jsx)(h.$n,{variant:"ghost",onClick:()=>n("input"),children:"codex"===b?"Popup blocked or use Session JSON?":"Popup blocked? Enter URL manually"})]}),"waiting"===m&&w&&y&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("div",{className:"text-center py-4",children:[(0,d.jsx)("p",{className:"text-sm text-text-muted mb-4",children:"Visit the login URL below and authorize:"}),(0,d.jsxs)("div",{className:"bg-sidebar p-4 rounded-lg mb-4",children:[(0,d.jsx)("p",{className:"text-xs text-text-muted mb-1",children:"Login URL"}),(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("code",{className:"flex-1 text-sm break-all",children:Q}),(0,d.jsx)(h.$n,{size:"sm",variant:"ghost",icon:"login_url"===E?"check":"content_copy",onClick:()=>F(Q,"login_url"),disabled:!Q}),(0,d.jsx)(h.$n,{size:"sm",variant:"ghost",icon:"open_in_new",onClick:()=>window.open(Q,"_blank","noopener,noreferrer"),disabled:!Q,children:"Open"})]})]}),(0,d.jsxs)("div",{className:"bg-primary/10 p-4 rounded-lg",children:[(0,d.jsx)("p",{className:"text-xs text-text-muted mb-1",children:"Your Code"}),(0,d.jsxs)("div",{className:"flex items-center justify-center gap-2",children:[(0,d.jsx)("p",{className:"text-2xl font-mono font-bold text-primary",children:y.user_code}),(0,d.jsx)(h.$n,{size:"sm",variant:"ghost",icon:"user_code"===E?"check":"content_copy",onClick:()=>F(y.user_code,"user_code")})]})]})]}),A&&(0,d.jsxs)("div",{className:"flex items-center justify-center gap-2 text-sm text-text-muted",children:[(0,d.jsx)("span",{className:"material-symbols-outlined animate-spin",children:"progress_activity"}),"Waiting for authorization..."]})]}),"input"===m&&!w&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("div",{className:"space-y-4",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("p",{className:"text-sm font-medium mb-2",children:"Step 1: Open this URL in your browser"}),(0,d.jsxs)("div",{className:"flex gap-2",children:[(0,d.jsx)(h.pd,{value:o?.authUrl||"",readOnly:!0,className:"flex-1 font-mono text-xs"}),(0,d.jsx)(h.$n,{variant:"secondary",icon:"auth_url"===E?"check":"content_copy",onClick:()=>F(o?.authUrl,"auth_url"),children:"Copy"})]})]}),(0,d.jsxs)("div",{children:[(0,d.jsx)("p",{className:"text-sm font-medium mb-2",children:"Step 2: Paste the callback URL here"}),(0,d.jsx)("p",{className:"text-xs text-text-muted mb-2",children:"After authorization, copy the full URL from your browser."}),(0,d.jsx)(h.pd,{value:q,onChange:a=>r(a.target.value),placeholder:I,className:"font-mono text-xs"}),(0,d.jsx)(h.$n,{onClick:N,fullWidth:!0,disabled:!q,className:"mt-3",children:"Connect"})]}),"codex"===b&&(0,d.jsxs)("div",{className:"pt-4 border-t border-border",children:[(0,d.jsx)("p",{className:"text-sm font-medium mb-2",children:"Alternative: Session JSON"}),(0,d.jsxs)("p",{className:"text-xs text-text-muted mb-2",children:["Visit ",(0,d.jsx)("a",{href:"https://chatgpt.com/api/auth/session",target:"_blank",rel:"noreferrer",className:"text-primary hover:underline",children:"https://chatgpt.com/api/auth/session"})," and paste the JSON response below."]}),(0,d.jsx)("textarea",{value:s,onChange:a=>t(a.target.value),placeholder:'{ "accessToken": "...", "user": {...} }',className:"w-full h-24 py-2 px-3 text-xs font-mono text-text-main bg-white dark:bg-white/5 border border-black/10 dark:border-white/10 rounded-md placeholder-text-muted/60 focus:ring-1 focus:ring-primary/30 focus:border-primary/50 focus:outline-none transition-all shadow-inner resize-none"}),(0,d.jsx)(h.$n,{onClick:O,fullWidth:!0,disabled:!s,className:"mt-2",variant:"secondary",children:"Parse and Connect"})]})]}),(0,d.jsx)("div",{className:"flex gap-2",children:(0,d.jsx)(h.$n,{onClick:P,variant:"ghost",fullWidth:!0,children:"Cancel"})})]}),"success"===m&&(0,d.jsxs)("div",{className:"text-center py-6",children:[(0,d.jsx)("div",{className:"size-16 mx-auto mb-4 rounded-full bg-green-100 dark:bg-green-900/30 flex items-center justify-center",children:(0,d.jsx)("span",{className:"material-symbols-outlined text-3xl text-green-600",children:"check_circle"})}),(0,d.jsx)("h3",{className:"text-lg font-semibold mb-2",children:"Connected Successfully!"}),(0,d.jsxs)("p",{className:"text-sm text-text-muted mb-4",children:["Your ",c.name," account has been connected."]}),(0,d.jsx)(h.$n,{onClick:P,fullWidth:!0,children:"Done"})]}),"error"===m&&(0,d.jsxs)("div",{className:"text-center py-6",children:[(0,d.jsx)("div",{className:"size-16 mx-auto mb-4 rounded-full bg-red-100 dark:bg-red-900/30 flex items-center justify-center",children:(0,d.jsx)("span",{className:"material-symbols-outlined text-3xl text-red-600",children:"error"})}),(0,d.jsx)("h3",{className:"text-lg font-semibold mb-2",children:"Connection Failed"}),(0,d.jsx)("p",{className:"text-sm text-red-600 mb-4",children:u}),(0,d.jsxs)("div",{className:"flex gap-2",children:[(0,d.jsx)(h.$n,{onClick:M,variant:"secondary",fullWidth:!0,children:"Try Again"}),(0,d.jsx)(h.$n,{onClick:P,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})]})})}j.propTypes={isOpen:g().bool.isRequired,provider:g().string,providerInfo:g().shape({name:g().string}),onSuccess:g().func,onClose:g().func.isRequired,oauthMeta:g().object,idcConfig:g().shape({startUrl:g().string,region:g().string})}},79488:(a,b,c)=>{c.d(b,{default:()=>i});var d=c(48249),e=c(67484),f=c(49885),g=c.n(f),h=c(50412);function i({isOpen:a,onSuccess:b,onClose:c}){let[f,g]=(0,e.useState)(""),[j,k]=(0,e.useState)(!1),[l,m]=(0,e.useState)(null),[n,o]=(0,e.useState)(!1),p=async()=>{if(!f.trim())return void m("Please paste your cookie");k(!0),m(null);try{let a=await fetch("/api/oauth/iflow/cookie",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cookie:f.trim()})}),c=await a.json();if(!a.ok)throw Error(c.error||"Authentication failed");o(!0),setTimeout(()=>{b?.(),q()},1500)}catch(a){m(a.message)}finally{k(!1)}},q=()=>{g(""),m(null),o(!1),c?.()};return(0,d.jsx)(h.aF,{isOpen:a,onClose:q,title:"iFlow Cookie Authentication",children:(0,d.jsx)("div",{className:"space-y-4",children:n?(0,d.jsxs)("div",{className:"text-center py-8",children:[(0,d.jsx)("div",{className:"text-6xl mb-4",children:"✅"}),(0,d.jsx)("p",{className:"text-lg font-medium text-text-primary",children:"Authentication Successful!"}),(0,d.jsx)("p",{className:"text-sm text-text-muted mt-2",children:"Fresh API key obtained"})]}):(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("div",{className:"space-y-2",children:[(0,d.jsxs)("p",{className:"text-sm text-text-muted",children:["To get a fresh API key, paste your browser cookie from"," ",(0,d.jsx)("a",{href:"https://platform.iflow.cn",target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:"platform.iflow.cn"})]}),(0,d.jsxs)("div",{className:"bg-surface-secondary p-3 rounded-lg text-xs space-y-2",children:[(0,d.jsx)("p",{className:"font-medium text-text-primary",children:"How to get cookie:"}),(0,d.jsxs)("ol",{className:"list-decimal list-inside space-y-1 text-text-muted",children:[(0,d.jsx)("li",{children:"Open platform.iflow.cn in your browser"}),(0,d.jsx)("li",{children:"Login to your account"}),(0,d.jsx)("li",{children:"Open DevTools (F12) → Application/Storage → Cookies"}),(0,d.jsx)("li",{children:"Copy the entire cookie string (must include BXAuth)"}),(0,d.jsx)("li",{children:"Paste it below"})]})]})]}),(0,d.jsxs)("div",{className:"space-y-2",children:[(0,d.jsx)("label",{className:"block text-sm font-medium text-text-primary",children:"Cookie String"}),(0,d.jsx)("textarea",{value:f,onChange:a=>g(a.target.value),placeholder:"BXAuth=xxx; ...",className:"w-full px-3 py-2 bg-surface-secondary border border-border rounded-lg text-sm text-text-primary placeholder-text-muted focus:outline-none focus:ring-2 focus:ring-primary resize-none",rows:4,disabled:j})]}),l&&(0,d.jsx)("div",{className:"p-3 bg-error/10 border border-error/20 rounded-lg",children:(0,d.jsx)("p",{className:"text-sm text-error",children:l})}),(0,d.jsxs)("div",{className:"flex gap-3 pt-2",children:[(0,d.jsx)(h.$n,{variant:"secondary",onClick:q,disabled:j,fullWidth:!0,children:"Cancel"}),(0,d.jsx)(h.$n,{onClick:p,loading:j,fullWidth:!0,children:"Authenticate"})]})]})})})}i.propTypes={isOpen:g().bool.isRequired,onSuccess:g().func,onClose:g().func}},83021:(a,b,c)=>{c.d(b,{A:()=>i});var d=c(48249),e=c(49885),f=c.n(e),g=c(17660);let h=a=>new Intl.NumberFormat().format(a||0);function i({stats:a}){let b;return(0,d.jsxs)("div",{className:"grid min-w-0 grid-cols-1 gap-3 sm:grid-cols-2 md:grid-cols-4 sm:gap-4",children:[(0,d.jsxs)(g.default,{className:"flex min-w-0 flex-col gap-1 px-4 py-3",children:[(0,d.jsx)("span",{className:"text-text-muted text-sm uppercase font-semibold",children:"Total Requests"}),(0,d.jsx)("span",{className:"truncate text-2xl font-bold",children:h(a.totalRequests)})]}),(0,d.jsxs)(g.default,{className:"flex min-w-0 flex-col gap-1 px-4 py-3",children:[(0,d.jsx)("span",{className:"text-text-muted text-sm uppercase font-semibold",children:"Total Input Tokens"}),(0,d.jsx)("span",{className:"truncate text-2xl font-bold text-primary",children:h(a.totalPromptTokens)})]}),(0,d.jsxs)(g.default,{className:"flex min-w-0 flex-col gap-1 px-4 py-3",children:[(0,d.jsx)("span",{className:"text-text-muted text-sm uppercase font-semibold",children:"Output Tokens"}),(0,d.jsx)("span",{className:"truncate text-2xl font-bold text-success",children:h(a.totalCompletionTokens)})]}),(0,d.jsxs)(g.default,{className:"flex min-w-0 flex-col gap-1 px-4 py-3",children:[(0,d.jsx)("span",{className:"text-text-muted text-sm uppercase font-semibold",children:"Est. Cost"}),(0,d.jsxs)("span",{className:"truncate text-2xl font-bold text-warning",children:["~",(b=a.totalCost,`$${(b||0).toFixed(2)}`)]})]})]})}i.propTypes={stats:f().object.isRequired}},83352:(a,b,c)=>{c.d(b,{default:()=>n});var d=c(48249),e=c(67484),f=c(49885),g=c.n(f),h=c(95145),i=c(72738),j=c(91431),k=c(96919);let l=[...Object.keys(k.zN),...Object.keys(k.IS),...Object.keys(k.nJ),...Object.keys(k.fg)],m=Object.keys(k.IS).filter(a=>k.IS[a].noAuth);function n({isOpen:a,onClose:b,onSelect:c,onDeselect:f,selectedModel:g,activeProviders:o=[],title:p="Select Model",modelAliases:q={},kindFilter:r=null,addedModelValues:s=[],closeOnSelect:t=!0}){let u=(0,e.useMemo)(()=>r?o.filter(a=>{let b=k.Q2[a.provider];return(b?.serviceKinds||["llm"]).includes(r)}):o,[o,r]),[v,w]=(0,e.useState)(""),[x,y]=(0,e.useState)([]),[z,A]=(0,e.useState)([]),[B,C]=(0,e.useState)([]),[D,E]=(0,e.useState)({}),F=(0,e.useMemo)(()=>({...k.zN,...k.IS,...k.nJ,...k.fg}),[]),G=(0,e.useMemo)(()=>{let a={},b=new Set(["webSearch","webFetch"]),c=new Set(["image","tts","stt","embedding","imageToText"]),d=new Set(["tts","image","webFetch"]);return[...new Set([...u.map(a=>a.provider),...r?m.filter(a=>(k.Q2[a]?.serviceKinds||["llm"]).includes(r)):m])].sort((a,b)=>{let c=l.indexOf(a),d=l.indexOf(b);return(-1===c?999:c)-(-1===d?999:d)}).forEach(e=>{let f=(0,k.wG)(e),g=F[e]||{name:e,color:"#666"},h=(0,k.mq)(e)||(0,k.gb)(e);if(r&&b.has(r)){a[e]={name:g.name,alias:f,color:g.color,models:[{id:e,name:g.name,value:e}]};return}if(g.passthroughModels){let b=Object.entries(q).filter(([,a])=>a.startsWith(`${f}/`)).map(([a,b])=>({id:b.replace(`${f}/`,""),name:a,value:b}));if(r&&c.has(r)&&0===(b=(0,j.KC)(e).filter(a=>a.type===r).map(a=>({id:a.id,name:a.name,value:`${f}/${a.id}`,type:a.type}))).length&&d.has(r)&&(g.serviceKinds||["llm"]).includes(r)&&(b=[{id:e,name:g.name,value:f}]),b.length>0){let c=z.find(a=>a.id===e),d=c?.name||g.name;a[e]={name:d,alias:f,color:g.color,models:b}}}else if(h){if(r&&c.has(r))return;let b=o.find(a=>a.provider===e),d=z.find(a=>a.id===e),f=b?.name||d?.name||g.name,h=b?.providerSpecificData?.prefix||d?.prefix||e,i=Object.entries(q).filter(([,a])=>a.startsWith(`${e}/`)).map(([a,b])=>({id:b.replace(`${e}/`,""),name:a,value:`${h}/${b.replace(`${e}/`,"")}`})),j=i.length>0?i:[{id:`__placeholder__${e}`,name:`${h}/model-id`,value:`${h}/model-id`,isPlaceholder:!0}];a[e]={name:f,alias:h,color:g.color,models:j,isCustom:!0,hasModels:i.length>0}}else{var i;let b=(0,j.KC)(e),h=new Set(b.map(a=>a.id)),k=b.length>0,l=Object.entries(q).filter(([a,b])=>b.startsWith(`${f}/`)&&(!k||a===b.replace(`${f}/`,""))&&!h.has(b.replace(`${f}/`,""))).map(([a,b])=>({id:b.replace(`${f}/`,""),name:a,value:b,isCustom:!0})),m=new Set(l.map(a=>a.id)),n=B.filter(a=>a.providerAlias===f&&!h.has(a.id)&&!m.has(a.id)).map(a=>({id:a.id,name:a.name||a.id,value:`${f}/${a.id}`,isCustom:!0})),o=[...b.map(a=>({id:a.id,name:a.name,value:`${f}/${a.id}`,type:a.type})),...l,...n],p=new Set,s=(i=o.filter(a=>!p.has(a.value)&&(p.add(a.value),!0)),r?c.has(r)?i.filter(a=>a.isPlaceholder||a.type===r):i:i.filter(a=>a.isPlaceholder||!a.type||"llm"===a.type));0===s.length&&r&&d.has(r)&&(g.serviceKinds||["llm"]).includes(r)&&(s=[{id:e,name:g.name,value:f}]),s.length>0&&(a[e]={name:g.name,alias:f,color:g.color,models:s})}}),Object.entries(a).forEach(([b,c])=>{let d=new Set([...D[(0,k.wG)(b)]||[],...D[b]||[]]);0!==d.size&&(c.models=c.models.filter(a=>!d.has(a.id)),0===c.models.length&&delete a[b])}),a},[u,q,F,z,B,D,r,o]),H=(0,e.useMemo)(()=>{if(r)return[];if(!v.trim())return x;let a=v.toLowerCase();return x.filter(b=>b.name.toLowerCase().includes(a))},[x,v,r]),I=(0,e.useMemo)(()=>{let a=v.trim().toLowerCase(),b={};return Object.entries(G).forEach(([c,d])=>{var e;let f=d.models;if(a){let b=d.name.toLowerCase().includes(a);if(0===(f=f.filter(b=>b.name.toLowerCase().includes(a)||b.id.toLowerCase().includes(a))).length&&!b)return}b[c]={...d,models:[...(e=f).filter(a=>s.includes(a.value)).sort((a,b)=>a.name.localeCompare(b.name)),...e.filter(a=>!s.includes(a.value)).sort((a,b)=>a.name.localeCompare(b.name))]}}),b},[G,v,s]),J=a=>{let d=a?.value||a?.name||a;s.includes(d)&&f?f(a):c(a),t&&(b(),w(""))};return(0,d.jsxs)(h.default,{isOpen:a,onClose:()=>{b(),w("")},title:p,size:"md",className:"p-4!",footer:null,children:[(0,d.jsxs)("div",{className:"flex items-center gap-2 mb-3 px-2.5 py-2 bg-primary/8 border border-primary/20 rounded-lg text-xs text-text-muted",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-primary shrink-0",style:{fontSize:"14px"},children:"info"}),(0,d.jsx)("span",{children:"Click to add, click again to remove. Changes are saved automatically."})]}),(0,d.jsx)("div",{className:"mb-3",children:(0,d.jsxs)("div",{className:"relative",children:[(0,d.jsx)("span",{className:"material-symbols-outlined absolute left-2.5 top-1/2 -translate-y-1/2 text-text-muted text-[16px]",children:"search"}),(0,d.jsx)("input",{type:"text",placeholder:"Search...",value:v,onChange:a=>w(a.target.value),className:"w-full pl-8 pr-3 py-1.5 bg-surface border border-border rounded text-xs focus:outline-none focus:ring-1 focus:ring-primary/50"})]})}),(0,d.jsxs)("div",{className:"max-h-[400px] overflow-y-auto space-y-3",children:[H.length>0&&(0,d.jsxs)("div",{children:[(0,d.jsxs)("div",{className:"flex items-center gap-1.5 mb-1.5 sticky top-0 bg-surface py-0.5",children:[(0,d.jsx)("span",{className:"material-symbols-outlined text-primary text-[14px]",children:"layers"}),(0,d.jsx)("span",{className:"text-xs font-medium text-primary",children:"Combos"}),(0,d.jsxs)("span",{className:"text-[10px] text-text-muted",children:["(",H.length,")"]})]}),(0,d.jsx)("div",{className:"flex flex-wrap gap-1.5",children:H.map(a=>{let b=g===a.name;return(0,d.jsxs)("button",{onClick:()=>J({id:a.name,name:a.name,value:a.name}),className:`
|
|
2
2
|
px-2 py-1 rounded-xl text-xs font-medium transition-all border hover:cursor-pointer flex items-center gap-1
|
|
3
3
|
${b?"bg-primary text-white border-primary":s.includes(a.name)?"bg-primary border-primary text-white hover:bg-primary-hover":"bg-surface border-border text-text-main hover:border-primary/50 hover:bg-primary/5"}
|
|
4
4
|
`,children:[s.includes(a.name)&&(0,d.jsx)("span",{className:"material-symbols-outlined leading-none",style:{fontSize:"10px"},children:"check"}),a.name]},a.id)})})]}),Object.entries(I).map(([a,b])=>(0,d.jsxs)("div",{children:[(0,d.jsxs)("div",{className:"flex items-center gap-1.5 mb-1.5 sticky top-0 bg-surface py-0.5",children:[(0,d.jsx)(i.A,{src:`/providers/${a}.png`,alt:b.name,size:14,fallbackText:(b.name||a).slice(0,2).toUpperCase(),fallbackColor:b.color}),(0,d.jsx)("span",{className:"text-xs font-medium text-primary",children:b.name}),(0,d.jsxs)("span",{className:"text-[10px] text-text-muted",children:["(",b.models.length,")"]})]}),(0,d.jsx)("div",{className:"flex flex-wrap gap-1.5",children:b.models.map(a=>{let b=g===a.value,c=a.isPlaceholder;return(0,d.jsx)("button",{onClick:()=>J(a),title:c?"Select to pre-fill, then edit model ID in the input":void 0,className:`
|