1(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,80173,e=>{"use strict";var t=e.i(843476),s=e.i(271645),r=e.i(948148),a=e.i(156132);e.s(["default",0,function({label:e,type:l="text",placeholder:i,value:n,onChange:o,error:c,hint:d,icon:u,disabled:m=!1,required:x=!1,className:p,inputClassName:h,id:b,onKeyDown:f,onKeyUp:g,...y}){let v=(0,r.useTranslations)("common"),j=(0,s.useId)(),k=b||j,N=c?`${k}-error`:void 0,w=d&&!c?`${k}-hint`:void 0,S=`${k}-capslock`,C="password"===l,[T,E]=(0,s.useState)(!1),[_,I]=(0,s.useState)(!1),A=(0,s.useCallback)(e=>{C&&E(e.getModifierState("CapsLock"))},[C]),D=(0,s.useCallback)(e=>{A(e),f?.(e)},[A,f]),K=(0,s.useCallback)(e=>{A(e),g?.(e)},[A,g]),L=C&&T&&_,M=[N,L?S:void 0,w].filter(Boolean).join(" ")||void 0;return(0,t.jsxs)("div",{className:(0,a.cn)("flex flex-col gap-1.5",p),children:[e&&(0,t.jsxs)("label",{htmlFor:k,className:"text-sm font-medium text-text-main",children:[e,x&&(0,t.jsx)("span",{className:"text-red-500 ml-1","aria-hidden":"true",children:"*"})]}),(0,t.jsxs)("div",{className:"relative",children:[u&&(0,t.jsx)("div",{className:"absolute inset-y-0 left-0 flex items-center pl-3 pointer-events-none text-text-muted",children:(0,t.jsx)("span",{className:"material-symbols-outlined text-[20px]","aria-hidden":"true",children:u})}),(0,t.jsx)("input",{id:k,type:l,placeholder:i,value:n,onChange:o,disabled:m,required:x,"aria-required":x||void 0,"aria-invalid":!!c||void 0,"aria-describedby":M,onKeyDown:D,onKeyUp:K,onFocus:e=>{I(!0),y.onFocus?.(e)},onBlur:e=>{I(!1),E(!1),y.onBlur?.(e)},className:(0,a.cn)("w-full py-2 px-3 text-sm text-text-main","bg-white dark:bg-white/5 border border-black/10 dark:border-white/10 rounded-control","placeholder-text-muted/60","focus:ring-1 focus:ring-accent/30 focus:border-accent/50 focus:outline-none","transition-all shadow-inner disabled:opacity-50 disabled:cursor-not-allowed","text-[16px] sm:text-sm",u&&"pl-10",c?"border-red-500 focus:border-red-500 focus:ring-red-500/20":"",h),...y})]}),L&&(0,t.jsxs)("p",{id:S,className:"text-xs text-amber-500 dark:text-amber-400 flex items-center gap-1 animate-in fade-in duration-200",role:"status","aria-live":"polite",children:[(0,t.jsx)("span",{className:"material-symbols-outlined text-[14px]","aria-hidden":"true",children:"keyboard_capslock"}),v("capsLockOn")]}),c&&(0,t.jsxs)("p",{id:N,className:"text-xs text-red-500 flex items-center gap-1",role:"alert",children:[(0,t.jsx)("span",{className:"material-symbols-outlined text-[14px]","aria-hidden":"true",children:"error"}),c]}),d&&!c&&(0,t.jsx)("p",{id:w,className:"text-xs text-text-muted",children:d})]})}])},907714,e=>{"use strict";var t=e.i(843476),s=e.i(271645),r=e.i(948148),a=e.i(156132);e.s(["default",0,function({label:e,options:l=[],value:i,onChange:n,placeholder:o,error:c,hint:d,disabled:u=!1,required:m=!1,className:x,selectClassName:p,id:h,children:b,...f}){let g=(0,r.useTranslations)("common"),y=(0,s.useId)(),v=h||y,j=c?`${v}-error`:void 0,k=d&&!c?`${v}-hint`:void 0,N=[j,k].filter(Boolean).join(" ")||void 0;return(0,t.jsxs)("div",{className:(0,a.cn)("flex flex-col gap-1.5",x),children:[e&&(0,t.jsxs)("label",{htmlFor:v,className:"text-sm font-medium text-text-main",children:[e,m&&(0,t.jsx)("span",{className:"text-red-500 ml-1","aria-hidden":"true",children:"*"})]}),(0,t.jsxs)("div",{className:"relative",children:[(0,t.jsxs)("select",{id:v,value:i,onChange:n,disabled:u,required:m,"aria-required":m||void 0,"aria-invalid":!!c||void 0,"aria-describedby":N,className:(0,a.cn)("w-full py-2 px-3 pe-10 text-sm text-text-main","bg-surface border border-black/10 dark:border-white/10 rounded-control appearance-none","focus:ring-1 focus:ring-accent/30 focus:border-accent/50 focus:outline-none","transition-all disabled:opacity-50 disabled:cursor-not-allowed","text-[16px] sm:text-sm",c?"border-red-500 focus:border-red-500 focus:ring-red-500/20":"",p),...f,children:[!b&&(o??g("selectOption"))&&(0,t.jsx)("option",{value:"",disabled:!0,className:"bg-surface text-text-muted",children:o??g("selectOption")}),!b&&l.map(e=>(0,t.jsx)("option",{value:e.value,className:"bg-surface text-text-main",children:e.label},e.value)),b]}),(0,t.jsx)("div",{className:"absolute inset-y-0 end-0 flex items-center pe-3 pointer-events-none text-text-muted","aria-hidden":"true",children:(0,t.jsx)("span",{className:"material-symbols-outlined text-[20px]",children:"expand_more"})})]}),c&&(0,t.jsxs)("p",{id:j,className:"text-xs text-red-500 flex items-center gap-1",role:"alert",children:[(0,t.jsx)("span",{className:"material-symbols-outlined text-[14px]","aria-hidden":"true",children:"error"}),c]}),d&&!c&&(0,t.jsx)("p",{id:k,className:"text-xs text-text-muted",children:d})]})}])},542055,e=>{"use strict";var t=e.i(843476),s=e.i(156132);e.s(["default",0,function({label:e,className:r,id:a,...l}){let i=(0,t.jsx)("input",{type:"checkbox",id:a,className:(0,s.cn)("h-4 w-4 shrink-0 cursor-pointer rounded-[4px] accent-[var(--color-accent)]","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/30","disabled:cursor-not-allowed disabled:opacity-50",r),...l});return e?(0,t.jsxs)("label",{htmlFor:a,className:"inline-flex items-center gap-2 cursor-pointer text-sm text-text-main",children:[i,(0,t.jsx)("span",{children:e})]}):i}])},51130,e=>{"use strict";var t=e.i(843476),s=e.i(271645),r=e.i(156132);
1e.s(["default",0,function({title:e,subtitle:a,icon:l,trailing:i,defaultOpen:n=!1,variant:o="default",className:c,children:d}){let[u,m]=(0,s.useState)(n),x=(0,r.cn)("default"===o?"rounded-lg border border-black/5 dark:border-white/5 bg-surface":"rounded-md border border-black/5 dark:border-white/5 bg-black/[0.02] dark:bg-white/[0.02]",c),p=(0,r.cn)("flex items-center gap-3","default"===o?"p-4":"p-3","hover:bg-black/[0.02] dark:hover:bg-white/[0.02] transition-colors",u&&"border-b border-black/5 dark:border-white/5");return(0,t.jsxs)("div",{className:x,children:[(0,t.jsxs)("div",{className:p,children:[(0,t.jsxs)("button",{type:"button",onClick:()=>m(e=>!e),"aria-expanded":u,className:"flex items-center gap-3 flex-1 min-w-0 text-left -m-1 p-1 rounded",children:[(0,t.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[20px] shrink-0","aria-hidden":"true",children:u?"expand_more":"chevron_right"}),l&&(0,t.jsx)("span",{className:"material-symbols-outlined text-text-muted text-[18px] shrink-0","aria-hidden":"true",children:l}),(0,t.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,t.jsx)("div",{className:"text-sm font-medium text-text-main truncate",children:e}),a&&(0,t.jsx)("div",{className:"text-xs text-text-muted truncate",children:a})]})]}),i&&(0,t.jsx)("div",{className:"flex items-center gap-2 shrink-0",children:i})]}),u&&(0,t.jsx)("div",{className:"default"===o?"p-4":"p-3",children:d})]})}])},822124,e=>{"use strict";var t=e.i(843476),s=e.i(156132);e.s(["default",0,function({src:e,alt:r="Avatar",name:a,size:l="md",className:i}){let n={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 e?(0,t.jsx)("div",{className:(0,s.cn)("rounded-full bg-cover bg-center bg-no-repeat","ring-2 ring-white dark:ring-surface-dark shadow-sm",n[l],i),style:{backgroundImage:`url(${e})`},role:"img","aria-label":r}):(0,t.jsx)("div",{className:(0,s.cn)("rounded-full flex items-center justify-center font-semibold text-white","ring-2 ring-white dark:ring-surface-dark shadow-sm",n[l],(e=>{if(!e)return"bg-primary";let t=["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"],s=e.charCodeAt(0)%t.length;return t[s]})(a),i),role:"img","aria-label":r,children:(e=>{if(!e)return"?";let t=e.split(" ");return t.length>=2?`${t[0][0]}${t[1][0]}`.toUpperCase():e.substring(0,2).toUpperCase()})(a)})}])},897844,e=>{"use strict";var t=e.i(843476),s=e.i(948148),r=e.i(287531),a=e.i(156132);e.s(["default",0,function({className:e,variant:l="default"}){let{toggleTheme:i,isDark:n}=(0,r.useTheme)(),o=(0,s.useTranslations)("header")(n?"switchToLightMode":"switchToDarkMode"),c={default:(0,a.cn)("flex items-center justify-center size-10 rounded-full","text-text-muted","hover:bg-black/5","hover:text-text-main","transition-colors"),card:(0,a.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-md","text-text-muted-light hover:text-primary","hover:text-primary","transition-all group")};return(0,t.jsx)("button",{onClick:i,className:(0,a.cn)(c[l],e),"aria-label":o,title:o,children:(0,t.jsx)("span",{className:(0,a.cn)("material-symbols-outlined text-[22px]","card"===l&&"transition-transform duration-300 group-hover:rotate-12"),children:n?"light_mode":"dark_mode"})})}])},241937,974440,513859,e=>{"use strict";let t=["home","api-manager","endpoints","providers","embedded-services","combos","combos-live","quota","context-settings","context-combos","context-caveman","context-rtk","context-headroom","context-session-dedup","context-ccr","context-llmlingua","context-lite","context-aggressive","context-ultra","context-omniglyph","compression-studio","compression-exclusions","cli-code","cli-agents","acp-agents","cloud-agents","agent-bridge","traffic-inspector","discovery","api-endpoints","webhooks","mitm-proxy","1proxy","analytics","analytics-combo-health","analytics-utilization","costs","cache","analytics-compression","analytics-search","analytics-evals","provider-stats","activity","logs","logs-proxy","logs-console","logs-timeline","logs-activity","health","runtime","costs-pricing","costs-budget","costs-free-tiers","costs-quota-s
1hare","free-provider-rankings","audit","audit-mcp","audit-a2a","translator","playground","search-tools","memory","skills","agent-skills","chaos-config","mcp","a2a","plugins","leaderboard","profile","tokens","media","batch","batch-files","settings-general","settings-appearance","settings-ai","settings-routing","settings-resilience","settings-advanced","settings-security","settings-access-tokens","settings-feature-flags","settings-cache","settings-sidebar","docs","issues","changelog"];e.s(["HIDEABLE_SIDEBAR_ITEM_IDS",0,t],974440);let s={home:"#60A5FA","api-manager":"#F59E0B",endpoints:"#38BDF8",providers:"#818CF8",combos:"#A855F7",quota:"#F472B6","context-caveman":"#F97316","context-rtk":"#2DD4BF","context-combos":"#C084FC","cli-code":"#FACC15","cli-agents":"#93C5FD","cloud-agents":"#7DD3FC","api-endpoints":"#14B8A6",webhooks:"#EC4899",proxy:"#A3E635","mitm-proxy":"#FB7185","1proxy":"#22D3EE",analytics:"#06B6D4","analytics-combo-health":"#34D399","analytics-utilization":"#FBBF24",costs:"#FB923C",cache:"#84CC16","analytics-compression":"#F97316","analytics-search":"#38BDF8","analytics-evals":"#A78BFA",logs:"#CBD5E1","logs-proxy":"#A3E635","logs-console":"#FACC15","logs-timeline":"#F472B6","logs-activity":"#60A5FA",health:"#EF4444",runtime:"#F59E0B","costs-pricing":"#FB923C","costs-budget":"#22C55E","costs-quota-share":"#06B6D4",audit:"#F43F5E","audit-mcp":"#818CF8","audit-a2a":"#A855F7",translator:"#3B82F6",playground:"#EAB308","search-tools":"#0891B2",memory:"#10B981",skills:"#F43F5E","agent-skills":"#D946EF",mcp:"#8B5CF6",a2a:"#06B6D4",leaderboard:"#FACC15",profile:"#60A5FA",tokens:"#A3E635",media:"#D946EF",batch:"#14B8A6","batch-files":"#38BDF8","settings-general":"#64748B","settings-appearance":"#D946EF","settings-ai":"#A78BFA","settings-routing":"#06B6D4","settings-resilience":"#22C55E","settings-advanced":"#F97316","settings-security":"#EF4444","settings-feature-flags":"#FACC15","settings-cache":"#84CC16","settings-sidebar":"#38BDF8",docs:"#2563EB",issues:"#DC2626",changelog:"#F59E0B"},r={},a=new Set(["home","endpoints","api-manager","providers","combos","analytics","costs","logs","health","settings-general","settings-sidebar","docs","changelog"]),l=new Set(["home","endpoints","api-manager","providers","combos","quota","context-caveman","context-rtk","context-combos","cli-code","cli-agents","acp-agents","api-endpoints","analytics","analytics-combo-health","costs","cache","logs","health","runtime","translator","playground","memory","skills","mcp","a2a","settings-general","settings-routing","settings-resilience","settings-sidebar","docs","issues","changelog"]),i=new Set(["home","endpoints","api-manager","providers","combos","quota","analytics","analytics-combo-health","analytics-utilization","costs","costs-pricing","costs-budget","costs-quota-share","cache","logs","activity","health","runtime","audit","audit-mcp","audit-a2a","settings-general","settings-routing","settings-resilience","settings-security","settings-access-tokens","settings-feature-flags","settings-sidebar","docs","changelog"]);function n(e){return t.filter(t=>!e.has(t))}let o=[{id:"all",icon:"select_all",hiddenItems:[]},{id:"minimal",icon:"minimize",hiddenItems:n(a)},{id:"developer",icon:"code",hiddenItems:n(l)},{id:"admin",icon:"admin_panel_settings",hiddenItems:n(i)}];e.s(["HIDDEN_SIDEBAR_ITEMS_SETTING_KEY",0,"hiddenSidebarItems","SIDEBAR_ITEM_ORDER_KEY",0,"sidebarItemOrder","SIDEBAR_PRESETS",0,o,"SIDEBAR_PRESET_KEY",0,"sidebarActivePreset","SIDEBAR_SECTION_ORDER_KEY",0,"sidebarSectionOrder","SIDEBAR_SETTINGS_UPDATED_EVENT",0,"omniroute:settings-updated","applyItemOrder",0,function(e,t){if(0===t.length)return[...e];let s=e=>("type"in e&&e.type,e.id),r=new Set(e.map(s)),a=t.filter(e=>r.has(e)),l=new Map(a.map((e,t)=>[e,t]));return[...e].sort((t,r)=>{let i=s(t),n=s(r);return(l.get(i)??a.length+e.indexOf(t))-(l.get(n)??a.length+e.indexOf(r))})},"applySectionOrder",0,function(e,t){if(0===t.length)return[...e];let s=new Set(e.map(e=>e.id)),r=t.filter(e=>s.has(e)),a=new Map(r.map((e,t)=>[e,t]));return[...e].sort((t,s)=>(a.get(t.id)??r.length+e.indexOf(t))-(a.get(s.id)??r.length+e.indexOf(s)))},"getSectionItems",0,function(e){return e.children.flatMap(e=>"type"in e&&"group"===e.type?e.items:[e])},"getSidebarIconAccent",0,function(e){return s[e]||r[e]||function(e){let t=0;for(let s=0;s<e.length;s+=1)t=31*t+e.charCodeAt(s)>>>0;
1let s=.72*(1-Math.abs(.1200000000000001)),r=t%360/60,a=s*(1-Math.abs(r%2-1)),l=.56-s/2,[i,n,o]=r<1?[s,a,0]:r<2?[a,s,0]:r<3?[0,s,a]:r<4?[0,a,s]:r<5?[a,0,s]:[s,0,a];return[i,n,o].map(e=>Math.round((e+l)*255).toString(16).padStart(2,"0").toUpperCase()).join("").replace(/^/,"#")}(e)},"normalizeHiddenSidebarItems",0,function(e){if(!Array.isArray(e))return[];let s=new Set;for(let r of e)"string"==typeof r&&t.includes(r)&&s.add(r);return t.filter(e=>s.has(e))}],241937);let c=[{id:"home",titleKey:"home",titleFallback:"Home",children:[{id:"home",href:"/home",i18nKey:"home",subtitleKey:"homeSubtitle",icon:"home",exact:!0}],showTitle:!1},{id:"omni-proxy",titleKey:"omniProxySection",titleFallback:"OmniProxy",children:[{id:"endpoints",href:"/dashboard/endpoint",i18nKey:"endpoints",subtitleKey:"endpointsSubtitle",icon:"api"},{id:"api-manager",href:"/dashboard/api-manager",i18nKey:"apiManager",subtitleKey:"apiManagerSubtitle",icon:"vpn_key"},{id:"providers",href:"/dashboard/providers",i18nKey:"providers",subtitleKey:"providersSubtitle",icon:"dns"},{id:"embedded-services",href:"/dashboard/providers/services",i18nKey:"embeddedServices",subtitleKey:"embeddedServicesSubtitle",icon:"deployed_code"},{id:"combos",href:"/dashboard/combos",i18nKey:"combos",subtitleKey:"combosSubtitle",icon:"layers"},{id:"combos-live",href:"/dashboard/combos/live",i18nKey:"combosLive",labelFallback:"Combo Studio",subtitleKey:"combosLiveSubtitle",subtitleFallback:"Live routing cascade",icon:"account_tree"},{id:"quota",href:"/dashboard/quota",i18nKey:"providerQuota",subtitleKey:"providerQuotaSubtitle",icon:"tune"},{id:"costs-quota-share",href:"/dashboard/costs/quota-share",i18nKey:"costsQuotaShare",subtitleKey:"costsQuotaShareSubtitle",icon:"pie_chart"},{type:"group",id:"compression-context",titleKey:"compressionContextGroup",titleFallback:"Compression Context",items:[{id:"context-settings",href:"/dashboard/context/settings",i18nKey:"contextSettings",labelFallback:"Compression Settings",subtitleKey:"contextSettingsSubtitle",subtitleFallback:"Global defaults",icon:"settings"},{id:"context-combos",href:"/dashboard/context/combos",i18nKey:"contextCombos",subtitleKey:"contextCombosSubtitle",icon:"hub"},{id:"context-caveman",href:"/dashboard/context/caveman",i18nKey:"contextCaveman",subtitleKey:"contextCavemanSubtitle",icon:"compress"},{id:"context-rtk",href:"/dashboard/context/rtk",i18nKey:"contextRtk",subtitleKey:"contextRtkSubtitle",icon:"filter_alt"},{id:"context-headroom",href:"/dashboard/context/headroom",i18nKey:"contextHeadroom",labelFallback:"Headroom",subtitleKey:"contextHeadroomSubtitle",subtitleFallback:"Tabular compaction",icon:"table_rows"},{id:"context-session-dedup",href:"/dashboard/context/session-dedup",i18nKey:"contextSessionDedup",labelFallback:"Session Dedup",subtitleKey:"contextSessionDedupSubtitle",subtitleFallback:"Cross-turn dedup",icon:"content_copy"},{id:"context-ccr",href:"/dashboard/context/ccr",i18nKey:"contextCcr",labelFallback:"CCR",subtitleKey:"contextCcrSubtitle",subtitleFallback:"Retrieve markers",icon:"archive"},{id:"context-llmlingua",href:"/dashboard/context/llmlingua",i18nKey:"contextLlmlingua",labelFallback:"LLMLingua",subtitleKey:"contextLlmlinguaSubtitle",subtitleFallback:"Semantic pruning",icon:"psychology"},{id:"context-lite",href:"/dashboard/context/lite",i18nKey:"contextLite",labelFallback:"Lite",subtitleKey:"contextLiteSubtitle",subtitleFallback:"Fast whitespace cleanup",icon:"compress"},{id:"context-aggressive",href:"/dashboard/context/aggressive",i18nKey:"contextAggressive",labelFallback:"Aggressive",subtitleKey:"contextAggressiveSubtitle",subtitleFallback:"Summary + aging",icon:"speed"},{id:"context-ultra",href:"/dashboard/context/ultra",i18nKey:"contextUltra",labelFallback:"Ultra",subtitleKey:"contextUltraSubtitle",subtitleFallback:"Heuristic pruning",icon:"bolt"},{id:"context-omniglyph",href:"/dashboard/context/omniglyph",i18nKey:"contextOmniglyph",labelFallback:"OmniGlyph",subtitleKey:"contextOmniglyphSubtitle",subtitleFallback:"Context-as-image",icon:"grain"},{id:"compression-studio",href:"/dashboard/compression/studio",i18nKey:"compressionStudio",labelFallback:"Compression Studio",subtitleKey:"compressionStudioSubtitle",subt
1itleFallback:"Live engine cascade",icon:"monitoring"},{id:"compression-exclusions",href:"/dashboard/compression/exclusions",i18nKey:"compressionExclusions",labelFallback:"Exclusions",subtitleKey:"compressionExclusionsSubtitle",subtitleFallback:"Per-model/endpoint bypass",icon:"block"}]},{type:"group",id:"tools",titleKey:"toolsGroup",titleFallback:"Tools",items:[{id:"cli-code",href:"/dashboard/cli-code",i18nKey:"cliCode",subtitleKey:"cliCodeSubtitle",icon:"terminal"},{id:"cli-agents",href:"/dashboard/cli-agents",i18nKey:"cliAgents",subtitleKey:"cliAgentsSubtitle",icon:"smart_toy"},{id:"acp-agents",href:"/dashboard/acp-agents",i18nKey:"acpAgents",subtitleKey:"acpAgentsSubtitle",icon:"device_hub"},{id:"cloud-agents",href:"/dashboard/cloud-agents",i18nKey:"cloudAgents",subtitleKey:"cloudAgentsSubtitle",icon:"cloud"},{id:"agent-bridge",href:"/dashboard/tools/agent-bridge",i18nKey:"agentBridge",subtitleKey:"agentBridgeSubtitle",icon:"link"},{id:"traffic-inspector",href:"/dashboard/tools/traffic-inspector",i18nKey:"trafficInspector",subtitleKey:"trafficInspectorSubtitle",icon:"network_check"},{id:"discovery",href:"/dashboard/discovery",i18nKey:"discovery",subtitleKey:"discoverySubtitle",icon:"travel_explore"}]},{type:"group",id:"integrations",titleKey:"integrationsGroup",titleFallback:"Integrations",items:[{id:"api-endpoints",href:"/dashboard/api-endpoints",i18nKey:"apiEndpoints",subtitleKey:"apiEndpointsSubtitle",icon:"api"},{id:"webhooks",href:"/dashboard/webhooks",i18nKey:"webhooks",subtitleKey:"webhooksSubtitle",icon:"webhook"}]},{id:"proxy",href:"/dashboard/system/proxy",i18nKey:"proxy",subtitleKey:"proxySubtitle",icon:"dns"}]},{id:"analytics",titleKey:"analyticsSection",titleFallback:"Analytics",children:[{id:"analytics",href:"/dashboard/analytics",i18nKey:"usage",subtitleKey:"usageSubtitle",icon:"analytics"},{id:"analytics-combo-health",href:"/dashboard/analytics/combo-health",i18nKey:"analyticsComboHealth",subtitleKey:"analyticsComboHealthSubtitle",icon:"monitor_heart"},{id:"analytics-utilization",href:"/dashboard/analytics/utilization",i18nKey:"analyticsUtilization",subtitleKey:"analyticsUtilizationSubtitle",icon:"bar_chart"},{id:"cache",href:"/dashboard/cache",i18nKey:"cache",subtitleKey:"cacheSubtitle",icon:"cached"},{id:"analytics-compression",href:"/dashboard/analytics/compression",i18nKey:"analyticsCompression",subtitleKey:"analyticsCompressionSubtitle",icon:"compress"},{id:"analytics-search",href:"/dashboard/analytics/search",i18nKey:"analyticsSearch",subtitleKey:"analyticsSearchSubtitle",icon:"manage_search"},{id:"analytics-evals",href:"/dashboard/analytics/evals",i18nKey:"analyticsEvals",subtitleKey:"analyticsEvalsSubtitle",icon:"labs"},{id:"provider-stats",href:"/dashboard/provider-stats",i18nKey:"providerStats",subtitleKey:"providerStatsSubtitle",icon:"speed"}]},{id:"costs",titleKey:"costsSection",titleFallback:"Costs",children:[{id:"costs",href:"/dashboard/costs",i18nKey:"costsOverview",subtitleKey:"costsOverviewSubtitle",icon:"account_balance_wallet"},{id:"costs-pricing",href:"/dashboard/costs/pricing",i18nKey:"costsPricing",subtitleKey:"costsPricingSubtitle",icon:"price_change"},{id:"costs-budget",href:"/dashboard/costs/budget",i18nKey:"costsBudget",subtitleKey:"costsBudgetSubtitle",icon:"savings"},{id:"costs-free-tiers",href:"/dashboard/free-tiers",i18nKey:"costsFreeTiers",subtitleKey:"costsFreeTiersSubtitle",icon:"request_quote"},{id:"free-provider-rankings",href:"/dashboard/free-provider-rankings",i18nKey:"freeProviderRankings",subtitleKey:"freeProviderRankingsSubtitle",icon:"leaderboard"}]},{id:"monitoring",titleKey:"monitoringSection",titleFallback:"Monitoring",children:[{id:"activity",href:"/dashboard/activity",i18nKey:"activity",subtitleKey:"activitySubtitle",icon:"timeline"},{type:"group",id:"logs",titleKey:"logsGroup",titleFallback:"Logs",items:[{id:"logs",href:"/dashboard/logs",i18nKey:"logs",subtitleKey:"logsSubtitle",icon:"description"},{id:"logs-proxy",href:"/dashboard/logs/proxy",i18nKey:"logsProxy",subtitleKey:"logsProxySubtitle",icon:"lan"},{id:"logs-console",href:"/dashboard/logs/console",i18nKey:"consoleLogs",subtitleKey:"consoleLogsSubtitle",icon:"terminal"},{id:"logs-timeline",href:"/dashboard/logs/timeline",i18nKey:"logsTimeline",subtitleKey:"logsTimelineSubtitle",icon:"view_timeline"}]},{type:"group",id:"audit",titleKey:"auditGroup",titleFallback:"Audit",items:[{id:"audit",href:"/dashboard/audit",i18nKey:"auditLog",subtitleKey:"auditLogSubtitle",icon:"policy"},{id:"audit-mcp",href:"/dashboard/audit/mcp",i18nKey:"auditMcp",subtitleKey:"auditMcpSubtitle",icon:"security"},{id:"audit-a2a",href:"/dashboard/audit/a2a",i18nKey:"auditA2a",subtitleKey:"auditA2aSubtitle",icon:"device_hub"}]},{type:"group",id:"system",titleKey:"systemGroup",titleFallback:"System",items:[{id:"health",href:"/dashboard/health",i18nKey:"health",subtitleKey:"healthSubtitle",icon:"health_and_safety"},{id:"runtime",href:"/dashboard/runtime",i18nKey:"runtime",subtitleKey:"runtimeSubtitle",icon:"bolt"}]}]},{id:"devtools",titleKey:"devtoolsSection",titleFallback:"Dev Tools",children:[{id:"translator",href:"/dashboard/translator",i18nKey:"translator",subtitleKey:"translatorSubtitle",icon:"translate"},{id:"playground",href:"/dashboard/playground",i18nKey:"playground",subtitleKey:"playgroundSubtitle",icon:"science"},{id:"search-tools",href:"/dashboard/search-tools",i18nKey:"searchTools",subtitleKey:"searchToolsSubtitle",icon:"manage_search"}],visibility:"debug"},{id:"agentic-features",titleKey:"agenticFeaturesSection",titleFallback:"Agentic Features",children:[{id:"memory",href:"/dashboard/memory",i18nKey:"memory",subtitleKey:"memorySubtitle",icon:"psychology"},{id:"agent-skills",href:"/dashboard/agent-skills",i18nKey:"agentSkills",subtitleKey:"agentSkillsSubtitle",icon:"share"},{id:"chaos-config",href:"/dashboard/chaos",i18nKey:"chaosConfig",labelFallback:"Chaos Mode",subtitleKey:"chaosConfigSubtitle",subt
1itleFallback:"Multi-model parallel execution",icon:"blender"},{id:"skills",href:"/dashboard/omni-skills",i18nKey:"omniSkills",subtitleKey:"omniSkillsSubtitle",icon:"auto_fix_high"},{id:"mcp",href:"/dashboard/mcp",i18nKey:"mcp",subtitleKey:"mcpSubtitle",icon:"hub"},{id:"a2a",href:"/dashboard/a2a",i18nKey:"a2a",subtitleKey:"a2aSubtitle",icon:"device_hub"},{id:"plugins",href:"/dashboard/plugins",i18nKey:"plugins",subtitleKey:"pluginsSubtitle",icon:"extension"}]},{id:"other-features",titleKey:"otherFeaturesSection",titleFallback:"Other Features",children:[{type:"group",id:"gamification",titleKey:"gamificationGroup",titleFallback:"Gamification",items:[{id:"leaderboard",href:"/dashboard/leaderboard",i18nKey:"leaderboard",subtitleKey:"leaderboardSubtitle",icon:"emoji_events"},{id:"profile",href:"/dashboard/profile",i18nKey:"profile",subtitleKey:"profileSubtitle",icon:"person"},{id:"tokens",href:"/dashboard/tokens",i18nKey:"tokens",subtitleKey:"tokensSubtitle",icon:"toll"}]},{id:"media",href:"/dashboard/cache/media",i18nKey:"media",subtitleKey:"mediaSubtitle",icon:"perm_media"},{type:"group",id:"batch",titleKey:"batchGroup",titleFallback:"Batch",items:[{id:"batch",href:"/dashboard/batch",i18nKey:"batch",subtitleKey:"batchSubtitle",icon:"view_list"},{id:"batch-files",href:"/dashboard/batch/files",i18nKey:"batchFiles",subtitleKey:"batchFilesSubtitle",icon:"folder"}]}]},{id:"configuration",titleKey:"configurationSection",titleFallback:"Configuration",children:[{id:"settings-general",href:"/dashboard/settings/general",i18nKey:"settingsGeneral",subtitleKey:"settingsGeneralSubtitle",icon:"tune"},{id:"settings-appearance",href:"/dashboard/settings/appearance",i18nKey:"settingsAppearance",subtitleKey:"settingsAppearanceSubtitle",icon:"palette"},{id:"settings-ai",href:"/dashboard/settings/ai",i18nKey:"settingsAi",subtitleKey:"settingsAiSubtitle",icon:"auto_awesome"},{id:"settings-routing",href:"/dashboard/settings/routing",i18nKey:"globalRouting",subtitleKey:"globalRoutingSubtitle",icon:"route"},{id:"settings-resilience",href:"/dashboard/settings/resilience",i18nKey:"settingsResilience",subtitleKey:"settingsResilienceSubtitle",icon:"health_and_safety"},{id:"settings-advanced",href:"/dashboard/settings/advanced",i18nKey:"settingsAdvanced",subtitleKey:"settingsAdvancedSubtitle",icon:"engineering"},{id:"settings-security",href:"/dashboard/settings/security",i18nKey:"settingsSecurity",subtitleKey:"settingsSecuritySubtitle",icon:"shield"},{id:"settings-access-tokens",href:"/dashboard/settings/access-tokens",i18nKey:"settingsAccessTokens",labelFallback:"Access Tokens",subtitleKey:"settingsAccessTokensSubtitle",icon:"key"},{id:"settings-feature-flags",href:"/dashboard/settings/feature-flags",i18nKey:"settingsFeatureFlags",subtitleKey:"settingsFeatureFlagsSubtitle",icon:"flag"},{id:"settings-cache",href:"/dashboard/settings/cache",i18nKey:"settingsCache",subtitleKey:"settingsCacheSubtitle",icon:"memory"},{id:"settings-sidebar",href:"/dashboard/settings/sidebar",i18nKey:"settingsSidebar",subtitleKey:"settingsSidebarSubtitle",icon:"view_sidebar"}]},{id:"help",titleKey:"helpSection",titleFallback:"Help",children:[{id:"docs",href:"/docs",i18nKey:"docs",subtitleKey:"docsSubtitle",icon:"menu_book",external:!0},{id:"issues",href:"https://github.com/diegosouzapw/OmniRoute/issues",i18nKey:"issues",subtitleKey:"issuesSubtitle",icon:"bug_report",external:!0},{id:"changelog",href:"/dashboard/changelog",i18nKey:"changelog",subtitleKey:"changelogSubtitle",icon:"campaign"}]}];e.s(["SIDEBAR_SECTIONS",0,c],513859)},647829,799012,e=>{"use strict";var t=e.i(247167),s=e.i(843476),r=e.i(271645),a=e.i(522016),l=e.i(618566),i=e.i(156132),n=e.i(723790),o=e.i(462939),c=e.i(342923),d=e.i(80173),u=e.i(703166),m=e.i(948148);let x={connected:{icon:"cloud_done",color:"text-green-500",labelKey:"synced"},syncing:{icon:"cloud_sync",color:"text-blue-400 animate-pulse",labelKey:"syncing"},disconnected:{icon:"cloud_off",color:"text-amber-500",labelKey:"off"},error:{icon:"cloud_off",color:"text-red-400",labelKey:"error"},disabled:{icon:"cloud_off",color:"text-text-muted/50",labelKey:"disabled"}};function p({collapsed:e=!1}){let t=(0,m.useTranslations)("cloudSyncStatus"),[a,i]=(0,r.useState)("disabled"),[n,o]=(0,r.useState)(null),c=(0,r.useRef)(!0),d=(0,l.useRouter)(),u=(0,r.useCallback)(async()=>{try{let e=await fetch("/api/sync/cloud");if(!c.current)return;if(!e.ok)return void i("disconnected");let t=await e.json();if(!c.current)return;t.enabled?t.syncing?i("syncing"):t.connected?(i("connected"),t.lastSync&&o(new Date(t.lastSync))):i("disconnected"):i("disabled")}catch{c.current&&i("disconnected")}},[]);if((0,r.useEffect)(()=>{c.current=!0,queueMicrotask(u);let e=setInterval(u,3e4),t=()=>{setTimeout(u,500)};return globalThis.addEventListener("cloud-status-changed",t),()=>{c.current=!1,clearInterval(e),globalThis.removeEventListener("cloud-status-changed",t)}},[u]),"disabled"===a)return null;let h=x[a],b=t(h.labelKey);return(0,s.jsxs)("button",{onClick:()=>d.push("/dashboard/endpoint"),className:"flex items-center gap-2 px-3 py-1.5 text-xs rounded-lg hover:bg-white/5 transition-colors cursor-pointer w-full",title:n?t("lastSync",{status:t("connected"===a?"connected":"disconnected"),time:n.toLocaleTimeString()}):b,"aria-label":t("statusLabel",{status:b}),children:[(0,s.jsx)("span",{className:`material-symbols-outlined text-[16px] ${h.color}`,"aria-hidden":"true",children:h.icon}),!e&&(0,s.jsx)("span",{className:`truncate ${"connected"===a?"text-green-500":"text-text-muted"}`,children:b})]})}let h=["compression-context","tools","integrations","logs","audit","system","gam
1ification","batch"],b="hiddenSidebarGroupLabels";function f(e){if(!Array.isArray(e))return[];let t=new Set;for(let s of e)"string"==typeof s&&h.includes(s)&&t.add(s);return h.filter(e=>t.has(e))}e.s(["HIDDEN_SIDEBAR_GROUP_LABELS_SETTING_KEY",0,b,"HIDEABLE_SIDEBAR_GROUP_IDS",0,h,"normalizeHiddenSidebarGroupLabels",0,f],799012);var g=e.i(241937),y=e.i(513859);let v="1"===t.default.env.NEXT_PUBLIC_OMNIROUTE_E2E_MODE,j="omni-proxy",k="sidebar-expanded-sections",N="sidebar-pinned-sections";function w(e,t){try{localStorage.setItem(e,JSON.stringify(t))}catch{}}e.s(["default",0,function({onClose:e,collapsed:t=!1,onToggleCollapse:x,isMacElectron:h=!1}){let S=(0,l.usePathname)(),C=(0,m.useTranslations)("sidebar"),T=(0,m.useTranslations)("common"),E=(0,r.useRef)(null),[_,I]=(0,r.useState)(!1),[A,D]=(0,r.useState)(!1),[K,L]=(0,r.useState)(!1),[M,O]=(0,r.useState)(!1),[R,F]=(0,r.useState)(!1),[P,$]=(0,r.useState)(!1),[z,B]=(0,r.useState)([]),[U,q]=(0,r.useState)([]),[W,H]=(0,r.useState)([]),[G,J]=(0,r.useState)({}),[Y,V]=(0,r.useState)(null),[X,Q]=(0,r.useState)(null),[Z,ee]=(0,r.useState)(new Set([j])),[et,es]=(0,r.useState)(new Set),[er,ea]=(0,r.useState)(!1),el=(0,r.useRef)(!1),[ei,en]=(0,r.useState)(null),[eo,ec]=(0,r.useState)("");(0,r.useEffect)(()=>{let e=function(e,t){try{let t=localStorage.getItem(e);if(t){let e=JSON.parse(t);if(Array.isArray(e))return e}}catch{}return t}(k,[j]),t=(()=>{try{return localStorage.getItem(N)}catch{return null}})(),s=new Set(null!==t?JSON.parse(t):y.SIDEBAR_SECTIONS.filter(e=>e.defaultPinned).map(e=>e.id)),r=new Set([...e,...s]);el.current=0===e.length,ee(r),es(s),ea(!0)},[]),(0,r.useEffect)(()=>{fetch("/api/settings").then(e=>e.json()).then(e=>{$(e?.debugMode===!0),B((0,g.normalizeHiddenSidebarItems)(e?.[g.HIDDEN_SIDEBAR_ITEMS_SETTING_KEY])),q(f(e?.[b])),V(e?.instanceName||null),Q(e?.customLogoBase64||e?.customLogoUrl||null),Array.isArray(e?.[g.SIDEBAR_SECTION_ORDER_KEY])&&H(e[g.SIDEBAR_SECTION_ORDER_KEY]),e?.[g.SIDEBAR_ITEM_ORDER_KEY]&&"object"==typeof e[g.SIDEBAR_ITEM_ORDER_KEY]&&J(e[g.SIDEBAR_ITEM_ORDER_KEY])}).catch(()=>{});let e=e=>{let t=e.detail||{};"debugMode"in t&&$(!0===t.debugMode),g.HIDDEN_SIDEBAR_ITEMS_SETTING_KEY in t&&B((0,g.normalizeHiddenSidebarItems)(t[g.HIDDEN_SIDEBAR_ITEMS_SETTING_KEY])),b in t&&q(f(t[b])),g.SIDEBAR_SECTION_ORDER_KEY in t&&Array.isArray(t[g.SIDEBAR_SECTION_ORDER_KEY])&&H(t[g.SIDEBAR_SECTION_ORDER_KEY]),g.SIDEBAR_ITEM_ORDER_KEY in t&&t[g.SIDEBAR_ITEM_ORDER_KEY]&&"object"==typeof t[g.SIDEBAR_ITEM_ORDER_KEY]&&J(t[g.SIDEBAR_ITEM_ORDER_KEY]),"instanceName"in t&&V(t.instanceName||null),"customLogoBase64"in t?Q(t.customLogoBase64||null):"customLogoUrl"in t&&Q(t.customLogoUrl||null)};return window.addEventListener(g.SIDEBAR_SETTINGS_UPDATED_EVENT,e),()=>window.removeEventListener(g.SIDEBAR_SETTINGS_UPDATED_EVENT,e)},[]);let ed=(e,t)=>"function"==typeof C.has&&C.has(e)?C(e):t,eu=(e,t)=>{if(t.has(e.id))return null;let s=e.subtitleKey?ed(e.subtitleKey,e.subtitleFallback??""):e.subtitleFallback;return{...e,label:ed(e.i18nKey,e.labelFallback??e.id),subtitle:s||void 0}},em=new Set(z),ex=new Set(U),ep=(0,g.applySectionOrder)(y.SIDEBAR_SECTIONS.filter(e=>"debug"!==e.visibility||P),W).map(e=>{let t=(0,g.applyItemOrder)(e.children,G[e.id]??[]).map(e=>{if("type"in e&&"group"===e.type){let t=e.items.map(e=>eu(e,em)).filter(Boolean);return 0===t.length?null:1===t.length?t[0]:{...e,title:ed(e.titleKey,e.titleFallback),separatorHidden:ex.has(e.id),items:t}}return eu(e,em)}).filter(Boolean);return{...e,title:ed(e.titleKey,e.titleFallback),children:t}}).filter(e=>e.children.flatMap(e=>"group"===e.type?e.items:[e]).length>0),eh=function(e,t){let s=null;for(let r of t)if(!r.external&&function(e,t,s=!1){return!!e&&(s?e===t:e===t||e.startsWith(`${t}/`))}(e,r.href,!0===r.exact)){if(!s||r.href.length>s.href.length){s=r;continue}r.href.length===s.href.length&&r.exact&&!s.exact&&(s=r)}return s?.href||null}(S,ep.flatMap(e=>e.children.flatMap(e=>"group"===e.type?e.items:[e]))),eb=eo.trim().length>0,ef=eb?function(e,t){let s=t.trim().toLowerCase();if(!s)return[...e];let r=e=>e.label.toLowerCase().includes(s),a=[];for(let t of e){let e=[];for(let s of t.children)if("object"==typeof s&&null!==s&&"type"in s&&"group"===s.type){let t=s.items.filter(r);t.length>0&&e.push({...s,items:t})}else r(s)&&e.push(s);e.length>0&&a.push({...t,children:e})}return a}(ep,eo):ep;(0,r.useEffect)(()=>
1{if(!t&&er){if(el.current){el.current=!1;return}for(let e of ep)if(e.children.flatMap(e=>"group"===e.type?e.items:[e]).some(e=>!e.external&&e.href===eh)){ee(t=>{let s=new Set([...et,e.id]);return[...s].every(e=>t.has(e))&&s.size===t.size?t:(w(k,[...s]),s)});break}}},[eh,t,et,er]);let eg=(0,r.useCallback)(e=>{ee(t=>{let s=function(e,t,s){if(e.has(s)){let t=new Set(e);return t.delete(s),t}return new Set([...t,s])}(t,et,e);return w(k,[...s]),s})},[et]),ey=(0,r.useCallback)(e=>{es(t=>{let s=new Set(t);return s.has(e)?s.delete(e):(s.add(e),ee(t=>{if(t.has(e))return t;let s=new Set(t);return s.add(e),w(k,[...s]),s})),w(N,[...s]),s})},[]),ev=async()=>{L(!0);try{await fetch("/api/shutdown",{method:"POST"})}catch(e){}L(!1),I(!1),F(!0)},ej=async()=>{O(!0);try{await fetch("/api/restart",{method:"POST"})}catch(e){}O(!1),D(!1),F(!0),setTimeout(()=>globalThis.location.reload(),3e3)},ek=(0,r.useCallback)((e,s,r)=>{if(!t)return;let a=e.currentTarget.getBoundingClientRect(),l=E.current?.getBoundingClientRect();en({id:s,label:r,x:(l?.right??64)+8,y:a.top+a.height/2})},[t]),eN=(0,r.useCallback)(()=>en(null),[]),ew=r=>{var l;let n,o=!r.external&&eh===r.href,c=(0,i.cn)("flex items-center gap-3 rounded-lg transition-all group",t?"justify-center px-2 py-2.5":"px-3 py-1.5",o?"bg-primary/10 text-primary":"text-text-muted hover:bg-surface/50 hover:text-text-main"),d=(0,i.cn)("material-symbols-outlined text-[18px] shrink-0",o?"fill-1":"group-hover:text-primary transition-colors"),u=(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("span",{className:d,style:(l=r.id,{"--sidebar-icon-accent":n=(0,g.getSidebarIconAccent)(l),color:n}),children:r.icon}),!t&&(0,s.jsxs)("div",{className:"flex min-w-0 flex-col",children:[(0,s.jsx)("span",{className:"truncate text-sm font-medium",children:r.label}),r.subtitle&&(0,s.jsx)("span",{className:"truncate text-[10px] text-text-muted/60",children:r.subtitle})]})]}),m={onMouseEnter:e=>ek(e,r.id,r.label),onMouseLeave:eN};return r.external?(0,s.jsx)("a",{href:r.href,target:"_blank",rel:"noopener noreferrer",onClick:e,className:c,...m,children:u},r.href):(0,s.jsx)(a.default,{href:r.href,prefetch:!1,onClick:e,className:c,...m,children:u},r.href)};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("aside",{ref:E,className:(0,i.cn)("flex h-full min-h-0 flex-col border-r border-black/5 bg-sidebar transition-all duration-300 ease-in-out dark:border-white/5",t?"w-16":"w-[220px]"),style:{paddingTop:h?"var(--desktop-safe-top)":void 0},children:[(0,s.jsx)("a",{href:"#main-content",className:"sr-only focus:not-sr-only focus:absolute focus:z-50 focus:p-3 focus:bg-primary focus:text-white focus:rounded-md focus:m-2",children:C("skipToContent")}),(x||!h)&&(0,s.jsxs)("div",{className:(0,i.cn)("flex items-center gap-2 pb-2",h?"pt-3":"pt-5",t?"px-3 justify-center":"px-4"),"aria-hidden":"true",children:[!h&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("div",{className:"w-3 h-3 rounded-full bg-[#FF5F56]"}),(0,s.jsx)("div",{className:"w-3 h-3 rounded-full bg-[#FFBD2E]"}),(0,s.jsx)("div",{className:"w-3 h-3 rounded-full bg-[#27C93F]"})]}),!t&&(0,s.jsx)("div",{className:"flex-1"}),x&&(0,s.jsx)("button",{onClick:x,title:t?C("expandSidebar"):C("collapseSidebar"),"aria-expanded":!t,"aria-label":t?C("expandSidebar"):C("collapseSidebar"),className:(0,i.cn)("rounded-md p-1 text-text-muted/50 transition-colors hover:bg-black/5 hover:text-text-muted dark:hover:bg-white/5",t&&!h&&"mt-2",h&&"ms-auto"),children:(0,s.jsx)("span",{className:"material-symbols-outlined text-[16px]","aria-hidden":"true",children:t?"chevron_right":"chevron_left"})})]}),(0,s.jsx)("div",{className:(0,i.cn)("py-3",t?"px-2":"px-4"),children:(0,s.jsxs)(a.default,{href:"/home",prefetch:!1,className:(0,i.cn)("flex items-center",t?"justify-center":"gap-2.5"),children:[(0,s.jsx)("div",{className:"flex items-center justify-center size-8 rounded bg-linear-to-br from-[#E54D5E] to-[#C93D4E] shrink-0",children:X?(0,s.jsx)("img",{src:X,alt:Y||n.APP_CONFIG.name,className:"size-5 object-contain"}):(0,s.jsx)(o.default,{size:18,className:"text-white"})}),!t&&(0,s.jsxs)("div",{className:"flex flex-col min-w-0",children:[(0,s.jsx)("h1",{className:"text-sm font-semibold tracking-tight text-text-main truncate",children:Y||n.APP_CONFIG.name}),(0,s.jsxs)("span",{className:"text-[10px] text-text-muted",children:["v",n.APP_CONFIG.version]})]})]})}),!t&&(0,s.jsx)("div",{className:"px-4 pb-2",children:(0,s.jsx)(d.default,{type:"search",value:eo,onChange:e=>ec(e.target.value),placeholder:T("search"),"aria-label":T("search"),icon:"search",className:"gap-0",inputClassName:"py-1.5 text-xs"})}),(0,s.jsxs)("nav",{"aria-label":C("mainNavigation"),className:(0,i.cn)("min-h-0 flex-1 overflow-y-auto py-1 custom-scrollbar",t?"px-2 space-y-0.5":"px-3"),children:[eb&&0===ef.length&&(0,s.jsx)("p",{className:"px-2 py-3 text-xs text-text-muted/60",children:T("noResults")}),ef.map((e,r)=>{let a=e.id,l=eb||Z.has(a),n=et.has(a),o=0===r,c=e.children.flatMap(e=>"group"===e.type?e.items:[e]);
1return t?(0,s.jsxs)("div",{children:[!o&&(0,s.jsx)("div",{className:"border-t border-black/5 dark:border-white/5 my-1.5"}),c.map(ew)]},e.id):!1===e.showTitle?(0,s.jsx)("div",{className:(0,i.cn)("space-y-0.5",!o&&"mt-1"),children:c.map(ew)},e.id):(0,s.jsxs)("div",{className:o?"space-y-0.5":"mt-2",children:[(0,s.jsxs)("div",{className:"flex items-center gap-0.5 px-2 py-1 rounded-md hover:bg-surface/30 transition-colors cursor-pointer group/header",onClick:()=>eg(a),role:"button","aria-expanded":l,children:[(0,s.jsx)("span",{className:"flex-1 text-[10px] font-semibold text-text-muted/60 uppercase tracking-wider group-hover/header:text-text-muted/90 transition-colors",children:e.title}),(0,s.jsx)("button",{onClick:e=>{e.stopPropagation(),ey(a)},title:n?C("unpinSection"):C("pinSectionOpen"),className:(0,i.cn)("p-0.5 rounded transition-all shrink-0",n?"text-primary opacity-100":"text-text-muted/30 opacity-0 group-hover/header:opacity-100 hover:text-text-muted/70"),children:(0,s.jsx)("span",{className:"material-symbols-outlined",style:{fontSize:"10px",...n?{fontVariationSettings:"'FILL' 1"}:{}},children:"push_pin"})}),(0,s.jsx)("span",{className:(0,i.cn)("material-symbols-outlined text-[14px] text-text-muted/40 transition-all duration-200 group-hover/header:text-text-muted/70 shrink-0",l&&"rotate-180"),children:"expand_more"})]}),l&&(0,s.jsx)("div",{className:"mt-0.5 space-y-0.5",children:e.children.map(e=>{if("group"===e.type){if(0===e.items.length)return null;let t=!0===e.separatorHidden;return(0,s.jsxs)("div",{className:t?"mt-0.5":"mt-2",children:[!t&&(0,s.jsxs)("div",{className:"flex items-center gap-1.5 px-2 py-0.5 mb-0.5",children:[(0,s.jsx)("div",{className:"h-px flex-1 bg-black/8 dark:bg-white/8"}),(0,s.jsx)("span",{className:"text-[8px] font-semibold text-text-muted/40 uppercase tracking-widest",children:e.title})]}),e.items.map(ew)]},e.id)}return ew(e)})})]},e.id)})]}),!v&&(0,s.jsx)(p,{collapsed:t}),(0,s.jsxs)("div",{className:(0,i.cn)("shrink-0 border-t border-black/5 dark:border-white/5",t?"p-2 flex flex-col gap-1":"p-2 flex gap-2"),style:{paddingBottom:h?"calc(0.5rem + var(--desktop-safe-bottom))":void 0},children:[(0,s.jsxs)("button",{onClick:()=>D(!0),title:C("restart"),className:(0,i.cn)("flex items-center justify-center gap-2 rounded-lg font-medium transition-all","text-amber-500 hover:bg-amber-500/10 border border-amber-500/20 hover:border-amber-500/40",t?"p-2":"flex-1 min-w-0 px-2 py-1.5 text-xs"),children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"restart_alt"}),!t&&(0,s.jsx)("span",{className:"truncate",children:C("restart")})]}),(0,s.jsxs)("button",{onClick:()=>I(!0),title:C("shutdown"),className:(0,i.cn)("flex items-center justify-center gap-2 rounded-lg font-medium transition-all","text-red-500 hover:bg-red-500/10 border border-red-500/20 hover:border-red-500/40",t?"p-2":"flex-1 min-w-0 px-2 py-1.5 text-xs"),children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"power_settings_new"}),!t&&(0,s.jsx)("span",{className:"truncate",children:C("shutdown")})]})]})]}),t&&ei&&(0,s.jsxs)("div",{className:"fixed z-[200] pointer-events-none flex items-center",style:{left:ei.x,top:ei.y,transform:"translateY(-50%)"},children:[(0,s.jsx)("div",{className:"w-0 h-0 border-t-[5px] border-b-[5px] border-r-[6px] border-t-transparent border-b-transparent border-r-sidebar dark:border-r-sidebar"}),(0,s.jsx)("div",{className:"px-2.5 py-1.5 bg-sidebar text-text-main text-xs font-medium rounded-md shadow-lg border border-black/10 dark:border-white/10 whitespace-nowrap",children:ei.label})]}),(0,s.jsx)(u.ConfirmModal,{isOpen:_,onClose:()=>I(!1),onConfirm:ev,title:C("shutdown"),message:C("shutdownConfirm"),confirmText:C("shutdown"),cancelText:T("cancel"),variant:"danger",loading:K}),(0,s.jsx)(u.ConfirmModal,{isOpen:A,onClose:()=>D(!1),onConfirm:ej,title:C("restart"),message:C("restartConfirm"),confirmText:C("restart"),cancelText:T("cancel"),variant:"warning",loading:M}),R&&(0,s.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/80 backdrop-blur-sm",children:(0,s.jsxs)("div",{className:"text-center p-8",children:[(0,s.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,s.jsx)("span",{className:"material-symbols-outlined text-[32px]",children:"power_off"})}),(0,s.jsx)("h2",{className:"text-xl font-semibold text-white mb-2",children:C("serverDisconnected")}),(0,s.jsx)("p",{className:"text-text-muted mb-6",children:C("serverDisconnectedMsg")}),(0,s.jsx)(c.default,{variant:"secondary",onClick:()=>globalThis.location.reload(),children:C("reloadPage")})]})})]})}],647829)},932993,31954,e=>{"use strict";var t=e.i(843476),s=e.i(948148),r=e.i(271645),a=e.i(922686);let l={healthy:{icon:"check_circle",color:a.STATUS_HEX.success,tooltip:"All tokens healthy"},warning:{icon:"warning",color:a.STATUS_HEX.warning,tooltip:"Some tokens need attention"},error:{icon:"error",color:a.STATUS_HEX.error,tooltip:"Token refresh failures detected"},unknown:{icon:"help",color:a.STATUS_HEX.muted,tooltip:"Health status unknown"}};e.s(["default",0,function(){let e=(0,s.useTranslations)("stats"),[a,i]=(0,r.useState)(null),[n,o]=(0,r.useState)(!1);if((0,r.useEffect)(()=>{let e=async()=>{try{let e=await fetch("/api/token-health");if(e.ok){let t=await e.json();i(t)}}catch{}};e();let t=setInterval(e,6e4);return()=>clearInterval(t)},[]),!a||0===a.total)return null;
1let c=l[a.status]||l.unknown;return(0,t.jsxs)("div",{className:"relative",onMouseEnter:()=>o(!0),onMouseLeave:()=>o(!1),children:[(0,t.jsxs)("button",{className:"flex items-center gap-1 px-2 py-1.5 rounded-lg hover:bg-surface/30 transition-colors",title:c.tooltip,children:[(0,t.jsx)("span",{className:"material-symbols-outlined text-[18px]",style:{color:c.color},children:c.icon}),a.errored>0&&(0,t.jsx)("span",{className:"text-xs font-medium",style:{color:c.color},children:a.errored})]}),n&&(0,t.jsxs)("div",{className:"absolute top-full right-0 mt-1 z-50 min-w-[200px] p-3 rounded-lg shadow-lg",style:{background:"rgba(15, 15, 25, 0.95)",border:"1px solid rgba(255,255,255,0.1)",backdropFilter:"blur(12px)"},children:[(0,t.jsx)("p",{className:"text-xs font-medium text-text-main mb-2",children:e("tokenHealth")}),(0,t.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,t.jsxs)("div",{className:"flex justify-between",children:[(0,t.jsx)("span",{className:"text-text-muted",children:e("totalOAuth")}),(0,t.jsx)("span",{className:"text-text-main",children:a.total})]}),(0,t.jsxs)("div",{className:"flex justify-between",children:[(0,t.jsx)("span",{className:"text-emerald-400",children:e("healthy")}),(0,t.jsx)("span",{className:"text-text-main",children:a.healthy})]}),a.errored>0&&(0,t.jsxs)("div",{className:"flex justify-between",children:[(0,t.jsx)("span",{className:"text-red-400",children:e("errored")}),(0,t.jsx)("span",{className:"text-text-main",children:a.errored})]}),a.warning>0&&(0,t.jsxs)("div",{className:"flex justify-between",children:[(0,t.jsx)("span",{className:"text-amber-400",children:e("warning")}),(0,t.jsx)("span",{className:"text-text-main",children:a.warning})]}),a.lastCheckAt&&(0,t.jsxs)("div",{className:"flex justify-between mt-1 pt-1 border-t border-white/5",children:[(0,t.jsx)("span",{className:"text-text-muted",children:e("lastCheck")}),(0,t.jsx)("span",{className:"text-text-muted",children:new Date(a.lastCheckAt).toLocaleTimeString()})]})]})]})]})}],932993);var i=e.i(522016);e.s(["default",0,function(){let[e,a]=(0,r.useState)(!1),l=(0,s.useTranslations)("common");return((0,r.useEffect)(()=>{let e=async()=>{try{let e=await fetch("/api/health/degradation?summary=true");if(e.ok){let t=await e.json();a(t.isDegraded)}}catch(e){}};e();let t=setInterval(e,6e4);return()=>clearInterval(t)},[]),e)?(0,t.jsxs)(i.default,{href:"/dashboard/health",className:"flex items-center gap-1.5 px-2.5 py-1 rounded-md bg-amber-500/10 text-amber-500 hover:bg-amber-500/20 transition-colors border border-amber-500/20",title:l("warning"),children:[(0,t.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"healing"}),(0,t.jsx)("span",{className:"text-xs font-semibold whitespace-nowrap",children:"Degraded"})]}):null}],31954)},70552,e=>{"use strict";var t=e.i(271645);function s(){return window.electronAPI?.isElectron===!0}function r(){return!1}let a=()=>()=>{};function l(){return(0,t.useSyncExternalStore)(a,s,r)}e.s(["useIsElectron",0,l,"useOpenExternal",0,function(){let e=l();return{openExternal:(0,t.useCallback)(async t=>{e&&window.electronAPI?await window.electronAPI.openExternal(t):window.open(t,"_blank","noopener,noreferrer")},[e])}}])},6998,e=>{"use strict";var t=e.i(247167),s=e.i(843476),r=e.i(271645),a=e.i(618566),l=e.i(897844),i=e.i(932993),n=e.i(31954),o=e.i(156221),c=e.i(393162),d=e.i(948148),u=e.i(928491),m=e.i(228688),x=e.i(914147),p=e.i(537698),h=e.i(241937),b=e.i(513859),f=e.i(70552);let g=()=>()=>{},y=()=>
1{if("u"<typeof navigator)return!1;let e=navigator.platform||navigator.userAgent;return/Mac|iPhone|iPad|iPod/.test(e)},v=()=>!1,j="1"===t.default.env.NEXT_PUBLIC_OMNIROUTE_E2E_MODE,k={home:"homeDescription",endpoints:"endpointDescription","api-manager":"apiManagerDescription",providers:"providerDescription",combos:"comboDescription",batch:"batchDescription",costs:"costsDescription",analytics:"analyticsDescription",cache:"cacheDescription",quota:"limitsDescription",runtime:"runtimeDescription",media:"mediaDescription","cli-code":"cliToolsDescription","cli-agents":"agentsDescription","acp-agents":"agentsDescription","cloud-agents":"cloudAgentsDescription",memory:"memoryDescription",skills:"skillsDescription","agent-skills":"agentSkillsDescription","omni-skills":"omniSkillsDescription",settings:"settingsDescription","context-caveman":"contextCavemanDescription","context-rtk":"contextRtkDescription","context-combos":"contextCombosDescription",translator:"translatorDescription",playground:"playgroundDescription","search-tools":"searchToolsDescription",logs:"logsDescription",audit:"auditDescription",webhooks:"webhooksDescription",health:"healthDescription",proxy:"proxyDescription",changelog:"changelogDescription",mcp:"mcpDescription",a2a:"a2aDescription","api-endpoints":"apiEndpointsDescription","batch-files":"batchFilesDescription","analytics-evals":"analyticsEvalsDescription","analytics-search":"analyticsSearchDescription","analytics-utilization":"analyticsUtilizationDescription","analytics-combo-health":"analyticsComboHealthDescription","analytics-compression":"analyticsCompressionDescription","costs-budget":"costsBudgetDescription","costs-pricing":"costsPricingDescription","logs-proxy":"logsProxyDescription","logs-console":"logsConsoleDescription","logs-activity":"logsActivityDescription","audit-mcp":"auditMcpDescription","settings-general":"settingsGeneralDescription","settings-appearance":"settingsAppearanceDescription","settings-ai":"settingsAiDescription","settings-security":"settingsSecurityDescription","settings-routing":"settingsRoutingDescription","settings-resilience":"settingsResilienceDescription","settings-cache":"settingsCacheDescription","settings-advanced":"settingsAdvancedDescription","mitm-proxy":"mitmProxyDescription","1proxy":"oneProxyDescription"},N=new Map;for(let e of b.SIDEBAR_SECTIONS)for(let t of(0,h.getSectionItems)(e))t.external||N.set(t.href,t);e.s(["default",0,function({onMenuClick:e,onOpenCommandPalette:t,showMenuButton:h=!0}){let b=(0,r.useSyncExternalStore)(g,y,v),w=(0,a.usePathname)(),S=(0,a.useRouter)(),C=(0,f.useIsElectron)(),T=(0,d.useTranslations)("header"),{title:E,description:_,icon:I,providerId:A}=function(e){let t=(0,d.useTranslations)("sidebar"),s=(0,d.useTranslations)("header");if(!e)return{title:"",description:""};let r=e.match(/\/providers\/([^/]+)$/);if(r){let e=r[1],t=m.OAUTH_PROVIDERS[e]||p.NOAUTH_PROVIDERS[e]||x.APIKEY_PROVIDERS[e];if(t)return{title:t.name,description:"",providerId:t.id};if(e.startsWith(u.CLAUDE_CODE_COMPATIBLE_PREFIX))return{title:"CC Compatible",description:"",providerId:"claude"};if(e.startsWith(u.OPENAI_COMPATIBLE_PREFIX))return{title:s("openaiCompatible"),description:"",providerId:"oai-cc"};if(e.startsWith(u.ANTHROPIC_COMPATIBLE_PREFIX))return{title:s("anthropicCompatible"),description:"",providerId:"anthropic-m"}}let a=function(e){let t,s=N.get(e);if(s)return s;let r=0;for(let[s,a]of N)e.startsWith(s)&&s.length>r&&(t=a,r=s.length);return t}(e);if(a){let e=k[a.id];return{title:t(a.i18nKey),description:e?s(e):"",icon:a.icon}}return{title:"",description:""}}(w),D=C&&window.electronAPI?.platform==="darwin",K=async()=>{try{(await fetch("/api/auth/logout",{method:"POST"})).ok&&(S.push("/login"),S.refresh())}catch(e){console.error("Failed to logout:",e)}};return(0,s.jsxs)("header",{className:"sticky top-0 z-10 flex items-center justify-between border-b border-black/5 bg-bg px-8 py-4 dark:border-white/5",style:{paddingTop:D?"calc(1rem + var(--desktop-safe-top))":void 0},children:[(0,s.jsx)("div",{className:"flex items-center gap-3 lg:hidden",children:h&&(0,s.jsx)("button",{onClick:e,className:"text-text-main hover:text-primary transition-colors",children:(0,s.jsx)("span",{className:"material-symbols-outlined",children:"menu"})})}),(0,s.jsxs)("div",{className:"hidden lg:flex items-center gap-3",children:[(I||A)&&(0,s.jsx)("div",{className:"flex items-center justify-center size-9 rounded-lg bg-primary/10 shrink-0",children:I?(0,s.jsx)("span",{className:"material-symbols-outlined text-primary text-[20px]",children:I}):A&&(0,s.jsx)(c.default,{providerId:A,size:22,type:"color"})}),E&&(0,s.jsxs)("div",{children:[(0,s.jsx)("h1",{className:"text-xl font-semibold text-text-main tracking-tight",children:E}),_&&(0,s.jsx)("p",{className:"text-xs text-text-muted mt-0.5",children:_})]})]}),(0,s.jsxs)("div",{className:"flex items-center gap-3 ml-auto",children:[t&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("button",{type:"button",onClick:t,className:"hidden md:inline-flex items-center gap-2 px-2.5 py-1.5 rounded-lg border border-black/10 dark:border-white/10 bg-bg-subtle text-text-muted hover:text-text-main hover:bg-black/[0.04] dark:hover:bg-white/[0.04] transition-colors",title:T("quickNavigationTitle"),"aria-label":T("openQuickNavigation"),children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"search"}),(0,s.jsx)("span",{className:"text-xs",children:T("quickNavigation")}),(0,s.jsx)("kbd",{className:"hidden lg:inline-flex font-mono text-[10px] px-1 py-0.5 rounded bg-black/5 dark:bg-white/5 border border-black/10 dark:border-white/10",children:b?"âK":"Ctrl+K"})]}),(0,s.jsx)("button",{type:"button",onClick:t,className:"md:hidden p-2 rounded-lg text-text-muted hover:text-text-main hover:bg-black/5 dark:hover:bg-white/5 transition-colors","aria-label":T("openQuickNavigation"),children:(0,s.jsx)("span",{className:"material-symbols-outlined",children:"search"})})]}),(0,s.jsx)(o.default,{}),(0,s.jsx)(l.default,{}),!j&&(0,s.jsx)(n.default,{}),!j&&(0,s.jsx)(i.default,{}),(0,s.jsx)("button",{onClick:K,className:"flex items-center justify-center p-2 rounded-lg text-text-muted hover:text-red-500 hover:bg-red-500/10 transition-all",title:T("logout"),"aria-label":T("logout"),children:(0,s.jsx)("span",{className:"material-symbols-outlined",children:"logout"})})]})]})}])},982131,e=>{"use strict";var t=e.i(843476),s=e.i(948148),r=e.i(522016),a=e.i(723790);let l=[{label:"Features",href:"#features"},{label:"Pricing",href:"#pricing"},{label:"Changelog",href:"https://github.com/diegosouzapw/OmniRoute/releases",external:!0}],i=[{label:"Documentation",href:"/docs"},{label:"API Reference",href:"/docs#api-reference"},{label:"Help Center",href:"https://github.com/diegosouzapw/OmniRoute/discussions",external:!0}],n=[{label:"About",href:"https://github.com/diegosouzapw/OmniRoute",external:!0},{label:"Blog",href:"https://github.com/diegosouzapw/OmniRoute/releases",external:!0},{label:"Contact",href:"https://github.com/diegosouzapw/OmniRoute/issues/new/choose",external:!0},{label:"Terms",href:"/terms"},{label:"Privacy",href:"/privacy"}];e.s(["default",0,function(){let e=(0,s.useTranslations)("stats"),o=e=>e.external?(0,t.jsx)("a",{href:e.href,target:"_blank",rel:"noopener noreferrer",className:"hover:text-primary transition-colors",children:e.label}):(0,t.jsx)(r.default,{href:e.href,className:"hover:text-primary transition-colors",children:e.label});return(0,t.jsx)("footer",{className:"bg-bg border-t border-border pt-16 pb-12",children:(0,t.jsxs)("div",{className:"container mx-auto px-4 sm:px-6 lg:px-8",children:[(0,t.jsxs)("div",{className:"grid grid-cols-2 md:grid-cols-4 lg:grid-cols-5 ga
1p-10 mb-12",children:[(0,t.jsxs)("div",{className:"col-span-2 lg:col-span-2",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 mb-6",children:[(0,t.jsx)("div",{className:"size-6 text-primary",children:(0,t.jsx)("svg",{className:"w-full h-full",fill:"currentColor",viewBox:"0 0 48 48",children:(0,t.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,t.jsx)("span",{className:"text-xl font-bold text-text-main",children:a.APP_CONFIG.name})]}),(0,t.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,t.jsxs)("div",{className:"flex gap-4",children:[(0,t.jsx)("a",{href:"https://github.com/diegosouzapw/OmniRoute/discussions",target:"_blank",rel:"noopener noreferrer",className:"text-gray-400 hover:text-primary transition-colors","aria-label":"Community Discussions",children:(0,t.jsx)("svg",{className:"w-5 h-5",fill:"currentColor",viewBox:"0 0 24 24",children:(0,t.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,t.jsx)("a",{href:"https://github.com/diegosouzapw/OmniRoute",target:"_blank",rel:"noopener noreferrer",className:"text-gray-400 hover:text-primary transition-colors","aria-label":"GitHub",children:(0,t.jsx)("svg",{className:"w-5 h-5",fill:"currentColor",viewBox:"0 0 24 24",children:(0,t.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,t.jsxs)("div",{children:[(0,t.jsx)("h4",{className:"font-semibold text-text-main mb-4",children:e("product")}),(0,t.jsx)("ul",{className:"flex flex-col gap-3 text-sm text-text-muted font-light",children:l.map(e=>(0,t.jsx)("li",{children:o(e)},e.label))})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("h4",{className:"font-semibold text-text-main mb-4",children:e("resources")}),(0,t.jsx)("ul",{className:"flex flex-col gap-3 text-sm text-text-muted font-light",children:i.map(e=>(0,t.jsx)("li",{children:o(e)},e.label))})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("h4",{className:"font-semibold text-text-main mb-4",children:e("company")}),(0,t.jsx)("ul",{className:"flex flex-col gap-3 text-sm text-text-muted font-light",children:n.map(e=>(0,t.jsx)("li",{children:o(e)},e.label))})]})]}),(0,t.jsxs)("div",{className:"border-t border-border pt-8 flex flex-col md:flex-row justify-between items-center gap-4",children:[(0,t.jsxs)("p",{className:"text-sm text-text-muted",children:["© ",new Date().getFullYear()," ",a.APP_CONFIG.name," Inc. All rights reserved."]}),(0,t.jsxs)("div",{className:"flex gap-6 text-sm text-text-muted",children:[(0,t.jsx)(r.default,{href:"/docs",className:"hover:text-primary transition-colors",children:"Documentation"}),(0,t.jsx)(r.default,{href:"/terms",className:"hover:text-primary transition-colors",children:"Terms"}),(0,t.jsx)(r.default,{href:"/privacy",className:"hover:text-primary transition-colors",children:"Privacy"}),(0,t.jsx)("a",{href:"https://github.com/diegosouzapw/OmniRoute/blob/main/LICENSE",target:"_blank",rel:"noopener noreferrer",className:"hover:text-primary transition-colors",children:"License"})]})]})]})})}])},964039,954609,e=>{"use strict";var t=e.i(247167),s=e.i(843476),r=e.i(271645),a=e.i(948148),l=e.i(703166),i=e.i(342923),n=e.i(80173),o=e.i(556938);function c(e){let t=Math.max(0,Math.floor(e)),s=Math.floor(t/60);return`${s}:${String(t%60).padStart(2,"0")}`}function d({deviceData:e,verificationUrl:t,secondsRemaining:r,polling:l}){let n=(0,a.useTranslations)("oauthModal"),{copied:u,copy:m}=(0,o.useCopyToClipboard)();return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:"text-center py-4",children:[(0,s.jsx)("p",{className:"text-sm text-text-muted mb-4",children:n("deviceCodeVisitUrl")}),(0,s.jsxs)("div",{className:"bg-sidebar p-4 rounded-lg mb-4",children:[(0,s.jsx)("p",{className:"text-xs text-text-muted mb-1",children:n("deviceCodeVerificationUrl")}),(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("a",{href:t,target:"_blank",rel:"noreferrer",className:"flex-1 text-sm break-all text-primary hover:underline",children:t}),(0,s.jsx)(i.default,{size:"sm",variant:"ghost",icon:"verify_url"===u?"check":"content_copy",onClick:()=>m(t,"verify_url")})]})]}),(0,s.jsxs)("div",{className:"bg-primary/10 p-4 rounded-lg",children:[(0,s.jsx)("p",{className:"text-xs text-text-muted mb-1",children:n("deviceCodeYourCode")}),(0,s.jsxs)("div",{className:"flex items-center justify-center gap-2",children:[(0,s.jsx)("p",{className:"text-2xl font-mono font-bold text-primary",children:e.user_code}),(0,s.jsx)(i.default,{size:"sm",variant:"ghost",icon:"user_code"===u?"check":"content_copy",onClick:()=>m(e.user_code,"user_code")})]}),null!==r&&(0,s.jsxs)("div",{className:"mt-3 flex items-center justify-center gap-1 text-xs text-text-muted","aria-label":n("deviceCodeWaiting"),children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-sm",children:"schedule"}),(0,s.jsx)("span",{children:c(r)}
1)]})]})]}),l&&(0,s.jsxs)("div",{className:"flex items-center justify-center gap-2 text-sm text-text-muted",children:[(0,s.jsx)("span",{className:"material-symbols-outlined animate-spin",children:"progress_activity"}),n("deviceCodeWaiting")]})]})}function u({providerName:e,hint:t,onClose:r}){let l=(0,a.useTranslations)("oauthModal"),{copied:c,copy:d}=(0,o.useCopyToClipboard)(),m=[{key:"cmd",body:l("loopbackMismatchStep1"),value:t.tunnelCommand,copyId:"tunnel_cmd",note:l("loopbackMismatchStep1Note",{userPlaceholder:"<user>"})},{key:"url",body:l("loopbackMismatchStep2"),value:t.localDashboardUrl,copyId:"local_url",note:null},{key:"retry",body:l("loopbackMismatchStep3",{providerName:e}),value:null,copyId:null,note:null}];return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:"space-y-4",children:[(0,s.jsxs)("div",{className:"flex items-start gap-3",children:[(0,s.jsx)("div",{className:"size-10 shrink-0 rounded-full bg-amber-500/15 flex items-center justify-center",children:(0,s.jsx)("span",{className:"material-symbols-outlined text-xl text-amber-500",children:"lan"})}),(0,s.jsxs)("div",{children:[(0,s.jsx)("h3",{className:"text-base font-semibold",children:l("loopbackMismatchTitle")}),(0,s.jsxs)("p",{className:"text-xs text-text-muted mt-0.5 font-mono",children:[t.dashboardHost,":",t.dashboardPort]})]})]}),(0,s.jsxs)("div",{className:"rounded-lg border border-amber-500/30 bg-amber-500/10 p-3",children:[(0,s.jsx)("p",{className:"text-xs font-semibold uppercase tracking-wide text-amber-500 mb-1",children:l("loopbackMismatchWhatHappened")}),(0,s.jsx)("p",{className:"text-sm text-text-muted",children:l.rich("loopbackMismatchExplanation",{providerName:e,redirectUri:t.redirectUri,code:e=>(0,s.jsx)("code",{className:"font-mono text-xs",children:e})})})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"text-sm font-medium mb-2",children:l("loopbackMismatchHowToFix")}),(0,s.jsx)("ol",{className:"space-y-3",children:m.map((e,t)=>(0,s.jsxs)("li",{className:"flex gap-3",children:[(0,s.jsx)("span",{className:"size-5 shrink-0 mt-0.5 rounded-full bg-primary/15 text-primary text-xs font-semibold flex items-center justify-center",children:t+1}),(0,s.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,s.jsx)("p",{className:"text-sm",children:e.body}),e.value&&(0,s.jsxs)("div",{className:"flex gap-2 mt-1.5",children:[(0,s.jsx)(n.default,{value:e.value,readOnly:!0,className:"flex-1 font-mono text-xs"}),(0,s.jsx)(i.default,{variant:"secondary",icon:c===e.copyId?"check":"content_copy",onClick:()=>d(e.value,e.copyId),children:l("copy")})]}),e.note&&(0,s.jsx)("p",{className:"text-xs text-text-muted mt-1",children:e.note})]})]},e.key))})]}),(0,s.jsx)("p",{className:"text-xs text-text-muted",children:l("loopbackMismatchAlternative")})]}),(0,s.jsx)("div",{className:"flex gap-2",children:(0,s.jsx)(i.default,{onClick:r,variant:"secondary",fullWidth:!0,children:l("cancel")})})]})}function m({hint:e}){let t=(0,a.useTranslations)("oauthModal"),{copied:r,copy:l}=(0,o.useCopyToClipboard)(),c=(e,t)=>(0,s.jsxs)("div",{className:"flex gap-2 mt-1.5",children:[(0,s.jsx)(n.default,{value:e,readOnly:!0,className:"flex-1 font-mono text-xs"}),(0,s.jsx)(i.default,{size:"sm",variant:"secondary",icon:r===t?"check":"content_copy",onClick:()=>l(e,t)})]});return(0,s.jsxs)("div",{className:"rounded-lg border border-amber-500/30 bg-amber-500/10 p-3 space-y-3",children:[(0,s.jsxs)("div",{children:[(0,s.jsxs)("p",{className:"text-sm font-semibold text-amber-500",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-sm align-middle mr-1",children:"warning"}),t("googleLoopbackTitle")]}),(0,s.jsx)("p",{className:"text-xs text-text-muted mt-1",children:t.rich("googleLoopbackWhatHappens",{redirectUri:e.redirectUri,code:e=>(0,s.jsx)("code",{className:"font-mono",children:e})})})]}),e.helperCommand&&(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"text-xs font-medium",children:t("googleLoopbackRecommended")}),c(e.helperCommand,"google_helper"),(0,s.jsx)("p",{className:"text-xs text-text-muted mt-1",children:t("googleLoopbackHelperNote")})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"text-xs font-medium",children:t("googleLoopbackTunnelLabel")}),c(e.tunnelCommand,"google_tunnel"),(0,s.jsx)("p",{className:"text-xs text-text-muted mt-1",children:t("googleLoopbackTunnelNote",{userPlaceholder:"<user>",localUrl:e.localDashboardUrl})})]}),(0,s.jsx)("p",{className:"text-xs text-text-muted",children:t.rich("googleLoopbackHeadlessAlt",{a:e=>(0,s.jsx)("a",{href:"https://github.com/diegosouzapw/OmniRoute#oauth-on-a-remote-server",target:"_blank",rel:"noreferrer",className:"underline",children:e})})})]})}function x({isGoogleOAuth:e,isTrueLocalhost:t,googleHint:r}){let l=(0,a.useTranslations)("oauthModal");return t?null:e&&r?(0,s.jsx)(m,{hint:r}):(0,s.jsxs)("div",{className:"rounded-lg border border-blue-500/30 bg-blue-500/10 p-3 text-xs text-blue-200",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-sm align-middle mr-1",children:"info"}),l("remoteAccessInfo")]})}function p({provider:e,isGoogleOAuth:t,isTrueLocalhost:r,googleHint:l,authUrl:c,callbackUrl:d,placeholderUrl:u,canSubmit:m,onCallbackUrlChange:h,onSubmit:b,onClose:f}){let g=(0,a.useTranslations)("oauthModal"),{copied:y,copy:v}=(0,o.useCopyToClipboard)();return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:"space-y-4",children:[(0,s.jsx)(x,{isGoogleOAuth:t,isTrueLocalhost:r,googleHint:l}),(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"text-sm font-medium mb-2",children:g("step1OpenUrl")}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(n.default,{value:c,readOnly:!0,className:"flex-1 font-mono text-xs"}),(0,s.jsx)(i.default,{variant:"secondary",icon:"auth_url"===y?"check":"content_copy",onClick:()=>v(c,"auth_url"),children:g("copy")})]})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"text-sm font-medium mb-2",children:g("step2PasteCallback")}),(0,s.jsx)("p",{className:"text-xs text-text-muted mb-2",children:g.rich("step2Hint",{code:e=>(0,s.jsx)("code",{className:"font-mono",children:e})})}),(0,s.jsx)(n.default,{value:d,onChange:e=>h(e.target.value),placeholder:"claude"===e||"cline"===e?"code#state or /callback?code=...":u,className:"font-mono text-xs"})]})]}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(i.default,{onClick:b,fullWidth:!0,disabled:!m,children:g("connect")}),(0,s.jsx)(i.default,{onClick:f,variant:"ghost",fullWidth:!0,children:g("cancel")})]})]})}e.s(["OAuthDeviceCodePanel",0,d,"OAuthLoopbackMismatchPanel",0,u,"OAuthManualInputPanel",0,p,"formatDeviceCodeRemaining",0,c],954609);async function h(e){let t=await e.text();if(!t)return null;try{return JSON.parse(t)}catch{return t}}function b(e,t,s="Request failed"){if(e&&"object"==typeof e){let t=e.error;if("string"==typeof t&&t.trim())return t;if(t&&"object"==typeof t){let e=t.message;return"string"==typeof e&&e.trim()?e:JSON.stringify(t)}let s=e.message??e.detail;if("string"==typeof s&&s.trim())return s}return"string"==typeof e&&e.trim()?e.length>300?`${e.slice(0,300)}â¦`:e:null!=t?`${s} (HTTP ${t})`:s}var f=e.i(467034);function g(e){return"string"==typeof e&&e.trim().startsWith("omniroute-cred-v1.")}async function y(e,t,s,r,a){let l=await fetch(`/api/oauth/${e}/paste-credentials`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({blob:t.trim(),connectionId:s?.id})}),i=await h(l);if(!l.ok)throw Error(b(i,l.status,"Failed to import credentials"));r("success"),a?.()}function v(e){return e&&"object"==typeof e&&!Array.isArray(e)?e:null}function j(e){return"string"==typeof e&&e.trim()?e.trim():void 0}function k({gheUrl:e,setGheUrl:t,error:r,setError:a,startOAuthFlow:l}){return(0,s.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,s.jsxs)("p",{className:"text-sm text-text-muted",children:["Enter the base URL of your GitHub Enterprise instance (e.g."," ",(0,s.jsx)("code",{className:"font-mono",children:"https://ghe.
1yourcompany.com"}),")."]}),(0,s.jsx)(n.default,{value:e,onChange:e=>t(e.target.value),placeholder:"https://ghe.yourcompany.com",label:"GitHub Enterprise URL",type:"url"}),(0,s.jsx)(i.default,{onClick:()=>{e.trim()?l():a("GitHub Enterprise URL is required")},fullWidth:!0,disabled:!e.trim(),children:"Connect"}),r&&(0,s.jsx)("p",{className:"text-sm text-red-500",children:r})]})}let N=/https?:\/\/[^\s"'<>)]+/g;function w({text:e}){return(0,s.jsx)(s.Fragment,{children:(function(e){let t;if(!e)return[];let s=[],r=0;for(N.lastIndex=0;null!==(t=N.exec(e));){t.index>r&&s.push({text:e.slice(r,t.index)});let a=t[0],l="";for(;a.length>0&&/[.,;:!?]$/.test(a);)l=a.slice(-1)+l,a=a.slice(0,-1);let i=function(e){let t;try{t=new URL(e).protocol}catch{return}return"http:"===t||"https:"===t?e:void 0}(a);s.push(i?{text:a,href:i}:{text:a}),l&&s.push({text:l}),r=t.index+t[0].length}return r<e.length&&s.push({text:e.slice(r)}),s})(e||"").map((e,t)=>e.href?(0,s.jsx)("a",{href:e.href,target:"_blank",rel:"noopener noreferrer",className:"underline break-all",children:e.text},t):(0,s.jsx)(r.Fragment,{children:e.text},t))})}var S=e.i(282225);function C({onContinue:e,onClose:t}){return(0,s.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,s.jsxs)("div",{className:"rounded-md border border-border bg-muted/40 px-3 py-3 text-left",children:[(0,s.jsx)("p",{className:"text-sm font-medium mb-2",children:"GitLab Duo OAuth setup"}),(0,s.jsx)("p",{className:"text-sm text-text-muted leading-relaxed",children:(0,s.jsx)(w,{text:S.GITLAB_DUO_OAUTH_SETUP_MESSAGE})})]}),(0,s.jsx)("p",{className:"text-xs text-text-muted",children:"After the application is registered and the env vars are set on this OmniRoute instance, click Continue to start the OAuth login."}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(i.default,{onClick:e,fullWidth:!0,children:"Continue"}),(0,s.jsx)(i.default,{onClick:t,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})}function T({error:e,errorTitle:t,tryAgainLabel:r,cancelLabel:a,returnToGitlabDuoSetup:l,onReturnToGitlabDuoSetup:n,onTryAgain:o,onClose:c}){return(0,s.jsxs)("div",{className:"text-center py-6",children:[(0,s.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,s.jsx)("span",{className:"material-symbols-outlined text-3xl text-red-600",children:"error"})}),(0,s.jsx)("h3",{className:"text-lg font-semibold mb-2",children:t}),(0,s.jsx)("p",{className:"text-sm text-red-600 mb-4",children:(0,s.jsx)(w,{text:e})}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(i.default,{onClick:()=>{l?n():o()},variant:"secondary",fullWidth:!0,children:r}),(0,s.jsx)(i.default,{onClick:c,variant:"ghost",fullWidth:!0,children:a})]})]})}function E({waitingLabel:e,completeAuthLabel:t,popupClosedHint:r,popupBlockedLabel:a,onManualInput:l}){return(0,s.jsxs)("div",{className:"text-center py-6",children:[(0,s.jsx)("div",{className:"size-16 mx-auto mb-4 rounded-full bg-primary/10 flex items-center justify-center",children:(0,s.jsx)("span",{className:"material-symbols-outlined text-3xl text-primary animate-spin",children:"progress_activity"})}),(0,s.jsx)("h3",{className:"text-lg font-semibold mb-2",children:e}),(0,s.jsx)("p",{className:"text-sm text-text-muted mb-2",children:t}),(0,s.jsx)("p",{className:"text-xs text-text-muted mb-4 opacity-70",children:r}),(0,s.jsx)(i.default,{variant:"ghost",onClick:l,children:a})]})}function _(e){return e.port?e.port:"https:"===e.protocol?"443":"80"}function I(e,t){let s=[...new Set(e)];return`ssh ${s.map(e=>`-L ${e}:127.0.0.1:${e}`).join(" ")} <user>@${t}`}let A=new Set(["antigravity"]),D={codex:"http://localhost:1455/auth/callback","xai-oauth":"http://127.0.0.1:56121/callback","grok-cli":"http://127.0.0.1:56122/callback"},K={codex:1455,"xai-oauth":56121,"grok-cli":56122},L=new Set(["antigravity","agy"]),M=new Set(["codex","xai-oauth","grok-cli"]),O=new Set(["github","kiro","amazon-q","kimi-coding","kilocode","codebuddy-cn","ghe-copilot","grok-cli"]),R=new Set(["windsurf","devin-cli","grok-cli"]),F=new Set(["windsurf","devin-cli"]);async function P(e,t,s,r){let a=await fetch("/api/oauth/codex/import-token",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({accessToken:e,name:t})}),l=await h(a);if(!a.ok)throw Error(b(l,a.status,"Failed to import access token"));s("success"),r?.()}function $(e,t){return Math.max(1,Number(e)||t)}async function z(e,t){try{let s=await fetch(`/api/oauth/${e}/poll`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}),r=await h(s);if(r.success)return{status:"success"};if("slow_down"===r.error)return{status:"slow_down"};if(r.error&&!r.pending)return{status:"error",message:String(r.errorDescription||r.error)};return{status:"pending"}}catch(e){return{status:"error",message:e instanceof Error?e.message:"Authorization failed"}}}e.s(["default",0,function({isOpen:e,provider:o,providerInfo:c,onSuccess:m,onClose:x,idcConfig:N,reauthConnection:w}){let S,B=(0,a.useTranslations)("oauthModal"),[U,q]=(0,r.useState)("waiting"),[W,H]=(0,r.useState)(null),[G,J]=(0,r.useState)(""),[Y,V]=(0,r.useState)(null),[X,Q]=(0,r.useState)(!1),[Z,ee]=(0,r.useState)(null),[et,es]=(0,r.useState)(""),[er,ea]=(0,r.useState)(!1),[el,ei]=(0,r.useState)(null),[en,eo]=(0,r.useState)(null),[ec,ed]=(0,r.useState)(F.has(o)),[eu,em]=(0,r.useState)(""),[ex,ep]=(0,r.useState)(!1),[eh,eb]=(0,r.useState)(!1),[ef,eg]=(0,r.useState)(null),ey=R.has(o),ev=F.has(o),ej=(0,r.useRef)(null),ek=(0,r.useRef)(0),eN=Z?.verification_uri_complete||Z?.verification_uri||"",{isLocalhost:ew,isTrueLocalhost:eS,placeholderUrl:eC,loopbackLocation:eT}=(0,r.useMemo)(()=>{let e=window.location.hostname;return{isLocalhost:"localhost"===e||"127.0.0.1"===e||e.startsWith("192.168.")||e.startsWith("10.")||/^172\.(1[6-9]|2\d|3[01])\./.test(e),isTrueLocalhost:"localhost"===e||"127.0.0.1"===e,placeholderUrl:`${window.location.origin}/callback?code=...`,loopbackLocation:{hostname:e,port:window.location.port,protocol:window.location.protocol}}},[]),eE=(0,r.useRef)(!1),e_=(0,r.useRef)(!1),eI=(0,r.useCallback)(()=>{ek.current+=1,ea(!1),ei(null),eo(null)},[]),eA=(0,r.useCallback)(async(e,t)=>{if(W)try{if(!W.redirectUri||!W.codeVerifier)throw Error("OAuth session is incomplete (missing redirect URI or code verifier). Restart the connection and try again.");let s="string"==typeof t&&t.length>0?t:void 0,r=await fetch(`/api/oauth/${o}/exchange`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({code:e,redirectUri:W.redirectUri,connectionId:w?.id,codeVerifier:W.codeVerifier,...s?{state:s}:{}})}),a=await h(r);if(!r.ok){let e="object"==typeof a.error&&null!==a.error?a.error:null,t=e?e.message||JSON.stringify(e):a.error||"Exchange failed",s=Array.isArray(e?.details)?e.details.map(e=>e?.message?e.field?`${e.field}: ${e.message}
1`:e.message:null).filter(Boolean).join("; "):"";throw Error(s?`${t} (${s})`:t)}q("success"),m?.()}catch(e){e.message?.toLowerCase().includes("redirect_uri_mismatch")&&L.has(o)?V("redirect_uri_mismatch: The default Google OAuth credentials only work on localhost. For remote use, configure your own OAuth credentials via environment variables: ANTIGRAVITY_OAUTH_CLIENT_ID and ANTIGRAVITY_OAUTH_CLIENT_SECRET. See the README section 'OAuth on a Remote Server'."):V(e.message),q("error")}},[W,o,m,w]),eD=(0,r.useCallback)(async()=>{let e=eu.trim();if(e&&o){ep(!0),V(null);try{let t=e;if("grok-cli"===o){let s=function(e){let t=e.trim();if(!t)return{ok:!1,error:"Paste the full contents of ~/.grok/auth.json"};if(t.startsWith("{"))try{let e=JSON.parse(t);if(!e||"object"!=typeof e||Array.isArray(e))return{ok:!1,error:"auth.json must be a JSON object from ~/.grok/auth.json"};let s=!1,r=!1;for(let t of Object.values(e))if(t&&"object"==typeof t&&("string"==typeof t.key&&t.key.startsWith("eyJ")&&(s=!0,"string"==typeof t.refresh_token&&t.refresh_token.length>0)||"string"==typeof t.access_token&&t.access_token.startsWith("eyJ")&&(s=!0,"string"==typeof t.refresh_token&&t.refresh_token.length>0))){r=!0;break}if(!s)return{ok:!1,error:'Could not find a Grok Build JWT ("key") in the pasted auth.json. Run `grok login` and paste the full file.'};if(!r)return{ok:!1,error:"auth.json is missing refresh_token. Re-run `grok login` and paste the full ~/.grok/auth.json so the connection can auto-refresh (#7610)."};return{ok:!0,token:e}}catch{return{ok:!1,error:"Could not parse auth.json. Paste the full JSON from ~/.grok/auth.json."}}return t.startsWith("eyJ")?{ok:!1,error:'Do not paste only the JWT "key" field. Paste the full ~/.grok/auth.json object so refresh_token is included (#7610).'}:{ok:!1,error:"Paste the full contents of ~/.grok/auth.json (JSON object)."}}(e);if(!1===s.ok)return void V(s.error);t=s.token}let s=await fetch(`/api/oauth/${o}/import-token`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({token:t,connectionId:w?.id})}),r=await h(s);if(!s.ok){let e=b(r,s.status,"Save failed");throw Error(e)}q("success"),m?.()}catch(e){V(e.message)}finally{ep(!1)}}},[eu,o,m,w]),eK=(0,r.useCallback)(async(e,t,s,r,a)=>{let l=++ek.current,i=$(s,5),n=$(r,60*i),c=Date.now()+1e3*n,d=i;for(ea(!0),ei(c);Date.now()<c&&(await new Promise(e=>setTimeout(e,1e3*d)),!(l!==ek.current||Date.now()>=c));){let s=await z(o,{deviceCode:e,connectionId:w?.id,codeVerifier:t,extraData:a});if(l!==ek.current)return;if("success"===s.status){q("success"),ea(!1),ei(null),m?.();return}if("slow_down"===s.status){d=Math.min(d+5,30);continue}if("error"===s.status){V(s.message),q("error"),ea(!1),ei(null);return}}l===ek.current&&(V("Authorization timeout"),q("error"),ea(!1),ei(null))},[o,m,w]),eL=(0,r.useCallback)(async e=>{if(o)try{let s;V(null);let r="grok-cli"===o&&(e?.grokBrowser??eh);if(O.has(o)&&!r){if(eI(),Q(!0),ee(null),q("waiting"),"ghe-copilot"===o&&!et.trim())return void q("ghe-config");let e=new URL(`/api/oauth/${o}/device-code`,window.location.origin);("kiro"===o||"amazon-q"===o)&&N&&"object"==typeof N&&("string"==typeof N.startUrl&&N.startUrl.trim()&&e.searchParams.set("startUrl",N.startUrl.trim()),"string"==typeof N.region&&N.region.trim()&&e.searchParams.set("region",N.region.trim())),"ghe-copilot"===o&&et.trim()&&e.searchParams.set("gheUrl",et.trim());let t=await fetch(e.toString()),s=await h(t);if(!t.ok){let e=b(s,t.status,"Request failed");throw Error(e)}ee(s);let r=s.verification_uri_complete||s.verification_uri;"string"==typeof r&&r&&window.open(r,"oauth_verify");let a="kiro"===o||"amazon-q"===o?{_clientId:s._clientId,_clientSecret:s._clientSecret,_region:s._region}:"ghe-copilot"===o&&et.trim()?{gheUrl:et.trim()}:null;eK(s.device_code,s.codeVerifier,s.interval||5,s.expires_in,a);return}let a=!1;if(("claude"===o||"cline"===o||"zed-hosted"===o)&&(a=!0),M.has(o)){if(eS)try{let e=await fetch(`/api/oauth/${o}/start-callback-server`),t=await h(e);if(!e.ok)throw Error(b(t,e.status,"Failed to start callback server"));H({...t,redirectUri:t.redirectUri}),q("waiting"),ej.current=window.open(t.authUrl,"oauth_auth"),ej.current||q("input"),ea(!0);for(let e=0;e<150;e++){await new Promise(e=>setTimeout(e,2e3));let e=await fetch(`/api/oauth/${o}/poll-callback`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({connectionId:w?.id})}
1),t=await h(e);if(t.success){q("success"),ea(!1),m?.();return}if(t.error&&!t.pending)throw Error(t.errorDescription||t.error)}throw ea(!1),Error("Authorization timeout")}catch(e){console.warn(`${o} callback server failed, falling back to manual flow`,e),ea(!1),a=!0}else if(ew){let e,t,s;eg((e=_(eT),t=K[o]??null,s=[e],null!=t&&String(t)!==e&&s.push(String(t)),{provider:o,redirectUri:D[o]??"a fixed localhost callback URL",callbackPort:t,dashboardPort:e,dashboardHost:eT.hostname,tunnelCommand:I(s,eT.hostname),localDashboardUrl:`http://localhost:${e}`})),q("loopback-mismatch");return}}if("codex"===o||"openai"===o)s="http://localhost:1455/auth/callback";else if("xai-oauth"===o||"grok-cli"===o){let e="xai-oauth"===o?56121:56122;s=`http://127.0.0.1:${e}/callback`}else if("windsurf"===o||"devin-cli"===o){let e=window.location.port||"20128";s=`http://localhost:${e}/auth/callback`}else if(L.has(o)){let e=window.location.port||"20128";s=`http://127.0.0.1:${e}/callback`}else if(ew){let e=window.location.port||("https:"===window.location.protocol?"443":"80");s=`http://localhost:${e}/callback`}else{let e=t.default.env.NEXT_PUBLIC_BASE_URL,r=e&&"http://localhost:20128"!==e?e.replace(/\/$/,""):window.location.origin;s=`${r}/callback`}let l=await fetch(`/api/oauth/${o}/authorize?redirect_uri=${encodeURIComponent(s)}`),i=await h(l);if(!l.ok){let e=b(i,l.status,"Authorization failed");throw Error(e)}if(!i.authUrl)throw Error(i.error||"Browser OAuth is unavailable for this provider in the current environment. Use the supported auth method instead.");H({...i,redirectUri:i.redirectUri||s}),!eS||a?(q("input"),window.open(i.authUrl,"oauth_auth")):(q("waiting"),ej.current=window.open(i.authUrl,"oauth_popup","width=600,height=700"),ej.current||q("input"))}catch(e){V(e.message),q("error")}},[o,ew,eS,eT,eK,m,w,N,et,eI,eh]);(0,r.useEffect)(()=>{if(!el)return void eo(null);let e=()=>{eo(Math.max(0,Math.ceil((el-Date.now())/1e3)))};e();let t=window.setInterval(e,1e3);return()=>window.clearInterval(t)},[el]),(0,r.useEffect)(()=>{eI(),e_.current=!1,eb(!1)},[o,eI]),(0,r.useEffect)(()=>{e||(eI(),e_.current=!1)},[e,eI]),(0,r.useEffect)(()=>()=>{ek.current+=1},[]),(0,r.useEffect)(()=>{if(!e||!o||e_.current)return;e_.current=!0;let t=F.has(o),s="gitlab-duo"===o;(ed(t),eb(!1),H(null),J(""),V(null),Q(!1),ee(null),ea(!1),s)?q("gitlab-duo-setup"):t||eL()},[e,o,eL]),(0,r.useEffect)(()=>{let e;if(!W)return;eE.current=!1;let t=async e=>{if(eE.current)return;let{code:t,state:s,error:r,errorDescription:a}=e;if(W?.state&&s&&s!==W.state){eE.current=!0,V("OAuth state mismatch. Restart the connection and try again."),q("error");return}if(r){eE.current=!0,V(a||r),q("error");return}t&&(eE.current=!0,await eA(t,s))},s=e=>{let s=window.location.port,r=!1,a=!1;try{let t=new URL(e.origin);a=(r=/^(localhost|127\.0\.0\.1|\[::1\]|::1)$/i.test(t.hostname))&&t.port===s}catch{}let l=e.data?.data,i=!!W?.state&&l?.state===W.state,n=L.has(o)&&r&&i;(e.origin===window.location.origin||a||n)&&e.data?.type==="oauth_callback"&&t(l)};window.addEventListener("message",s);try{(e=new BroadcastChannel("oauth_callback")).onmessage=e=>t(e.data)}catch(e){console.log("BroadcastChannel not supported")}let r=e=>{if("oauth_callback"===e.key&&e.newValue)try{let s=JSON.parse(e.newValue);t(s),localStorage.removeItem("oauth_callback")}catch(e){console.log("Failed to parse localStorage data")}};window.addEventListener("storage",r);try{let e=localStorage.getItem("oauth_callback");if(e){let s=JSON.parse(e);s.timestamp&&Date.now()-s.timestamp<3e4&&(t(s),localStorage.removeItem("oauth_callback"))}}catch{}return()=>{window.removeEventListener("message",s),window.removeEventListener("storage",r),e&&e.close()}},[W,eA,o]),(0,r.useEffect)(()=>{if("waiting"!==U||X||!ej.current)return;let e=setInterval(()=>{if(eE.current)return void clearInterval(e);try{ej.current?.closed&&(clearInterval(e),"waiting"===U&&q("input"))}catch{}},1e3),t=setTimeout(()=>{eE.current||"waiting"!==U||(clearInterval(e),q("input"))},3e5);return()=>{clearInterval(e),clearTimeout(t)}},[U,X]);let eM=async()=>{try{if(V(null),g(G))return void await y(o,G,w,q,m);if("codex"===o&&/^eyJ/.test(G.trim()))return void await P(G.trim(),void 0,q,m);if("codex"===o&&function(e){let t="string"==typeof e?e.trim():"";if(!t.startsWith("{"))return!1;try{return null!==v(JSON.parse(t))}catch{return!1}}(G)){let e=function(e){let t=v(e);if(!t)return{ok:!1,error:"Pasted session data is not a JSON object"};let s=function(e){let t=j(e.accessToken)||j(e.access_token)||j(e.sessionToken)||j(e.session_token);if(t)return t;let s=v(e.tokens);if(s)return j(s.access_token)||j(s.accessToken)}(t);if(!s)return{ok:!1,error:"Could not find an access token field in the pasted session JSON (expected accessToken, access_token, sessionToken, or tokens.access_token)"};if(3!==s.split(".").length)return{ok:!1,error:"The access token field does not look like a valid JWT"};if(function(e,t){let s,r,a=j(e.expires);if(a){let e=Date.parse(a);if(Number.isFinite(e)&&e<=Date.now())return!0}let l=(r=(s=function(e){try{if(!e||"string"!=typeof e)return null;let t=e.split(".");if(3!==t.length)return null;let s=t[1].replace(/-/g,"+").replace(/_/g,"/"),r=(4-s.length%4)%4,a=s+"=".repeat(r);return JSON.parse(f.Buffer.from(a,"base64").toString("utf8"))}catch{return null}}(t))&&"number"==typeof s.exp?s.exp:null,null!==r&&Number.isFinite(r)?r:null);return null!==l&&1e3*l<=Date.now()}(t,s))return{ok:!1,error:"Session is expired â sign in to chatgpt.com again and re-copy the session JSON"};let r=v(t.user);return{ok:!0,session:{accessToken:s,email:r&&j(r.email)||void 0}}}(JSON.parse(G.trim()));if(!1===e.ok)return void V(e.error);await P(e.session.accessToken,e.session.email,q,m);return}if(!W)throw Error("OAuth session not initialized. Restart the connection flow and try again.");let e=G.trim(),t=null,s=W?.state||null,r=null,a=null;try{let l=new URL(e);t=l.searchParams.get("code"),s=l.searchParams.get("state")||l.hash.replace(/^#/,"")||s,r=l.searchParams.get("error"),a=l.searchParams.get("error_description")}catch{let[r,a]=e.split("#",2);t=r||null,s=a||s}if(r)throw Error(a||r);if(!t)throw Error("No authorization code found. Paste the callback URL or the Authentication Code.");await eA(t,s)}catch(e){V(e.message),q("error")}},eO=(0,r.useCallback)(()=>{eI(),x()},[eI,x]),eR=(0,r.useCallback)(()=>{eI(),ed(!0)},[eI]),eF=(0,r.useCallback)(()=>{ed(!1),"grok-cli"===o&&eb(!0),eL("grok-cli"===o?{grokBrowser:!0}:void 0)},[eL,o]),eP=(0,r.useCallback)(()=>{ed(!1),eb(!1),eL({grokBrowser:!1})},[eL]);return o&&c?(0,s.jsx)(l.default,{isOpen:e,title:B("title",{providerName:c.name}),onClose:eO,size:"lg",children:(0,s.jsxs)("div",{className:"flex flex-col gap-4",children:[ey&&!ev&&"success"!==U&&(0,s.jsxs)("div",{className:"flex gap-2 border-b border-border pb-3",children:["grok-cli"===o&&(0,s.jsx)("button",{className:`text-sm px-3 py-1 rounded-t ${!ec&&!eh?"font-semibold border-b-2 border-primary text-primary":"text-text-muted"}`,onClick:eP,children:"Device Code"}),(0,s.jsx)("button",{className:`text-sm px-3 py-1 rounded-t ${!ec&&("grok-cli"!==o||eh)?"font-semibold border-b-2 border-primary text-primary":"text-text-muted"}`,onClick:eF,children:"Browser Login"}),(0,s.jsx)("button",{className:`text-sm px-3 py-1 rounded-t ${ec?"font-semibold border-b-2 border-primary text-primary":"text-text-muted"}`,onClick:eR,children:"grok-cli"===o?"Import auth.json":"Paste API Key"})]}),ey&&ec&&"success"!==U&&(0,s.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,s.jsx)("p",{className:"text-sm text-text-muted",children:"windsurf"===o?'In the Windsurf / VS Code IDE, run the "Windsurf: Provide Auth Token" command from the command palette (or click the Jupyter "Get Windsurf Authentication Token" button), then copy the shown token and paste it below. Opening windsurf.com/show-auth-token directly only shows a "Redirecting" page â the IDE must initiate the flow.':"grok-cli"===o?'Paste the FULL contents of ~/.grok/auth.json (not just the JWT "key" field). A bare JWT has no refresh_token, so the connection dies after expiry (#7610). Prefer the dedicated Import auth.json modal when available.':'Provide your WINDSURF_API_KEY (obtained via `devin auth login`, or via the Windsurf IDE "Windsurf: Provide Auth Token" command).'}),"grok-cli"===o?(0,s.jsx)("textarea",{className:"w-full h-32 p-3 text-sm font-mono bg-input border border-border rounded-md resize-none focus:outline-none focus:ring-2 focus:ring-primary",value:eu,onChange:e=>em(e.target.value),placeholder:'{"https://auth.x.ai::clientId": {"key": "eyJ...", "refresh_token": "..."}}',"aria-label":"Grok Build auth.json"}):(0,s.jsx)(n.default,{value:eu,onChange:e=>em(e.target.value),placeholder:"ws-...",type:"password",label:"API Key / Token"}),Y&&(0,s.jsx)("p",{className:"text-sm text-red-500",children:Y}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(i.default,{onClick:eD,fullWidth:!0,disabled:!eu.trim()||ex,children:ex?"Savingâ¦":"Save Connection"}),(0,s.jsx)(i.default,{onClick:eO,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]}),(!ey||!ec)&&(0,s.jsxs)(s.Fragment,{children:["ghe-copilot"===o&&"ghe-config"===U&&(0,s.jsx)(k,{gheUrl:et,setGheUrl:es,error:Y,setError:V,startOAuthFlow:eL}),"gitlab-duo"===o&&"gitlab-duo-setup"===U&&(0,s.jsx)(C,{onContinue:()=>void eL(),onClose:eO}),"waiting"===U&&!X&&(0,s.jsx)(E,{waitingLabel:B("waiting"),completeAuthLabel:B("completeAuthInPopup"),popupClosedHint:B("popupClosedHint"),popupBlockedLabel:B("popupBlocked"),onManualInput:()=>q("input")}),"waiting"===U&&X&&Z&&(0,s.jsx)(d,{deviceData:Z,verificationUrl:eN,secondsRemaining:en,polling:er}),"input"===U&&!X&&(0,s.jsx)(p,{provider:o,isGoogleOAuth:L.has(o),isTrueLocalhost:eS,googleHint:L.has(o)?(S=_(eT),{provider:o,redirectUri:`http://127.0.0.1:${S}/callback`,dashboardHost:eT.hostname,dashboardPort:S,tunnelCommand:I([S],eT.hostname),localDashboardUrl:`http://localhost:${S}`,helperCommand:A.has(o)?`npx omniroute login ${o}`:null}):null,authUrl:"string"==typeof W?.authUrl?W.authUrl:"",callbackUrl:G,placeholderUrl:eC,canSubmit:!!(G&&(W||g(G))),onCallbackUrlChange:J,onSubmit:eM,onClose:eO})]}),"success"===U&&(0,s.jsxs)("div",{className:"text-center py-6",children:[(0,s.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,s.jsx)("span",{className:"material-symbols-outlined text-3xl text-green-600",children:"check_circle"})}),(0,s.jsx)("h3",{className:"text-lg font-semibold mb-2",children:B("success")}),(0,s.jsx)("p",{className:"text-sm text-text-muted mb-4",children:B("successMessage",{providerName:c.name})}),(0,s.jsx)(i.default,{onClick:eO,fullWidth:!0,children:B("done")})]}),"loopback-mismatch"===U&&ef&&!ec&&(0,s.jsx)(u,{providerName:c.name,hint:ef,onClose:eO}),"error"===U&&!ec&&(0,s.jsx)(T,{error:Y,errorTitle:B("error"),tryAgainLabel:B("tryAgain"),cancelLabel:B("cancel"),returnToGitlabDuoSetup:"gitlab-duo"===o,onReturnToGitlabDuoSetup:()=>{V(null),q("gitlab-duo-setup")},onTryAgain:()=>void eL(),onClose:eO})]})}):null}],964039)},629476,e=>{"use strict";var t=e.i(843476),s=e.i(271645),r=e.i(907714),a=e.i(80173);
1e.s(["default",0,function({value:e,onChange:l,disabled:i=!1,label:n,placeholder:o,ariaLabel:c,allowCustom:d=!0,className:u}){let[m,x]=(0,s.useState)({status:"loading",options:[]});if((0,s.useEffect)(()=>{let e=!1;return fetch("/api/models").then(e=>e.ok?e.json():Promise.reject(Error("fetch failed"))).then(t=>{e||x({status:"ready",options:(Array.isArray(t?.models)?t.models:[]).map(e=>{let t=e.fullModel||`${e.provider}/${e.model}`;return{value:t,label:t}})})}).catch(()=>{e||x({status:"error",options:[]})}),()=>{e=!0}},[]),"error"===m.status&&d)return(0,t.jsx)(a.default,{label:n,value:e,onChange:e=>l(e.target.value),placeholder:o,disabled:i,"aria-label":c,className:u});let p=!(""===e||m.options.some(t=>t.value===e))&&d?[{value:e,label:`${e} (custom)`},...m.options]:m.options;return(0,t.jsx)(r.default,{label:n,value:e,onChange:e=>l(e.target.value),options:p,placeholder:"loading"===m.status?"Loading modelsâ¦":o||"Select a model",disabled:i||"loading"===m.status,"aria-label":c,className:u})}])},16190,474078,11477,339971,961430,148943,e=>{"use strict";e.s(["default",()=>x],16190);var t=e.i(843476),s=e.i(271645),r=e.i(948148);e.i(565650);var a=e.i(342923);e.s(["Button",()=>a.default],474078);var a=a,l=e.i(393718);e.s(["Card",()=>l.default],11477);var l=l,i=e.i(80173);e.s(["Input",()=>i.default],339971);var i=i,n=e.i(907714);e.s(["Select",()=>n.default],961430);var n=n,o=e.i(635055);e.s(["Toggle",()=>o.default],148943);var o=o;let c=["none","low","medium","high","xhigh"],d=["max","ultra"];function u(e){return{name:"",description:"",scope:e?"apiKey":"global",apiKeyId:e||"",comboId:"",connectionId:"",modelPattern:"",sourceEffort:"any",requestTags:"",tagMatchMode:"any",effortMode:"inherit",targetEffort:"medium",targetKind:"keep",targetModel:"",targetComboId:"",budgetAction:"preserve",budgetTokens:"",priority:"0",enabled:!0}}function m(e,t){let s=e.trim().toLowerCase().replace(/^(?:codex|cx)\//,"");return"ultra"===t?/^gpt-5\.6-(?:sol|terra)(?:-|$)/.test(s):/^gpt-5\.6-(?:sol|terra|luna)(?:-|$)/.test(s)}function x({apiKeyId:e}){let p=(0,r.useTranslations)("reasoningRouting"),[h,b]=(0,s.useState)([]),[f,g]=(0,s.useState)([]),[y,v]=(0,s.useState)([]),[j,k]=(0,s.useState)([]),[N,w]=(0,s.useState)(()=>u(e)),[S,C]=(0,s.useState)(null),[T,E]=(0,s.useState)(!1),[_,I]=(0,s.use
1State)(""),[A,D]=(0,s.useState)("all"),[K,L]=(0,s.useState)("all"),[M,O]=(0,s.useState)(""),[R,F]=(0,s.useState)({model:"",effort:"missing",requestTags:"",transport:"http"}),[P,$]=(0,s.useState)(null),z=(0,s.useCallback)(async()=>{let e=await Promise.all([fetch("/api/settings/reasoning-routing-rules"),fetch("/api/combos"),fetch("/api/keys"),fetch("/api/providers")]);if(e.some(e=>!e.ok))throw Error(p("loadError"));let[t,s,r,a]=await Promise.all(e.map(e=>e.json()));b(Array.isArray(t.rules)?t.rules:[]),g(Array.isArray(s.combos)?s.combos:[]),v(Array.isArray(r.keys)?r.keys:[]),k(Array.isArray(a.connections)?a.connections:[])},[p]);(0,s.useEffect)(()=>{z().catch(()=>I(p("loadError")))},[z,p]);let B=(0,s.useMemo)(()=>{let t=M.trim().toLowerCase();return h.filter(s=>(!e||"apiKey"===s.scope&&s.apiKeyId===e)&&(!!e||"all"===A||s.scope===A)&&("enabled"!==K||!!s.enabled)&&("disabled"!==K||!s.enabled)&&(!t||[s.name,s.description,s.modelPattern,...s.requestTags].filter(Boolean).some(e=>String(e).toLowerCase().includes(t))))},[e,h,A,M,K]),U="model"===N.targetKind?N.targetModel:N.modelPattern,q=(0,s.useMemo)(()=>{let e=[...c];for(let t of d)(m(U,t)||N.targetEffort===t)&&e.push(t);return e.map(e=>({value:e,label:e}))},[N.targetEffort,U]),W=(0,s.useMemo)(()=>"inherit"!==N.effortMode&&d.includes(N.targetEffort)?"combo"===N.targetKind?p("extendedComboWarning"):U.trim()?m(U,N.targetEffort)?"":p("extendedUnsupportedWarning"):p("extendedUnknownWarning"):"",[N.effortMode,N.targetEffort,N.targetKind,p,U]),H=()=>{C(null),w(u(e))},G=async()=>{E(!0),I("");try{let e,t=await fetch(S?`/api/settings/reasoning-routing-rules/${encodeURIComponent(S)}`:"/api/settings/reasoning-routing-rules",{method:S?"PATCH":"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify((e="connection"===N.scope?"keep":N.targetKind,{...N,apiKeyId:"apiKey"===N.scope&&N.apiKeyId||null,comboId:"combo"===N.scope&&N.comboId||null,connectionId:"connection"===N.scope&&N.connectionId||null,modelPattern:("model"===N.scope||"apiKey"===N.scope)&&N.modelPattern||null,requestTags:N.requestTags.split(",").map(e=>e.trim()).filter(Boolean),targetEffort:"inherit"===N.effortMode?null:N.targetEffort,targetKind:e,targetModel:"model"===e&&N.targetModel||null,targetComboId:"combo"===e&&N.targetComboId||null,budgetTokens:"set"===N.budgetAction?Number(N.budgetTokens):null,priority:Number(N.priority)}))});if(!t.ok){let e=await t.json().catch(()=>null);throw Error(e?.error?.message||e?.error||p("saveError"))}await z(),H(),I(p("saved"))}catch(e){I(e instanceof Error?e.message:p("saveError"))}finally{E(!1)}},J=async e=>{window.confirm(p("deleteConfirm"))&&((await fetch(`/api/settings/reasoning-routing-rules/${encodeURIComponent(e)}`,{method:"DELETE"})).ok?await z():I(p("deleteError")))},Y=async e=>{(await fetch(`/api/settings/reasoning-routing-rules/${encodeURIComponent(e.id)}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({enabled:!e.enabled})})).ok?await z():I(p("saveError"))},V=async()=>{$(null);let t=await fetch("/api/settings/reasoning-routing-rules/simulate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...R,apiKeyId:e||N.apiKeyId||null,requestTags:R.requestTags.split(",").map(e=>e.trim()).filter(Boolean)})});$(await t.json())},X=["global","apiKey","combo","model","connection"].map(e=>({value:e,label:p(`scope.${e}`)}));return(0,t.jsx)(l.default,{title:e?p("apiKeyTitle"):p("title"),subtitle:p("subtitle"),icon:"route",children:(0,t.jsxs)("div",{className:"space-y-5",children:[(0,t.jsxs)("div",{className:"grid gap-3 md:grid-cols-3",children:[(0,t.jsx)(i.default,{label:p("filterSearch"),value:M,onChange:e=>O(e.target.value)}),!e&&(0,t.jsx)(n.default,{label:p("filterScope"),value:A,onChange:e=>D(e.target.value),options:[{value:"all",label:p("all")},...X]}),(0,t.jsx)(n.default,{label:p("filterStatus"),value:K,onChange:e=>L(e.target.value),options:[{value:"all",label:p("all")},{value:"enabled",label:p("enabled")},{value:"disabled",label:p("disabled")}]})]}),(0,t.jsxs)("div",{className:"space-y-2",children:[0===B.length&&(0,t.jsx)("p",{className:"text-sm text-text-muted",children:p("empty")}),B.map(s=>(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-3 rounded-lg border border-border p-3",children:[(0,t.jsx)(o.default,{checked:s.enabled,onChange:()=>Y(s),size:"sm",ariaLabel:p("toggleAria",{name:s.name})}),(0,t.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,t.jsx)("p",{className:"font-medium text-text-main",children:s.name}),(0,t.jsxs)("p",{className:"text-xs text-text-muted",children:[p(`scope.${s.scope}`)," · ",s.modelPattern||p("allModels")," ·"," ",s.sourceEffort," â"," ","keep"===s.targetKind?p("keepModel"):s.targetModel||s.targetComboId," ","· ",p(`mode.${s.effortMode}`),s.targetEffort?` ${s.targetEffort}`:""," ·"," ",p("priorityShort",{value:s.priority})]})]}),(0,t.jsx)(a.default,{size:"sm",variant:"ghost",icon:"edit",onClick:()=>{C(s.id),w({...u(e),...s,apiKeyId:s.apiKeyId||"",comboId:s.comboId||"",connectionId:s.connectionId||"",modelPattern:s.modelPattern||"",targetEffort:s.targetEffort||"medium",targetModel:s.targetModel||"",targetComboId:s.targetComboId||"",requestTags:s.requestTags.join(", "),budgetTokens:s.budgetTokens?String(s.budgetTokens):"",priority:String(s.priority)})},children:p("edit")}),(0,t.jsx)(a.default,{size:"sm",variant:"danger",icon:"delete",onClick:()=>J(s.id),children:p("delete")})]},s.id))]}),(0,t.jsxs)("div",{className:"grid gap-3 md:grid-cols-2 xl:grid-cols-4",children:[(0,t.jsx)(i.default,{label:p("name"),value:N.name,onChange:e=>w({...N,name:e.target.value}),required:!0}),(0,t.jsx)(i.default,{label:p("description"),value:N.description,onChange:e=>w({...N,description:e.target.value})}),!e&&(0,t.jsx)(n.default,{label:p("scopeLabel"),value:N.scope,onCh
1ange:e=>w({...N,scope:e.target.value,targetKind:"connection"===e.target.value?"keep":N.targetKind}),options:X}),"apiKey"===N.scope&&!e&&(0,t.jsx)(n.default,{label:p("apiKey"),value:N.apiKeyId,onChange:e=>w({...N,apiKeyId:e.target.value}),options:y.map(e=>({value:e.id,label:e.name}))}),"combo"===N.scope&&(0,t.jsx)(n.default,{label:p("sourceCombo"),value:N.comboId,onChange:e=>w({...N,comboId:e.target.value}),options:f.map(e=>({value:e.id,label:e.name}))}),"connection"===N.scope&&(0,t.jsx)(n.default,{label:p("connection"),value:N.connectionId,onChange:e=>w({...N,connectionId:e.target.value}),options:j.map(e=>({value:e.id,label:e.displayName||e.name||`${e.provider} \xb7 ${e.id.slice(0,8)}`}))}),("model"===N.scope||"apiKey"===N.scope)&&(0,t.jsx)(i.default,{label:p("sourceModel"),value:N.modelPattern,onChange:e=>w({...N,modelPattern:e.target.value}),placeholder:"apiKey"===N.scope?p("sourceModelOptional"):p("sourceModelExample")}),(0,t.jsx)(n.default,{label:p("sourceEffort"),value:N.sourceEffort,onChange:e=>w({...N,sourceEffort:e.target.value}),options:[{value:"any",label:p("any")},{value:"missing",label:p("missing")},...[...c,...d].map(e=>({value:e,label:e}))]}),(0,t.jsx)(i.default,{label:p("requestTags"),value:N.requestTags,onChange:e=>w({...N,requestTags:e.target.value}),placeholder:p("requestTagsExample")}),(0,t.jsx)(n.default,{label:p("tagMode"),value:N.tagMatchMode,onChange:e=>w({...N,tagMatchMode:e.target.value}),options:[{value:"any",label:p("any")},{value:"all",label:p("all")}]}),(0,t.jsx)(n.default,{label:p("effortMode"),value:N.effortMode,onChange:e=>w({...N,effortMode:e.target.value}),options:["inherit","default","force"].map(e=>({value:e,label:p(`mode.${e}`)}))}),"inherit"!==N.effortMode&&(0,t.jsx)(n.default,{label:p("targetEffort"),value:N.targetEffort,onChange:e=>w({...N,targetEffort:e.target.value}),options:q}),(0,t.jsx)(n.default,{label:p("routingTarget"),value:"connection"===N.scope?"keep":N.targetKind,disabled:"connection"===N.scope,onChange:e=>w({...N,targetKind:e.target.value}),options:[{value:"keep",label:p("keepModel")},{value:"model",label:p("otherModel")},{value:"combo",label:p("combo")}]}),"model"===N.targetKind&&"connection"!==N.scope&&(0,t.jsx)(i.default,{label:p("targetModel"),value:N.targetModel,onChange:e=>w({...N,targetModel:e.target.value})}),"combo"===N.targetKind&&"connection"!==N.scope&&(0,t.jsx)(n.default,{label:p("targetCombo"),value:N.targetComboId,onChange:e=>w({...N,targetComboId:e.target.value}),options:f.map(e=>({value:e.id,label:e.name}))}),(0,t.jsx)(n.default,{label:p("budgetAction"),value:N.budgetAction,onChange:e=>w({...N,budgetAction:e.target.value}),options:["preserve","remove","set"].map(e=>({value:e,label:p(`budget.${e}`)}))}),"set"===N.budgetAction&&(0,t.jsx)(i.default,{label:p("budgetTokens"),type:"number",min:"1",value:N.budgetTokens,onChange:e=>w({...N,budgetTokens:e.target.value})}),(0,t.jsx)(i.default,{label:p("priority"),type:"number",value:N.priority,onChange:e=>w({...N,priority:e.target.value})})]}),W&&(0,t.jsx)("p",{className:"text-sm text-amber-600 dark:text-amber-400",children:W}),(0,t.jsxs)("div",{className:"flex gap-2",children:[(0,t.jsx)(a.default,{onClick:G,loading:T,children:S?p("saveChanges"):p("add")}),S&&(0,t.jsx)(a.default,{variant:"ghost",onClick:H,children:p("cancel")})]}),_&&(0,t.jsx)("p",{className:"text-sm text-text-muted",children:_}),(0,t.jsxs)("div",{className:"border-t border-border pt-5",children:[(0,t.jsx)("h4",{className:"mb-3 font-medium text-text-main",children:p("simulateTitle")}),(0,t.jsxs)("div",{className:"grid gap-3 md:grid-cols-4",children:[(0,t.jsx)(i.default,{label:p("model"),value:R.model,onChange:e=>F({...R,model:e.target.value})}),(0,t.jsx)(n.default,{label:p("effort"),value:R.effort,onChange:e=>F({...R,effort:e.target.value}),options:[{value:"missing",label:p("missing")},{value:"signal",label:p("signalOnly")},...[...c,...d].map(e=>({value:e,label:e}))]}),(0,t.jsx)(i.default,{label:p("requestTags"),value:R.requestTags,onChange:e=>F({...R,requestTags:e.target.value})}),(0,t.jsx)(n.default,{label:p("transport"),value:R.transport,onChange:e=>F({...R,transport:e.target.value}),options:[{value:"http",label:"HTTP"},{value:"codex-ws",label:"Codex WebSocket"}]})]}),(0,t.jsx)(a.default,{className:"mt-3",variant:"secondary",onClick:V,children:p("simulate")}),P&&(0,t.jsx)("pre",{className:"mt-3 max-h-64 overflow-auto rounded-lg bg-black/5 p-3 text-xs text-text-main dark:bg-white/5",children:JSON.stringify(P,null,2)})]})]})})}},193464,e=>{"use strict";var t=e.i(843476),s=e.i(271645),r=e.i(948148),a=e.i(703166),l=e.i(342923),i=e.i(556938);e.s(["default",0,function({isOpen:e,onClose:n,title:o,configs:c=[]}){let d=(0,r.useTranslations)("common"),u=o??d("manualConfig"),[m,x]=(0,s.use
1State)(null),{copy:p}=(0,i.useCopyToClipboard)(),h=async(e,t)=>{await p(e,`manualconfig-${t}`)&&(x(t),setTimeout(()=>x(null),2e3))};return(0,t.jsx)(a.default,{isOpen:e,onClose:n,title:u,size:"xl",children:(0,t.jsx)("div",{className:"flex flex-col gap-4",children:c.map((e,s)=>(0,t.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsx)("span",{className:"text-sm font-medium text-text-main",children:e.filename}),(0,t.jsxs)(l.default,{variant:"ghost",size:"sm",onClick:()=>h(e.content,s),children:[(0,t.jsx)("span",{className:"material-symbols-outlined text-[14px] mr-1",children:m===s?"check":"content_copy"}),m===s?d("copied"):d("copy")]})]}),(0,t.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:e.content})]},s))})})}])},548036,e=>{"use strict";var t=e.i(843476),s=e.i(948148),r=e.i(271645),a=e.i(618566),l=e.i(393718),i=e.i(969353),n=e.i(454149),o=e.i(243009);function c({field:e,currentSort:s,currentOrder:r}){return s!==e?(0,t.jsx)("span",{className:"ml-1 opacity-20",children:"â"}):(0,t.jsx)("span",{className:"ml-1",children:"asc"===r?"â":"â"})}function d({data:e,colorClass:s="bg-primary"}){let r=Math.max(...e,1);return(0,t.jsx)("div",{className:"flex items-end gap-1 h-8 w-24",children:e.slice(-9).map((e,a)=>(0,t.jsx)("div",{className:`flex-1 rounded-t-sm transition-all duration-500 ${s}`,style:{height:`${Math.max(e/r*100,5)}%`},title:String(e)},`bar-${a}-${e}`))})}e.s(["default",0,function(){let e=(0,s.useTranslations)("stats"),u=(0,a.useRouter)(),m=(0,a.useSearchParams)(),x=m.get("sortBy")||"rawModel",p=m.get("sortOrder")||"asc",[h,b]=(0,r.useState)(null),[f,g]=(0,r.useState)(!0),[y,v]=(0,r.useState)(!0),[j,k]=(0,r.useState)("tokens"),[N,w]=(0,r.useState)(5e3),S=(0,r.useRef)(0),C=e=>{let t=new URLSearchParams(m.toString());x===e?t.set("sortOrder","asc"===p?"desc":"asc"):(t.set("sortBy",e),t.set("sortOrder","asc")),u.replace(`?${t.toString()}`,{scroll:!1})},T=(0,r.useCallback)((e,t={})=>Object.entries(e||{}).map(([e,s])=>{let r=(s.promptTokens||0)+(s.completionTokens||0),a=s.cost||0,l=r>0?(s.promptTokens||0)*(a/r):0,i=r>0?(s.completionTokens||0)*(a/r):0;return{...s,key:e,totalTokens:r,totalCost:a,inputCost:l,outputCost:i,pending:t[e]||0}}).sort((e,t)=>{let s=e[x],r=t[x];return("string"==typeof s&&(s=s.toLowerCase()),"string"==typeof r&&(r=r.toLowerCase()),s<r)?"asc"===p?-1:1:s>r?"asc"===p?1:-1:0}),[x,p]),E=(0,r.useMemo)(()=>T(h?.byModel,h?.pending?.byModel),[h?.byModel,h?.pending?.byModel,T]),_=(0,r.useMemo)(()=>{let e={};return h?.pending?.byAccount&&Object.entries(h.byAccount||{}).forEach(([t,s])=>{let r=h.pending.byAccount[s.connectionId];if(r){let a=s.provider?`${s.rawModel} (${s.provider})`:s.rawModel;e[t]=r[a]||0}}),T(h?.byAccount,e)},[h?.byAccount,h?.pending?.byAccount,T]),I=(0,r.useCallback)(async(e=!0)=>{e&&g(!0);try{let e=await fetch("/api/usage/history");if(e.ok){let t=await e.json();b(t);let s=t.totalRequests||0;s>S.current?w(5e3):w(e=>Math.min(2*e,6e4)),S.current=s}}catch(e){console.error("Failed to fetch usage stats:",e)}finally{e&&g(!1)}},[]);if((0,r.useEffect)(()=>{I()},[I]),(0,r.useEffect)(()=>{let e,t=!0,s=()=>{(t=!document.hidden)&&y&&I(!1)};return document.addEventListener("visibilitychange",s),y&&(e&&clearInterval(e),e=setInterval(()=>{t&&I(!1)},N)),()=>{e&&clearInterval(e),document.removeEventListener("visibilitychange",s)}},[y,N,I]),f)return(0,t.jsx)(n.CardSkeleton,{});if(!h)return(0,t.jsx)("div",{className:"text-text-muted",children:e("failedToLoad")});let A=e=>(0,o.fmtFull)(e),D=e=>{if(!e)return"Never";let t=new Date(e),s=Math.floor((new Date().getTime()-t.getTime())/6e4);return s<1?"Just now":s<60?`${s}m ago`:s<1440?`${Math.floor(s/60)}h ago`:t.toLocaleDateString()};return(0,t.jsxs)("div",{className:"flex flex-col gap-6",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsx)("h2",{className:"text-xl font-semibold",children:e("usageOverview")}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsxs)("div",{className:"flex items-center gap-1 bg-bg-subtle rounded-lg p-1 border border-border",children:[(0,t.jsx)("button",{onClick:()=>k("tokens"),className:`px-3 py-1 rounded-md text-sm font-medium transition-colors ${"tokens"===j?"bg-primary text-white shadow-sm":"text-text-muted hover:text-text hover:bg-bg-hover"}`,children:"Tokens"}),(0,t.jsx)("button",{onClick:()=>k("costs"),className:`px-3 py-1 rounded-md text-sm font-medium transition-colors ${"costs"===j?"bg-primary text-white shadow-sm":"text-text-muted hover:text-text hover:bg-bg-hover"}`,children:"Costs"})]}),(0,t.jsxs)("div",{className:"text-sm font-medium text-text-muted flex items-center gap-2",children:[(0,t.jsxs)("span",{children:["Auto Refresh (",N/1e3,"s)"]}),(0,t.jsx)("button",{type:"button",onClick:()=>v(!y),role:"switch","aria-checked":y,"aria-label":"Toggle auto refresh",className:`relative inline-flex h-5 w-9 items-center rounded-full transition-colors focus:outline-none focus:ring-2 focus:ring-primary/50 ${y?"bg-primary":"bg-bg-subtle border border-border"}`,children:(0,t.jsx)("span",{className:`inline-block h-3 w-3 transform rounded-full bg-white transition-transform ${y?"translate-x-5":"translate-x-1"}`})})]})]})]}),(h.activeRequests||[]).length>0&&(0,t.jsx)(l.default,{className:"p-3 border-primary/20 bg-primary/5",children:(0,t.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 text-primary font-semibold text-sm uppercase tracking-wider",children:[(0,t.jsxs)("span",{className:"relative flex h-2 w-2",children:[(0,t.jsx)("span",{className:"animate-ping absolute inline-flex h-full w-full rounded-full bg-primary opacity-75"}),(0,t.jsx)("span",{className:"relative inline-flex rounded-full h-2 w-2 bg-primary"})]}),"Active Requests"]}),(0,t.jsx)("div",{className:"flex flex-wrap gap-3",children:h.activeRequests.map(e=>(0,t.jsxs)("div",{className:"px-3 py-1.5 rounded-md bg-bg-subtle border border-primary/20 text-xs font-mono shadow-sm",children:[(0,t.jsx)("span",{className:"text-primary font-bold",children:e.model}),(0,t.jsx)("span",{className:"mx-1 text-text-muted",children:"|"}),(0,t.jsx)("span",{className:"text-text",children:e.provider}),(0,t.jsx)("span",{className:"mx-1 text-text-muted",children:"|"}),(0,t.jsx)("span",{className:"text-text font-medium",children:e.account}),e.count>1&&(0,t.jsxs)("span",{className:"ml-2 px-1.5 py-0.5 rounded bg-primary text-white font-bold",children:["x",e.count]})]},`${e.model}-${e.provider}-${e.account}`))})]})}),(0,t.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[(0,t.jsx)(l.default,{className:"px-4 py-3 flex flex-col gap-1",children:(0,t.jsxs)("div",{className:"flex justify-between items-start",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,t.jsx)("span",{className:"text-text-muted text-sm uppercase font-semibold",children:"Total Requests"}),(0,t.jsx)("span",{className:"text-2xl font-bold",children:A(h.totalRequests)})]}),(0,t.jsx)(d,{data:(h.last10Minutes||[]).map(e=>e.requests),colorClass:"bg-text-muted/30"})]})}),(0,t.jsx)(l.default,{className:"px-4 py-3 flex flex-col gap-1",children:(0,t.jsxs)("div",{className:"flex justify-between items-start",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,t.jsx)("span",{className:"text-text-muted text-sm uppercase font-semibold",children:"Total Input Tokens"}),(0,t.jsx)("span",{className:"text-2xl font-bold text-primary",children:A(h.totalPromptTokens)})]}),(0,t.jsx)(d,{data:(h.last10Minutes||[]).map(e=>e.promptTokens),colorClass:"bg-primary/50"})]})}),(0,t.jsx)(l.default,{className:"px-4 py-2 flex flex-col gap-1",children:(0,t.jsxs)("div",{className:"flex justify-between items-start gap-4",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-1 flex-1",children:[(0,t.jsx)("span",{className:"text-text-muted text-sm uppercase font-semibold",children:e("outputTokens")}),(0,t.jsx)("span",{className:"text-2xl font-bold text-success",children:A(h.totalCompletionTokens)})]}),(0,t.jsx)("div",{className:"w-px bg-border self-stretch mx-2"}),(0,t.jsxs)("div",{className:"flex flex-col gap-1 flex-1",children:[(0,t.jsx)("span",{className:"text-text-muted text-sm uppercase font-semibold",children:e("totalCost")}),(0,t.jsx)("span",{className:"text-2xl font-bold text-warning",children:(0,o.fmtCost)(h.totalCost)})]})]})})]}),(0,t.jsxs)(l.default,{className:"overflow-hidden",children:[(0,t.jsx)("div",{className:"p-4 border-b border-border bg-bg-subtle/50",children:(0,t.jsx)("h3",{className:"font-semibold",children:"Usage by Model"})}),(0,t.jsx)("div",{className:"overflow-x-auto",children:(0,t.jsxs)("table",{className:"w-full text-sm text-left",children:[(0,t.jsx)("thead",{className:"bg-bg-subtle/30 text-text-muted uppercase text-xs",children:(0,t.jsxs)("tr",{children:[(0,t.jsxs)("th",{className:"px-6 py-3 cursor-pointer hover:bg-bg-subtle/50",onClick:()=>C("rawModel"),children:["Model ",(0,t.jsx)(c,{field:"rawModel",currentSort:x,currentOrder:p})]}),(0,t.jsxs)("th",{className:"px-6 py-3 cursor-pointer hover:bg-bg-subtle/50",onClick:()=>C("provider"),children:["Provider"," ",(0,t.jsx)(c,{field:"provider",currentSort:x,currentOrder:p})]}),(0,t.jsxs)("th",{className:"px-6 py-3 text-right cursor-pointer hover:bg-bg-subtle/50",onClick:()=>C("requests"),children:["Requests"," ",(0,t.jsx)(c,{field:"requests",currentSort:x,currentOrder:p})]}),(0,t.jsxs)("th",{className:"px-6 py-3 text-right cursor-pointer hover:bg-bg-subtle/50",onClick:()=>C("lastUsed"),children:["Last Used"," ",(0,t.jsx)(c,{field:"lastUsed",currentSort:x,currentOrder:p})]}),"tokens"===j?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("th",{className:"px-6 py-3 text-right cursor-pointer hover:bg-bg-subtle/50",onClick:()=>C("promptTokens"),children:["Input Tokens"," ",(0,t.jsx)(c,{field:"promptTokens",currentSort:x,currentOrder:p})]}),(0,t.jsxs)("th",{className:"px-6 py-3 text-right cursor-pointer hover:bg-bg-subtle/50",onClick:()=>C("completionTokens"),children:["Output Tokens"," ",(0,t.jsx)(c,{field:"completionTokens",currentSort:x,currentOrder:p})]}),(0,t.jsxs)("th",{className:"px-6 py-3 text-right cursor-pointer hover:bg-bg-subtle/50",onClick:()=>C("totalTokens"),children:["Total Tokens"," ",(0,t.jsx)(c,{field:"totalTokens",currentSort:x,currentOrder:p})]})]}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("th",{className:"px-6 py-3 text-right cursor-pointer hover:bg-bg-subtle/50",onClick:()=>C("promptTokens"),children:["Input Cost"," ",(0,t.jsx)(c,{field:"promptTokens",currentSort:x,currentOrder:p})]}),(0,t.jsxs)("th",{className:"px-6 py-3 text-right cursor-pointer hover:bg-bg-subtle/50",onClick:()=>
1C("completionTokens"),children:["Output Cost"," ",(0,t.jsx)(c,{field:"completionTokens",currentSort:x,currentOrder:p})]}),(0,t.jsxs)("th",{className:"px-6 py-3 text-right cursor-pointer hover:bg-bg-subtle/50",onClick:()=>C("cost"),children:["Total Cost"," ",(0,t.jsx)(c,{field:"cost",currentSort:x,currentOrder:p})]})]})]})}),(0,t.jsxs)("tbody",{className:"divide-y divide-border",children:[E.map(e=>(0,t.jsxs)("tr",{className:"hover:bg-bg-subtle/20",children:[(0,t.jsx)("td",{className:`px-6 py-3 font-medium transition-colors ${e.pending>0?"text-primary":""}`,children:e.rawModel}),(0,t.jsx)("td",{className:"px-6 py-3",children:(0,t.jsx)(i.default,{variant:e.pending>0?"primary":"default",size:"sm",children:e.provider})}),(0,t.jsx)("td",{className:"px-6 py-3 text-right",children:A(e.requests)}),(0,t.jsx)("td",{className:"px-6 py-3 text-right text-text-muted whitespace-nowrap",children:D(e.lastUsed)}),"tokens"===j?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("td",{className:"px-6 py-3 text-right text-text-muted",children:A(e.promptTokens)}),(0,t.jsx)("td",{className:"px-6 py-3 text-right text-text-muted",children:A(e.completionTokens)}),(0,t.jsx)("td",{className:"px-6 py-3 text-right font-medium",children:A(e.totalTokens)})]}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("td",{className:"px-6 py-3 text-right text-text-muted",children:(0,o.fmtCost)(e.inputCost)}),(0,t.jsx)("td",{className:"px-6 py-3 text-right text-text-muted",children:(0,o.fmtCost)(e.outputCost)}),(0,t.jsx)("td",{className:"px-6 py-3 text-right font-medium text-warning",children:(0,o.fmtCost)(e.totalCost)})]})]},e.key)),0===E.length&&(0,t.jsx)("tr",{children:(0,t.jsx)("td",{colSpan:8,className:"px-6 py-8 text-center text-text-muted",children:"No usage recorded yet. Make some requests to see data here."})})]})]})})]}),(0,t.jsxs)(l.default,{className:"overflow-hidden",children:[(0,t.jsx)("div",{className:"p-4 border-b border-border bg-bg-subtle/50",children:(0,t.jsx)("h3",{className:"font-semibold",children:"Usage by Account"})}),(0,t.jsx)("div",{className:"overflow-x-auto",children:(0,t.jsxs)("table",{className:"w-full text-sm text-left",children:[(0,t.jsx)("thead",{className:"bg-bg-subtle/30 text-text-muted uppercase text-xs",children:(0,t.jsxs)("tr",{children:[(0,t.jsxs)("th",{className:"px-6 py-3 cursor-pointer hover:bg-bg-subtle/50",onClick:()=>C("rawModel"),children:["Model ",(0,t.jsx)(c,{field:"rawModel",currentSort:x,currentOrder:p})]}),(0,t.jsxs)("th",{className:"px-6 py-3 cursor-pointer hover:bg-bg-subtle/50",onClick:()=>C("provider"),children:["Provider"," ",(0,t.jsx)(c,{field:"provider",currentSort:x,currentOrder:p})]}),(0,t.jsxs)("th",{className:"px-6 py-3 cursor-pointer hover:bg-bg-subtle/50",onClick:()=>C("accountName"),children:["Account"," ",(0,t.jsx)(c,{field:"accountName",currentSort:x,currentOrder:p})]}),(0,t.jsxs)("th",{className:"px-6 py-3 text-right cursor-pointer hover:bg-bg-subtle/50",onClick:()=>C("requests"),children:["Requests"," ",(0,t.jsx)(c,{field:"requests",currentSort:x,currentOrder:p})]}),(0,t.jsxs)("th",{className:"px-6 py-3 text-right cursor-pointer hover:bg-bg-subtle/50",onClick:()=>C("lastUsed"),children:["Last Used"," ",(0,t.jsx)(c,{field:"lastUsed",currentSort:x,currentOrder:p})]}),"tokens"===j?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("th",{className:"px-6 py-3 text-right cursor-pointer hover:bg-bg-subtle/50",onClick:()=>C("promptTokens"),children:["Input Tokens"," ",(0,t.jsx)(c,{field:"promptTokens",currentSort:x,currentOrder:p})]}),(0,t.jsxs)("th",{className:"px-6 py-3 text-right cursor-pointer hover:bg-bg-subtle/50",onClick:()=>C("completionTokens"),children:["Output Tokens"," ",(0,t.jsx)(c,{field:"completionTokens",currentSort:x,currentOrder:p})]}),(0,t.jsxs)("th",{className:"px-6 py-3 text-right cursor-pointer hover:bg-bg-subtle/50",onClick:()=>C("totalTokens"),children:["Total Tokens"," ",(0,t.jsx)(c,{field:"totalTokens",currentSort:x,currentOrder:p})]})]}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("th",{className:"px-6 py-3 text-right cursor-pointer hover:bg-bg-subtle/50",onClick:()=>C("promptTokens"),children:["Input Cost"," ",(0,t.jsx)(c,{field:"promptTokens",currentSort:x,currentOrder:p})]}),(0,t.jsxs)("th",{className:"px-6 py-3 text-right cursor-pointer hover:bg-bg-subtle/50",onClick:()=>
1C("completionTokens"),children:["Output Cost"," ",(0,t.jsx)(c,{field:"completionTokens",currentSort:x,currentOrder:p})]}),(0,t.jsxs)("th",{className:"px-6 py-3 text-right cursor-pointer hover:bg-bg-subtle/50",onClick:()=>C("cost"),children:["Total Cost"," ",(0,t.jsx)(c,{field:"cost",currentSort:x,currentOrder:p})]})]})]})}),(0,t.jsxs)("tbody",{className:"divide-y divide-border",children:[_.map(e=>(0,t.jsxs)("tr",{className:"hover:bg-bg-subtle/20",children:[(0,t.jsx)("td",{className:`px-6 py-3 font-medium transition-colors ${e.pending>0?"text-primary":""}`,children:e.rawModel}),(0,t.jsx)("td",{className:"px-6 py-3",children:(0,t.jsx)(i.default,{variant:e.pending>0?"primary":"default",size:"sm",children:e.provider})}),(0,t.jsx)("td",{className:"px-6 py-3",children:(0,t.jsx)("span",{className:`font-medium transition-colors ${e.pending>0?"text-primary":""}`,children:e.accountName||`Account ${e.connectionId?.slice(0,8)}...`})}),(0,t.jsx)("td",{className:"px-6 py-3 text-right",children:A(e.requests)}),(0,t.jsx)("td",{className:"px-6 py-3 text-right text-text-muted whitespace-nowrap",children:D(e.lastUsed)}),"tokens"===j?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("td",{className:"px-6 py-3 text-right text-text-muted",children:A(e.promptTokens)}),(0,t.jsx)("td",{className:"px-6 py-3 text-right text-text-muted",children:A(e.completionTokens)}),(0,t.jsx)("td",{className:"px-6 py-3 text-right font-medium",children:A(e.totalTokens)})]}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("td",{className:"px-6 py-3 text-right text-text-muted",children:(0,o.fmtCost)(e.inputCost)}),(0,t.jsx)("td",{className:"px-6 py-3 text-right text-text-muted",children:(0,o.fmtCost)(e.outputCost)}),(0,t.jsx)("td",{className:"px-6 py-3 text-right font-medium text-warning",children:(0,o.fmtCost)(e.totalCost)})]})]},e.key)),0===_.length&&(0,t.jsx)("tr",{children:(0,t.jsx)("td",{colSpan:9,className:"px-6 py-8 text-center text-text-muted",children:"No account-specific usage recorded yet. Make requests using OAuth accounts to see data here."})})]})]})})]})]})}])},566770,801646,e=>{"use strict";var t=e.i(843476),s=e.i(271645),r=e.i(861745),a=e.i(948148),l=e.i(393718),i=e.i(454149),n=e.i(243009);async function o(e,t){try{let t=await e.json(),s=t?.error;if("string"==typeof s&&s.trim())return s.trim();if(s&&"object"==typeof s){let e=s.message;if("string"==typeof e&&e.trim())return e.trim()}}catch{}return t}let c=["#f59e0b","#ef4444","#8b5cf6","#10b981","#06b6d4","#ec4899","#f97316","#6366f1","#14b8a6","#a855f7"],d={priority:"serviceTierFast",flex:"serviceTierFlex",standard:"serviceTierStandard"},u={priority:"Fast",flex:"Flex",standard:"Standard"};function m(e){let t="string"==typeof e?e.trim().toLowerCase():"";return"priority"===t||"fast"===t?"priority":"flex"===t?"flex":"standard"}function x(e,t,s){return"function"==typeof e.has&&e.has(t)?e(t):s}function p(e,t,s){let r=m(t),a="string"==typeof s?s.trim():"",l=a&&m(a)!==r?a:u[r];return x(e,d[r],l)}e.s(["getServiceTierDisplayLabel",0,p,"translateCostText",0,x],801646);var h=e.i(484124);let b=new Set(["model"]),f=[{field:"model",labelKey:"chartModel",align:"left"},{field:"requests",labelKey:"chartRequests",align:"right"},{field:"promptTokens",labelKey:"chartInput",align:"right"},{field:"completionTokens",labelKey:"chartOutput",align:"right"},{field:"totalTokens",labelKey:"chartTotal",align:"right"},{field:"cost",labelKey:"chartCost",align:"right"}];function g({active:e,sortOrder:s}){return e?(0,t.jsx)("span",{className:"material-symbols-outlined text-[12px] text-primary",children:"asc"===s?"expand_less":"expand_more"}):(0,t.jsx)("span",{className:"material-symbols-outlined text-[12px] opacity-0 group-hover:opacity-30",children:"unfold_more"})}function y({byModel:e,summary:r}){let i=(0,a.useTranslations)("analytics"),[o,c]=(0,s.useState)({by:"totalTokens",order:"desc"}),d=(0,s.useCallback)(e=>{c(t=>{var s,r;let a=(s=t.by,r=t.order,s===e?{sortBy:e,sortOrder:"asc"===r?"desc":"asc"}:{sortBy:e,sortOrder:"desc"});return{by:a.sortBy,order:a.sortOrder}})},[]),u=(0,s.useMemo)(()=>{let t;return t=Number(r?.totalTokens??0),(e||[]).map(e=>{if(void 0!==e.pct&&null!==e.pct&&""!==e.pct)return{...e};let s=Number(e.totalTokens??0),r=t>0?(s/t*100).toFixed(1):"0";return{...e,pct:r}}
1)},[e,r?.totalTokens]),m=(0,s.useMemo)(()=>{var e,t;let s;return e=o.by,t=o.order,(s=[...u||[]]).sort((s,r)=>{let a=s[e],l=r[e];if(b.has(e)||"string"==typeof a||"string"==typeof l){let e=String(a??""),s=String(l??""),r=e.localeCompare(s,void 0,{sensitivity:"base",numeric:!0});return"asc"===t?r:-r}let i=Number(a??0),n=Number(l??0),o=Number.isFinite(i)?i:0,c=Number.isFinite(n)?n:0;return"asc"===t?o-c:c-o}),s},[u,o.by,o.order]);return(0,t.jsxs)(l.default,{className:"overflow-hidden",children:[(0,t.jsx)("div",{className:"p-4 border-b border-border",children:(0,t.jsx)("h3",{className:"text-sm font-semibold text-text-muted uppercase tracking-wider",children:i("chartModelBreakdown")})}),(0,t.jsx)("div",{className:"overflow-x-auto",children:(0,t.jsxs)("table",{className:"w-full text-sm",children:[(0,t.jsx)("thead",{className:"text-xs text-text-muted uppercase bg-black/[0.02] dark:bg-white/[0.02]",children:(0,t.jsxs)("tr",{children:[f.map(e=>(0,t.jsx)("th",{className:`px-4 py-2.5 ${"right"===e.align?"text-right":"text-left"}`,children:(0,t.jsxs)("button",{type:"button",className:`inline-flex items-center gap-1 cursor-pointer group hover:text-text-main ${"right"===e.align?"justify-end w-full":"justify-start"}`,onClick:()=>d(e.field),children:[(0,t.jsx)("span",{children:i(e.labelKey)}),(0,t.jsx)(g,{active:o.by===e.field,sortOrder:o.order})]})},e.field)),(0,t.jsx)("th",{className:"px-4 py-2.5 text-right w-36",children:i("chartShare")})]})}),(0,t.jsx)("tbody",{className:"divide-y divide-border",children:m.map((e,s)=>(0,t.jsxs)("tr",{className:"hover:bg-black/[0.02] dark:hover:bg-white/[0.02] transition-colors",children:[(0,t.jsx)("td",{className:"px-4 py-2.5",children:(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("span",{className:"w-2 h-2 rounded-full shrink-0",style:{backgroundColor:(0,h.getModelColor)(s)}}),(0,t.jsx)("span",{className:"font-medium",children:e.model})]})}),(0,t.jsx)("td",{className:"px-4 py-2.5 text-right font-mono text-text-muted",children:(0,n.fmtFull)(e.requests)}),(0,t.jsx)("td",{className:"px-4 py-2.5 text-right font-mono text-primary",children:(0,n.fmtCompact)(e.promptTokens)}),(0,t.jsx)("td",{className:"px-4 py-2.5 text-right font-mono text-emerald-500",children:(0,n.fmtCompact)(e.completionTokens)}),(0,t.jsx)("td",{className:"px-4 py-2.5 text-right font-mono font-semibold",children:(0,n.fmtCompact)(e.totalTokens)}),(0,t.jsx)("td",{className:"px-4 py-2.5 text-right font-mono text-amber-500",children:(0,n.fmtCost)(e.cost)}),(0,t.jsx)("td",{className:"px-4 py-2.5 text-right",children:(0,t.jsxs)("div",{className:"flex items-center gap-2 justify-end",children:[(0,t.jsx)("div",{className:"w-16 h-1.5 rounded-full bg-white/[0.06] overflow-hidden",children:(0,t.jsx)("div",{className:"h-full rounded-full transition-all",style:{width:`${e.pct??0}%`,backgroundColor:(0,h.getModelColor)(s)}})}),(0,t.jsxs)("span",{className:"text-xs font-mono text-text-muted w-10 text-right",children:[e.pct??0,"%"]})]})})]},String(e.model??s)))})]})})]})}function v(e,t){try{return new Intl.DateTimeFormat(e,t)}catch{return new Intl.DateTimeFormat(void 0,t)}}function j({active:e,sortOrder:s}){return e?(0,t.jsx)("span",{className:"material-symbols-outlined text-[12px] text-primary",children:"asc"===s?"expand_less":"expand_more"}):(0,t.jsx)("span",{className:"material-symbols-outlined text-[12px] opacity-0 group-hover:opacity-30",children:"unfold_more"})}function k({icon:e,label:s,value:r,subValue:a,color:i="text-text-main"}){return(0,t.jsxs)(l.default,{className:"px-4 py-3 flex flex-col gap-1 min-w-0",children:[(0,t.jsxs)("div",{className:"flex items-center gap-1.5 text-text-muted text-[11px] uppercase font-semibold tracking-wide min-w-0",children:[(0,t.jsx)("span",{className:"material-symbols-outlined text-[14px] shrink-0",children:e}),(0,t.jsx)("span",{className:"truncate",children:s})]}),(0,t.jsx)("span",{className:`text-2xl font-bold ${i} truncate`,title:String(r),children:r}),a&&(0,t.jsx)("span",{className:"text-xs text-text-muted truncate",children:a})]})}function N({sections:e}){return(0,t.jsx)(l.default,{className:"px-5 py-4",children:(0,t.jsx)("div",{className:"flex flex-col gap-3",children:e.map((e,s)=>(0,t.jsxs)("div",{children:[s>0&&(0,t.jsx)("div",{className:"border-t border-black/[0.06] dark:border-white/[0.06] mb-3"}),(0,t.jsx)("div",{className:"text-[10px] uppercase font-semibold tracking-widest text-text-muted/50 mb-2",children:e.title}),(0,t.jsx)("div",{className:e.wideValues?"grid grid-cols-1 sm:grid-cols-2 md:grid-cols-4 gap-x-5 gap-y-2":"grid grid-cols-2 md:grid-cols-4 gap-x-5 gap-y-2",children:e.items.map((s,r)=>(0,t.jsxs)("div",{className:"flex items-center justify-between gap-2 min-w-0 py-0.5",children:[(0,t.jsxs)("div",{className:`flex items-center gap-1.5 ${e.wideValues?"shrink-0":"min-w-0"}`,children:[(0,t.jsx)("span",{className:"material-symbols-outlined text-[14px] text-text-muted shrink-0",children:s.icon}),(0,t.jsx)("span",{className:`text-[11px] uppercase font-semibold tracking-wide text-text-muted ${e.wideValues?"whitespace-nowrap":"truncate"}`,children:s.label})]}),(0,t.jsx)("span",{className:`text-sm font-bold text-right ${e.wideValues?"truncate min-w-0":"shrink-0"} ${s.color||"text-text-main"}
1`,title:String(s.value),children:s.value})]},r))})]},s))})})}function w({activityMap:e}){let i=(0,a.useTranslations)("analytics"),o=(0,r.useLocale)(),c=(0,s.useRef)(null),d=(0,s.useMemo)(()=>v(o,{month:"short"}),[o]),u=(0,s.useMemo)(()=>v(o,{weekday:"short"}),[o]),m=(0,s.useMemo)(()=>{let t=new Date,s=[],r=0;for(let a=364;a>=0;a--){let l=new Date(t);l.setDate(l.getDate()-a);let i=`${l.getFullYear()}-${String(l.getMonth()+1).padStart(2,"0")}-${String(l.getDate()).padStart(2,"0")}`,n=e?.[i]||0;n>r&&(r=n),s.push({date:i,value:n,dayOfWeek:l.getDay()})}return{days:s,maxVal:r}},[e]),x=(0,s.useMemo)(()=>{let e=[],t=[],s=m.days[0]?.dayOfWeek||0;for(let e=0;e<s;e++)t.push(null);for(let s of m.days)t.push(s),7===t.length&&(e.push(t),t=[]);return t.length>0&&e.push(t),e},[m]);(0,s.useEffect)(()=>{c.current&&(c.current.scrollLeft=c.current.scrollWidth)},[x]);let p=(0,s.useMemo)(()=>{let e=[],t=-1;return x.forEach((s,r)=>{let a=s.find(e=>null!==e);if(a){let s=new Date(a.date).getMonth();s!==t&&(e.push({weekIdx:r,label:d.format(new Date(2024,s,1))}),t=s)}}),e},[d,x]),h=(0,s.useMemo)(()=>[1,3,5].map(e=>u.format(new Date(2024,0,7+e))),[u]);return(0,t.jsxs)(l.default,{className:"p-4 h-full min-w-0 overflow-hidden",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between mb-3",children:[(0,t.jsx)("h3",{className:"text-sm font-semibold text-text-muted uppercase tracking-wider",children:i("overview")}),(0,t.jsx)("span",{className:"text-xs text-text-muted",children:i("activitySummary",{active:Object.keys(e||{}).length,tokens:(0,n.fmtCompact)(Object.values(e||{}).reduce((e,t)=>e+t,0)),days:365})})]}),(0,t.jsx)("div",{ref:c,className:"overflow-x-auto",children:(0,t.jsxs)("div",{className:"w-max",children:[(0,t.jsx)("div",{className:"flex gap-[3px] mb-1 ml-6",style:{fontSize:"10px"},children:p.map((e,s)=>(0,t.jsx)("span",{className:"text-text-muted",style:{position:"relative",left:`${13*e.weekIdx}px`,marginLeft:0===s?0:"-20px"},children:e.label},s))}),(0,t.jsxs)("div",{className:"flex gap-[3px]",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-[3px] shrink-0 text-[10px] text-text-muted pr-1 sticky left-0 z-10 bg-surface",children:[(0,t.jsx)("span",{className:"h-[10px]"}),(0,t.jsx)("span",{className:"h-[10px] leading-[10px]",children:h[0]}),(0,t.jsx)("span",{className:"h-[10px]"}),(0,t.jsx)("span",{className:"h-[10px] leading-[10px]",children:h[1]}),(0,t.jsx)("span",{className:"h-[10px]"}),(0,t.jsx)("span",{className:"h-[10px] leading-[10px]",children:h[2]}),(0,t.jsx)("span",{className:"h-[10px]"})]}),x.map((e,s)=>(0,t.jsx)("div",{className:"flex flex-col gap-[3px]",children:e.map((e,s)=>(0,t.jsx)("div",{title:e?i("activityCellTitle",{date:e.date,tokens:(0,n.fmtFull)(e.value)}):"",className:`w-[10px] h-[10px] rounded-[2px] ${e?function(e){if(!e||0===e)return"bg-white/[0.04]";let t=Math.min(e/(m.maxVal||1),1);return t<.25?"bg-primary/20":t<.5?"bg-primary/40":t<.75?"bg-primary/60":"bg-primary/90"}(e.value):"bg-transparent"}`},s))},s))]})]})}),(0,t.jsxs)("div",{className:"flex items-center gap-1 mt-2 ml-6 text-[10px] text-text-muted",children:[(0,t.jsx)("span",{children:i("activityLess")}),(0,t.jsx)("div",{className:"w-[10px] h-[10px] rounded-[2px] bg-white/[0.04]"}),(0,t.jsx)("div",{className:"w-[10px] h-[10px] rounded-[2px] bg-primary/20"}),(0,t.jsx)("div",{className:"w-[10px] h-[10px] rounded-[2px] bg-primary/40"}),(0,t.jsx)("div",{className:"w-[10px] h-[10px] rounded-[2px] bg-primary/60"}),(0,t.jsx)("div",{className:"w-[10px] h-[10px] rounded-[2px] bg-primary/90"}),(0,t.jsx)("span",{children:i("activityMore")})]})]})}function S({byApiKey:e}){let r=(0,a.useTranslations)("analytics"),[i,o]=(0,s.useState)(""),[c,d]=(0,s.useState)("totalTokens"),[u,m]=(0,s.useState)("desc"),x=(0,s.useMemo)(()=>e||[],[e]),p=(0,s.useMemo)(()=>{let e=i.trim().toLowerCase();return e?x.filter(t=>(t.apiKeyName||"").toLowerCase().includes(e)||(t.apiKeyId||"").toLowerCase().includes(e)):x},[x,i]),h=(0,s.useMemo)(()=>{let e=[...p];return e.sort((e,t)=>{let s=e[c]??0,r=t[c]??0;return"string"==typeof s?"asc"===u?s.localeCompare(r):r.localeCompare(s):"asc"===u?s-r:r-s}),e},[p,c,u]),b=(0,s.useCallback)(e=>{c===e?m(e=>"asc"===e?"desc":"asc"):(d(e),m("desc"))},[c]);return x.length>0?(0,t.jsxs)(l.default,{className:"overflow-hidden",children:[(0,t.jsxs)("div",{className:"p-4 border-b border-border flex items-center justify-between gap-3",children:[(0,t.jsx)("h3",{className:"text-sm font-semibold text-text-muted uppercase tracking-wider",children:r("chartApiKeyBreakdown")}),(0,t.jsx)("input",{type:"text",value:i,onChange:e=>o(e.target.value),placeholder:r("filterSearchKeys"),className:"w-full max-w-[220px] px-3 py-1.5 rounded-lg bg-bg-subtle border border-border text-xs text-text-primary placeholder:text-text-muted focus:outline-none focus:border-primary"})]}),(0,t.jsx)("div",{className:"overflow-x-auto",children:(0,t.jsxs)("table",{className:"w-full text-sm",children:[(0,t.jsx)("thead",{className:"text-xs text-text-muted uppercase bg-black/[0.02] dark:bg-white/[0.02]",children:(0,t.jsxs)("tr",{children:[(0,t.jsxs)("th",{className:"px-4 py-2.5 text-left cursor-pointer group",onClick:()=>b("apiKeyName"),children:[r("chartApiKey")," ",(0,t.jsx)(j,{active:"apiKeyName"===c,sortOrder:u})]}),(0,t.jsxs)("th",{className:"px-4 py-2.5 text-right cursor-pointer group",onClick:()=>b("requests"),children:[r("chartRequests")," ",(0,t.jsx)(j,{active:"requests"===c,sortOrder:u})]}),(0,t.jsxs)("th",{className:"px-4 py-2.5 text-right cursor-pointer group",onClick:()=>b("promptTokens"),children:[r("chartInput")," ",(0,t.jsx)(j,{active:"promptTokens"===c,sortOrder:u})]}),(0,t.jsxs)("th",{className:"px-4 py-2.5 text-right cursor-pointer group",onClick:()=>b("completionTokens"),children:[r("chartOutput")," ",(0,t.jsx)(j,{active:"completionTokens"===c,sortOrder:u})]}),(0,t.jsxs)("th",{className:"px-4 py-2.5 text-right cursor-pointer group",onClick:()=>b("totalTokens"),children:[r("chartTotal")," ",(0,t.jsx)(j,{active:"totalTokens"===c,sortOrder:u})]}),(0,t.jsxs)("th",{className:"px-4 py-2.5 text-right cursor-pointer group",onClick:()=>b("cost"),children:[r("chartCost")," ",(0,t.jsx)(j,{active:"cost"===c,sortOrder:u})]})]})}),(0,t.jsxs)("tbody",{className:"divide-y divide-border",children:[h.map((e,s)=>(0,t.jsxs)("tr",{className:"hover:bg-black/[0.02] dark:hover:bg-white/[0.02] transition-colors",children:[(0,t.jsx)("td",{className:"px-4 py-2.5",children:(0,t.jsx)("span",{className:"font-medium",title:e.apiKeyName||e.apiKeyId||"unknown",children:(0,n.formatApiKeyLabel)(e.apiKeyName,e.apiKeyId)})}),(0,t.jsx)("td",{className:"px-4 py-2.5 text-right font-mono text-text-muted",children:(0,n.fmtFull)(e.requests)}),(0,t.jsx)("td",{className:"px-4 py-2.5 text-right font-mono text-primary",children:(0,n.fmtCompact)(e.promptTokens)}),(0,t.jsx)("td",{className:"px-4 py-2.5 text-right font-mono text-emerald-500",children:(0,n.fmtCompact)(e.completionTokens)}),(0,t.jsx)("td",{className:"px-4 py-2.5 text-right font-mono font-semibold",children:(0,n.fmtCompact)(e.totalTokens)}),(0,t.jsx)("td",{className:"px-4 py-2.5 text-right font-mono text-amber-500",children:(0,n.fmtCost)(e.cost)})]},`${e.apiKeyId||e.apiKeyName||"key"}-${s}`)),0===h.length&&(0,t.jsx)("tr",{children:(0,t.jsx)("td",{colSpan:6,className:"px-4 py-8 text-center text-text-muted",children:r("filterNoKeysMatch")})})]})]})})]}):(0,t.jsxs)(l.default,{className:"p-4 flex-1",children:[(0,t.jsx)("h3",{className:"text-sm font-semibold text-text-muted uppercase tracking-wider mb-3",children:r("chartApiKeyBreakdown")}),(0,t.jsx)("div",{className:"text-center text-text-muted text-sm py-8",children:r("chartNoData")})]})}function C({activityMap:e}){let i=(0,a.useTranslations)("analytics"),o=(0,r.useLocale)(),c=(0,s.useMemo)(()=>v(o,{weekday:"long"}),[o]),d=(0,s.useMemo)(()=>v(o,{month:"short",day:"numeric"}
1),[o]),u=(0,s.useMemo)(()=>{if(!e)return null;let t=new Date,s=null,r=0;for(let a=0;a<7;a++){let l=new Date(t);l.setDate(l.getDate()-a);let i=`${l.getFullYear()}-${String(l.getMonth()+1).padStart(2,"0")}-${String(l.getDate()).padStart(2,"0")}`,n=e[i]||0;n>r&&(r=n,s=i)}if(!s||0===r)return null;let a=new Date(s+"T12:00:00");return{weekday:c.format(a),label:d.format(a),tokens:r}},[e,d,c]);return(0,t.jsxs)(l.default,{className:"p-4 flex flex-col justify-center",style:{flex:1,minHeight:0},children:[(0,t.jsx)("h3",{className:"text-xs font-semibold uppercase tracking-wider mb-2",style:{color:"var(--color-text-muted)"},children:i("mostActiveDay")}),u?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("span",{className:"text-xl font-bold capitalize",style:{lineHeight:1.2},children:u.weekday}),(0,t.jsx)("span",{className:"text-xs mt-1",style:{color:"var(--color-text-muted)"},children:i("datedTokenCount",{date:u.label,tokens:(0,n.fmtCompact)(u.tokens)})})]}):(0,t.jsx)("span",{className:"text-xs",style:{color:"var(--color-text-muted)"},children:i("noDataLast7Days")})]})}function T({activityMap:e}){let i=(0,a.useTranslations)("analytics"),o=(0,r.useLocale)(),c=(0,s.useMemo)(()=>v(o,{weekday:"short"}),[o]),d=(0,s.useMemo)(()=>v(o,{month:"short",day:"numeric"}),[o]),u=(0,s.useMemo)(()=>{if(!e)return[];let t=new Date,s=[],r=0;for(let a=6;a>=0;a--){let l=new Date(t);l.setDate(l.getDate()-a);let i=`${l.getFullYear()}-${String(l.getMonth()+1).padStart(2,"0")}-${String(l.getDate()).padStart(2,"0")}`,n=e[i]||0;n>r&&(r=n),s.push({key:i,val:n,label:c.format(l),dateLabel:d.format(l)})}return s.map(e=>({...e,intensity:r>0?e.val/r:0}))},[e,d,c]);return(0,t.jsxs)(l.default,{className:"p-4 flex flex-col justify-center",style:{flex:1,minHeight:0},children:[(0,t.jsx)("h3",{className:"text-xs font-semibold uppercase tracking-wider mb-3",style:{color:"var(--color-text-muted)"},children:i("chartWeekly")}),(0,t.jsx)("div",{style:{display:"flex",alignItems:"flex-end",gap:6,justifyContent:"center"},children:u.map((e,s)=>{var r;return(0,t.jsxs)("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:4},children:[(0,t.jsx)("div",{title:i("activityCellTitle",{date:e.dateLabel,tokens:(0,n.fmtFull)(e.val)}),style:{width:36,height:36,borderRadius:8,...0===(r=e.intensity)?{background:"rgba(255,255,255,0.04)"}:{background:`rgba(229, 77, 94, ${(.15+.75*r).toFixed(2)})`},transition:"all 0.2s",cursor:"default"}}),(0,t.jsx)("span",{style:{fontSize:9,fontWeight:600,color:"var(--color-text-muted)",letterSpacing:"0.03em"},children:e.label})]},e.key)})})]})}function E({byServiceTier:e,summary:r}){let i=(0,a.useTranslations)("costs"),o=(0,a.useTranslations)("analytics"),c=(0,s.useMemo)(()=>e||[],[e]),d=Number(r?.totalRequests||0),u=Number(r?.totalCost||0);return c.length?(0,t.jsxs)(l.default,{className:"overflow-hidden",children:[(0,t.jsxs)("div",{className:"p-4 border-b border-border flex items-center justify-between gap-3",children:[(0,t.jsx)("h3",{className:"text-sm font-semibold text-text-muted uppercase tracking-wider",children:x(i,"serviceTierBreakdownTitle","Service Tier")}),(0,t.jsx)("span",{className:"text-[11px] text-text-muted",children:x(i,"serviceTierBreakdownSubtitle","Fast / Flex / Standard split")})]}),(0,t.jsx)("div",{className:"divide-y divide-border",children:c.map(e=>{var s,r,a;let l="flex"===e.serviceTier,c=p(i,e.serviceTier,e.label),m=d>0?(Number(e.requests||0)/d*100).toFixed(1):"0",h=u>0?(Number(e.cost||0)/u*100).toFixed(1):"0",b=Number(e.usageSavingsTokens||0),f=Number(e.savings||0),g=l&&b>0?` \xb7 ${(0,n.fmtCompact)(b)} ${x(i,"serviceTierUsageSaved","usage saved")}`:"",y=l&&f>0?`${(0,n.fmtCost)(f)} ${x(i,"serviceTierCostSaved","saved")}`:`${h}% ${x(i,"serviceTierCostShareSuffix","of cost")}`;return(0,t.jsxs)("div",{className:"p-4 flex flex-col gap-3",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("span",{className:`material-symbols-outlined text-[18px] ${"priority"===(s=e.serviceTier)?"text-sky-500":"flex"===s?"text-emerald-500":"text-text-muted"}`,children:"priority"===(r=e.serviceTier)?"bolt":"flex"===r?"savings":"speed"}),(0,t.jsxs)("div",{children:[(0,t.jsx)("div",{className:"text-sm font-semibold text-text-main",children:c}),(0,t.jsxs)("div",{className:"text-xs text-text-muted",children:[o("requestTokenSummary",{requests:(0,n.fmtFull)(e.requests),tokens:(0,n.fmtCompact)(e.totalTokens)}),g]})]})]}),(0,t.jsxs)("div",{className:"text-right",children:[(0,t.jsx)("div",{className:`font-mono text-sm font-semibold ${"flex"===e.serviceTier?"text-emerald-500":"text-amber-500"}`,children:(0,n.fmtCost)(e.cost)}),(0,t.jsx)("div",{className:"text-xs text-text-muted",children:y})]})]}),(0,t.jsx)("div",{className:"h-1.5 rounded-full bg-black/5 dark:bg-white/10 overflow-hidden",children:(0,t.jsx)("div",{className:`h-full rounded-full ${"priority"===(a=e.serviceTier)?"bg-sky-500":"flex"===a?"bg-emerald-500":"bg-text-muted/50"}`,style:{width:`${m}%`}})})]},e.serviceTier)})})]}):null}function _({byProvider:e}
1){let r=(0,a.useTranslations)("analytics"),[i,o]=(0,s.useState)("totalTokens"),[d,u]=(0,s.useState)("desc"),m=(0,s.useMemo)(()=>e||[],[e]),x=(0,s.useMemo)(()=>m.reduce((e,t)=>e+t.totalTokens,0),[m]),p=(0,s.useCallback)(e=>{i===e?u(e=>"asc"===e?"desc":"asc"):(o(e),u("desc"))},[i]),h=(0,s.useMemo)(()=>{let e=[...m];return e.sort((e,t)=>{let s=e[i]??0,r=t[i]??0;return"string"==typeof s?"asc"===d?s.localeCompare(r):r.localeCompare(s):"asc"===d?s-r:r-s}),e},[m,i,d]);return m.length?(0,t.jsxs)(l.default,{className:"overflow-hidden",children:[(0,t.jsx)("div",{className:"p-4 border-b border-border",children:(0,t.jsx)("h3",{className:"text-sm font-semibold text-text-muted uppercase tracking-wider",children:r("chartProviderBreakdown")})}),(0,t.jsx)("div",{className:"overflow-x-auto",children:(0,t.jsxs)("table",{className:"w-full text-sm",children:[(0,t.jsx)("thead",{className:"text-xs text-text-muted uppercase bg-black/[0.02] dark:bg-white/[0.02]",children:(0,t.jsxs)("tr",{children:[(0,t.jsxs)("th",{className:"px-4 py-2.5 text-left cursor-pointer group",onClick:()=>p("provider"),children:[r("chartProvider")," ",(0,t.jsx)(j,{active:"provider"===i,sortOrder:d})]}),(0,t.jsxs)("th",{className:"px-4 py-2.5 text-right cursor-pointer group",onClick:()=>p("requests"),children:[r("chartRequests")," ",(0,t.jsx)(j,{active:"requests"===i,sortOrder:d})]}),(0,t.jsxs)("th",{className:"px-4 py-2.5 text-right cursor-pointer group",onClick:()=>p("promptTokens"),children:[r("chartInput")," ",(0,t.jsx)(j,{active:"promptTokens"===i,sortOrder:d})]}),(0,t.jsxs)("th",{className:"px-4 py-2.5 text-right cursor-pointer group",onClick:()=>p("completionTokens"),children:[r("chartOutput")," ",(0,t.jsx)(j,{active:"completionTokens"===i,sortOrder:d})]}),(0,t.jsxs)("th",{className:"px-4 py-2.5 text-right cursor-pointer group",onClick:()=>p("totalTokens"),children:[r("chartTotal")," ",(0,t.jsx)(j,{active:"totalTokens"===i,sortOrder:d})]}),(0,t.jsxs)("th",{className:"px-4 py-2.5 text-right cursor-pointer group",onClick:()=>p("cost"),children:[r("chartCost")," ",(0,t.jsx)(j,{active:"cost"===i,sortOrder:d})]}),(0,t.jsx)("th",{className:"px-4 py-2.5 text-right w-36",children:r("chartShare")})]})}),(0,t.jsx)("tbody",{className:"divide-y divide-border",children:h.map((e,s)=>{let r=x>0?(e.totalTokens/x*100).toFixed(1):"0";return(0,t.jsxs)("tr",{className:"hover:bg-black/[0.02] dark:hover:bg-white/[0.02] transition-colors",children:[(0,t.jsx)("td",{className:"px-4 py-2.5",children:(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("span",{className:"w-2 h-2 rounded-full shrink-0",style:{backgroundColor:c[s%c.length]}}),(0,t.jsx)("span",{className:"font-medium capitalize",children:e.provider})]})}),(0,t.jsx)("td",{className:"px-4 py-2.5 text-right font-mono text-text-muted",children:(0,n.fmtFull)(e.requests)}),(0,t.jsx)("td",{className:"px-4 py-2.5 text-right font-mono text-primary",children:(0,n.fmtCompact)(e.promptTokens)}),(0,t.jsx)("td",{className:"px-4 py-2.5 text-right font-mono text-emerald-500",children:(0,n.fmtCompact)(e.completionTokens)}),(0,t.jsx)("td",{className:"px-4 py-2.5 text-right font-mono font-semibold",children:(0,n.fmtCompact)(e.totalTokens)}),(0,t.jsx)("td",{className:"px-4 py-2.5 text-right font-mono text-amber-500",children:(0,n.fmtCost)(e.cost)}),(0,t.jsx)("td",{className:"px-4 py-2.5 text-right",children:(0,t.jsxs)("div",{className:"flex items-center gap-2 justify-end",children:[(0,t.jsx)("div",{className:"w-16 h-1.5 rounded-full bg-white/[0.06] overflow-hidden",children:(0,t.jsx)("div",{className:"h-full rounded-full transition-all",style:{width:`${r}%`,backgroundColor:c[s%c.length]}})}),(0,t.jsxs)("span",{className:"text-xs font-mono text-text-muted w-10 text-right",children:[r,"%"]})]})})]},`${e.provider}-${s}`)})})]})})]}):(0,t.jsxs)(l.default,{className:"p-4",children:[(0,t.jsx)("h3",{className:"text-sm font-semibold text-text-muted uppercase tracking-wider mb-3",children:r("chartProviderBreakdown")}),(0,t.jsx)("div",{className:"text-center text-text-muted text-sm py-8",children:r("chartNoData")})]})}let I=null,A=null;
1function D(){let[t,r]=(0,s.useState)(I);return(0,s.useEffect)(()=>{if(t)return;let s=!1;return(I?Promise.resolve(I):(!A&&(A=e.A(416494).then(e=>(I=e,e)).catch(e=>{throw A=null,e})),A)).then(e=>{s||r(e)}).catch(()=>{s||r(null)}),()=>{s=!0}},[t]),t}function K({className:e="p-4 flex-1"}){return(0,t.jsx)(l.default,{className:e,children:(0,t.jsx)("div",{className:"py-8","aria-hidden":"true"})})}function L({active:e,payload:s,label:r,formatter:a}){return e&&s?.length?(0,t.jsxs)("div",{className:"rounded-lg border border-white/10 bg-surface px-3 py-2 text-xs shadow-lg",children:[r&&(0,t.jsx)("div",{className:"font-semibold text-text-main mb-1",children:r}),s.map((e,s)=>(0,t.jsxs)("div",{className:"flex items-center gap-1.5 text-text-muted",children:[(0,t.jsx)("span",{className:"w-2 h-2 rounded-full shrink-0",style:{backgroundColor:e.color}}),(0,t.jsxs)("span",{children:[e.name,":"]}),(0,t.jsx)("span",{className:"font-mono font-medium text-text-main",children:a?a(e.value):e.value})]},s))]}):null}function M({pieData:e,title:s,formatter:r,valueClassName:a="text-text-muted",labelClassName:i="",getLegendKey:n,getLegendTitle:o}){let c=D();if(!c)return(0,t.jsx)(K,{});let{Cell:d,PieChart:u,Pie:m,Tooltip:x,ResponsiveContainer:p}=c;return(0,t.jsxs)(l.default,{className:"p-4 flex-1",children:[(0,t.jsx)("h3",{className:"text-sm font-semibold text-text-muted uppercase tracking-wider mb-3",children:s}),(0,t.jsxs)("div",{className:"flex items-center gap-4",children:[(0,t.jsx)(p,{width:120,height:120,children:(0,t.jsxs)(u,{children:[(0,t.jsx)(m,{data:e,dataKey:"value",nameKey:"name",cx:"50%",cy:"50%",innerRadius:28,outerRadius:55,paddingAngle:1,animationDuration:600,children:e.map((e,s)=>(0,t.jsx)(d,{fill:e.fill,stroke:"none"},s))}),(0,t.jsx)(x,{content:(0,t.jsx)(L,{formatter:r})})]})}),(0,t.jsx)("div",{className:"flex flex-col gap-1 min-w-0 flex-1",children:e.map((e,s)=>(0,t.jsxs)("div",{className:"flex items-center justify-between gap-2 text-xs",children:[(0,t.jsxs)("div",{className:"flex items-center gap-1.5 min-w-0",children:[(0,t.jsx)("span",{className:"w-2 h-2 rounded-full shrink-0",style:{backgroundColor:e.fill}}),(0,t.jsx)("span",{className:`truncate text-text-main ${i}`.trim(),title:o?.(e),children:e.name})]}),(0,t.jsx)("span",{className:`font-mono font-medium shrink-0 ${a}`,children:r(e.value)})]},n?n(e,s):s))})]})]})}function O({byAccount:e}){let r=(0,a.useTranslations)("analytics"),i=(0,s.useMemo)(()=>e||[],[e]),o=i.length>0,c=(0,s.useMemo)(()=>i.slice(0,8).map((e,t)=>({name:e.account,value:e.totalTokens,fill:(0,h.getModelColor)(t)})),[i]);return o?(0,t.jsx)(M,{pieData:c,title:r("chartByAccount"),formatter:n.fmtCompact}):(0,t.jsxs)(l.default,{className:"p-4 flex-1",children:[(0,t.jsx)("h3",{className:"text-sm font-semibold text-text-muted uppercase tracking-wider mb-3",children:r("chartByAccount")}),(0,t.jsx)("div",{className:"text-center text-text-muted text-sm py-8",children:r("chartNoData")})]})}function R({byApiKey:e}){let r=(0,a.useTranslations)("analytics"),i=(0,s.useMemo)(()=>e||[],[e]),o=i.length>0,c=(0,s.useMemo)(()=>i.slice(0,8).map((e,t)=>({name:(0,n.formatApiKeyLabel)(e.apiKeyName,e.apiKeyId),fullName:e.apiKeyName||e.apiKeyId||r("unknownApiKey"),value:e.totalTokens,fill:(0,h.getModelColor)(t)})),[i,r]);return o?(0,t.jsx)(M,{pieData:c,title:r("chartByApiKey"),formatter:n.fmtCompact,getLegendKey:(e,t)=>`${e.fullName}-${t}`,getLegendTitle:e=>e.fullName}):(0,t.jsxs)(l.default,{className:"p-4 flex-1",children:[(0,t.jsx)("h3",{className:"text-sm font-semibold text-text-muted uppercase tracking-wider mb-3",children:r("chartByApiKey")}),(0,t.jsx)("div",{className:"text-center text-text-muted text-sm py-8",children:r("chartNoData")})]})}function F({byProvider:e}){let r=(0,a.useTranslations)("analytics"),i=(0,s.useMemo)(()=>e||[],[e]),o=i.length>0&&i.some(e=>e.cost>0),d=(0,s.useMemo)(()=>i.filter(e=>e.cost>0).sort((e,t)=>t.cost-e.cost).slice(0,8).map((e,t)=>({name:e.provider,value:e.cost,fill:c[t%c.length]})),[i]);return o?(0,t.jsx)(M,{pieData:d,title:r("chartCostByProvider"),formatter:n.fmtCost,valueClassName:"text-amber-500",labelClassName:"capitalize"}):(0,t.jsxs)(l.default,{className:"p-4 flex-1",children:[(0,t.jsx)("h3",{className:"text-sm font-semibold text-text-muted uppercase tracking-wider mb-3",children:r("chartCostByProvider")}),(0,t.jsx)("div",{className:"text-center text-text-muted text-sm py-8",children:r("chartNoCostData")})]})}function P({dailyTrend:e}){let r=(0,a.useTranslations)("analytics"),i=(0,s.useMemo)(()=>(e||[]).map(e=>({date:e.date.slice(5),[r("chartInput")]:e.promptTokens,[r("chartOutput")]:e.completionTokens,[r("chartCost")]:e.cost||0})),[e,r]),n=(0,s.useMemo)(()=>i.some(e=>e[r("chartCost")]>0),[i,r]);return i.length?(0,t.jsx)($,{chartData:i,hasCost:n}):(0,t.jsxs)(l.default,{className:"p-4",children:[(0,t.jsx)("h3",{className:"text-sm font-semibold text-text-muted uppercase tracking-wider mb-3",children:r("chartModelUsageOverTime")}),(0,t.jsx)("div",{className:"text-center text-text-muted text-sm py-8",children:r("chartNoData")})]})}function $({chartData:e,hasCost:s}){let r=(0,a.useTranslations)("analytics"),i=D();if(!i)return(0,t.jsx)(K,{});
1let{ComposedChart:n,Bar:o,Line:c,XAxis:d,YAxis:u,Tooltip:m,ResponsiveContainer:x}=i;return(0,t.jsxs)(l.default,{className:"p-4 flex-1",children:[(0,t.jsx)("h3",{className:"text-sm font-semibold text-text-muted uppercase tracking-wider mb-3",children:r("chartModelUsageOverTime")}),(0,t.jsx)(x,{width:"100%",height:140,children:(0,t.jsxs)(n,{data:e,margin:{top:0,right:40*!!s,left:0,bottom:0},children:[(0,t.jsx)(d,{dataKey:"date",tick:{fontSize:9,fill:"var(--color-text-muted)"},axisLine:!1,tickLine:!1,interval:Math.max(Math.floor(e.length/6),0)}),s&&(0,t.jsx)(u,{yAxisId:"cost",orientation:"right",tick:{fontSize:8,fill:"#f59e0b"},axisLine:!1,tickLine:!1,tickFormatter:e=>`$${e.toFixed(2)}`,width:36}),(0,t.jsx)(m,{content:(0,t.jsx)(z,{}),cursor:{fill:"rgba(255,255,255,0.04)"}}),(0,t.jsx)(o,{dataKey:r("chartInput"),stackId:"a",fill:"var(--color-primary)",opacity:.7,radius:[0,0,0,0],animationDuration:600}),(0,t.jsx)(o,{dataKey:r("chartOutput"),stackId:"a",fill:"#10b981",opacity:.7,radius:[3,3,0,0],animationDuration:600}),s&&(0,t.jsx)(c,{yAxisId:"cost",type:"monotone",dataKey:r("chartCost"),stroke:"#f59e0b",strokeWidth:2,dot:!1,animationDuration:600})]})}),(0,t.jsxs)("div",{className:"flex items-center gap-4 mt-2 text-[10px] text-text-muted",children:[(0,t.jsxs)("span",{className:"flex items-center gap-1",children:[(0,t.jsx)("span",{className:"w-2 h-2 rounded-full bg-primary/70"})," ",r("chartInput")]}),(0,t.jsxs)("span",{className:"flex items-center gap-1",children:[(0,t.jsx)("span",{className:"w-2 h-2 rounded-full bg-emerald-500/70"})," ",r("chartOutput")]}),s&&(0,t.jsxs)("span",{className:"flex items-center gap-1",children:[(0,t.jsx)("span",{className:"w-2 h-2 rounded-full bg-amber-500/70"})," ",r("chartCost")," ($)"]})]})]})}function z({active:e,payload:s,label:r}){let l=(0,a.useTranslations)("analytics");return e&&s?.length?(0,t.jsxs)("div",{className:"rounded-lg border border-white/10 bg-surface px-3 py-2 text-xs shadow-lg",children:[r&&(0,t.jsx)("div",{className:"font-semibold text-text-main mb-1",children:r}),s.map((e,s)=>(0,t.jsxs)("div",{className:"flex items-center gap-1.5 text-text-muted",children:[(0,t.jsx)("span",{className:"w-2 h-2 rounded-full shrink-0",style:{backgroundColor:e.color}}),(0,t.jsxs)("span",{children:[e.name,":"]}),(0,t.jsx)("span",{className:"font-mono font-medium text-text-main",children:e.name===l("chartCost")?(0,n.fmtCost)(e.value):(0,n.fmtCompact)(e.value)})]},s))]}):null}function B({dailyByModel:e,modelNames:r}){let i=(0,a.useTranslations)("analytics"),n=(0,s.useMemo)(()=>e||[],[e]),o=(0,s.useMemo)(()=>r||[],[r]),c=(0,s.useMemo)(()=>n.map(e=>{let t={...e};if(e.date){let s=e.date.split("-");t.dateLabel=`${s[1]}/${s[2]}`}return t}),[n]);return n.length&&o.length?(0,t.jsx)(U,{chartData:c,models:o}):(0,t.jsxs)(l.default,{className:"p-4",children:[(0,t.jsx)("h3",{className:"text-sm font-semibold text-text-muted uppercase tracking-wider mb-3",children:i("chartModelUsageOverTime")}),(0,t.jsx)("div",{className:"text-center text-text-muted text-sm py-8",children:i("chartNoData")})]})}function U({chartData:e,models:s}){let r=(0,a.useTranslations)("analytics"),i=D();if(!i)return(0,t.jsx)(K,{className:"p-4"});let{AreaChart:o,Area:c,XAxis:d,YAxis:u,Tooltip:m,ResponsiveContainer:x}=i;return(0,t.jsxs)(l.default,{className:"p-4",children:[(0,t.jsx)("h3",{className:"text-sm font-semibold text-text-muted uppercase tracking-wider mb-3",children:r("chartModelUsageOverTime")}),(0,t.jsx)(x,{width:"100%",height:240,children:(0,t.jsxs)(o,{data:e,margin:{top:4,right:4,left:0,bottom:0},children:[(0,t.jsx)(d,{dataKey:"dateLabel",tick:{fontSize:10,fill:"var(--color-text-muted)"},axisLine:!1,tickLine:!1,interval:"preserveStartEnd"}),(0,t.jsx)(u,{tick:{fontSize:10,fill:"var(--color-text-muted)"},tickFormatter:e=>(0,n.fmtCompact)(e),axisLine:!1,tickLine:!1,width:50}),(0,t.jsx)(m,{content:(0,t.jsx)(L,{formatter:n.fmtCompact})}),s.map((e,s)=>(0,t.jsx)(c,{type:"monotone",dataKey:e,stackId:"1",stroke:(0,h.getModelColor)(s),fill:(0,h.getModelColor)(s),fillOpacity:.4,strokeWidth:1.5,animationDuration:600},e))]})}),(0,t.jsx)("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 mt-2 text-[10px] text-text-muted",children:s.map((e,s)=>(0,t.jsxs)("span",{className:"flex items-center gap-1",children:[(0,t.jsx)("span",{className:"w-2 h-2 rounded-full shrink-0",style:{backgroundColor:(0,h.getModelColor)(s)}}),e]},e))})]})}function q(e){return!e||e.length<=8?e||"unknown":`${e.slice(0,6)}â¦${e.slice(-4)}`}function W({available:e,selected:r,onChange:l}
1){let i=(0,a.useTranslations)("analytics"),[n,o]=(0,s.useState)(!1),[c,d]=(0,s.useState)(""),u=(0,s.useRef)(null);(0,s.useEffect)(()=>{if(n)return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e);function e(e){u.current&&!u.current.contains(e.target)&&o(!1)}},[n]),(0,s.useEffect)(()=>{if(n)return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e);function e(e){"Escape"===e.key&&o(!1)}},[n]);let m=(0,s.useMemo)(()=>{let t=c.trim().toLowerCase();return t?e.filter(e=>e.name.toLowerCase().includes(t)||e.id.toLowerCase().includes(t)):e},[e,c]),x=0===r.length,p=(0,s.useCallback)(e=>{r.includes(e)?l(r.filter(t=>t!==e)):l([...r,e])},[r,l]),h=(0,s.useCallback)(()=>{l([])},[l]),b=(0,s.useMemo)(()=>{if(x)return i("filterAllKeys");if(1===r.length){let t=e.find(e=>e.id===r[0]);return t?q(t.name):i("filterOneKey")}return i("filterMultipleKeys",{count:r.length})},[x,r,e,i]);return 0===e.length?null:(0,t.jsxs)("div",{className:"relative",ref:u,children:[(0,t.jsxs)("button",{type:"button",onClick:()=>o(e=>!e),className:`flex items-center gap-1.5 rounded-lg border px-3 py-1.5 text-xs font-medium transition-all ${x?"border-border/50 bg-black/[0.03] text-text-muted hover:text-text-main dark:bg-white/[0.03]":"border-primary/40 bg-primary/10 text-primary"}`,children:[(0,t.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"vpn_key"}),b,(0,t.jsx)("span",{className:`material-symbols-outlined text-[14px] transition-transform ${n?"rotate-180":""}`,children:"expand_more"})]}),n&&(0,t.jsxs)("div",{className:"absolute left-0 top-full z-50 mt-1.5 w-[260px] rounded-xl border border-border/50 bg-surface shadow-xl",style:{backdropFilter:"blur(16px)"},children:[e.length>5&&(0,t.jsx)("div",{className:"border-b border-border/30 p-2",children:(0,t.jsx)("input",{type:"text",value:c,onChange:e=>d(e.target.value),placeholder:i("filterSearchKeys"),className:"w-full rounded-md border border-border/30 bg-black/[0.03] px-2.5 py-1.5 text-xs text-text-main placeholder:text-text-muted focus:outline-none focus:border-primary dark:bg-white/[0.03]",autoFocus:!0})}),(0,t.jsxs)("div",{className:"max-h-[280px] overflow-y-auto p-1.5",children:[(0,t.jsxs)("button",{type:"button",onClick:h,className:`flex w-full items-center gap-2.5 rounded-lg px-2.5 py-2 text-left text-xs transition-colors ${x?"bg-primary/10 text-primary font-semibold":"text-text-muted hover:bg-black/[0.04] hover:text-text-main dark:hover:bg-white/[0.04]"}`,children:[(0,t.jsx)("span",{className:`flex h-4 w-4 shrink-0 items-center justify-center rounded border text-[10px] ${x?"border-primary bg-primary text-white":"border-border/60 bg-transparent"}`,children:x&&(0,t.jsx)("span",{className:"material-symbols-outlined text-[12px]",children:"check"})}),i("filterAllKeys"),(0,t.jsx)("span",{className:"ml-auto text-[10px] text-text-muted font-normal",children:e.length})]}),(0,t.jsx)("div",{className:"my-1 h-px bg-border/20"}),m.map(e=>{let s=r.includes(e.id);return(0,t.jsxs)("button",{type:"button",onClick:()=>p(e.id),className:`flex w-full items-center gap-2.5 rounded-lg px-2.5 py-2 text-left text-xs transition-colors ${s?"bg-primary/[0.06] text-text-main":"text-text-muted hover:bg-black/[0.04] hover:text-text-main dark:hover:bg-white/[0.04]"}`,title:e.name||e.id,children:[(0,t.jsx)("span",{className:`flex h-4 w-4 shrink-0 items-center justify-center rounded border text-[10px] ${s?"border-primary bg-primary text-white":"border-border/60 bg-transparent"}`,children:s&&(0,t.jsx)("span",{className:"material-symbols-outlined text-[12px]",children:"check"})}),(0,t.jsx)("span",{className:"truncate",children:q(e.name||e.id)})]},e.id)}),0===m.length&&(0,t.jsx)("p",{className:"px-2.5 py-3 text-center text-[11px] text-text-muted",children:i("filterNoKeysMatch")})]})]})]})}function H(e){if(!e)return"";let t=new Date(e);if(isNaN(t.getTime()))return"";let s=e=>String(e).padStart(2,"0");return`${t.getFullYear()}-${s(t.getMonth()+1)}-${s(t.getDate())}T${s(t.getHours())}:${s(t.getMinutes())}`}function G(e){return e?new Date(e).toISOString():""}function J({start:e,end:r,onApply:l,onClose:i}
1){let n=(0,a.useTranslations)("analytics"),[o,c]=(0,s.useState)(H(e)||""),[d,u]=(0,s.useState)(H(r)||""),m=(0,s.useRef)(null);(0,s.useEffect)(()=>{function e(e){m.current&&!m.current.contains(e.target)&&i()}return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[i]),(0,s.useEffect)(()=>{function e(e){"Escape"===e.key&&i()}return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[i]);let x=(0,s.useCallback)(()=>{o&&d&&l(G(o),G(d))},[o,d,l]),p=(0,s.useCallback)(e=>{let{start:t,end:s}=function(e){let t=new Date,s=H(t.toISOString()),r=new Date(t);switch(e){case"today":r.setHours(0,0,0,0);break;case"yesterday":{r.setDate(r.getDate()-1),r.setHours(0,0,0,0);let e=new Date(r);return e.setHours(23,59,59,999),{start:H(r.toISOString()),end:H(e.toISOString())}}case"thisWeek":r.setDate(r.getDate()-r.getDay()),r.setHours(0,0,0,0);break;case"thisMonth":r.setDate(1),r.setHours(0,0,0,0);break;case"last3d":r.setDate(r.getDate()-3);break;case"last14d":r.setDate(r.getDate()-14);break;default:r.setDate(r.getDate()-7)}return{start:H(r.toISOString()),end:s}}(e);c(t),u(s)},[]),h=o&&d&&new Date(o)<=new Date(d),b=[{key:"today",label:n("rangeToday")},{key:"yesterday",label:n("rangeYesterday")},{key:"last3d",label:n("rangeLast3Days")},{key:"thisWeek",label:n("rangeThisWeek")},{key:"last14d",label:n("rangeLast14Days")},{key:"thisMonth",label:n("rangeThisMonth")}];return(0,t.jsxs)("div",{ref:m,className:"absolute right-0 top-full z-50 mt-2 w-[340px] rounded-xl border border-border/50 bg-surface p-4 shadow-xl",style:{backdropFilter:"blur(16px)"},children:[(0,t.jsxs)("div",{className:"mb-3",children:[(0,t.jsx)("p",{className:"text-[10px] font-semibold uppercase tracking-wider text-text-muted mb-1.5",children:n("rangeQuickSelect")}),(0,t.jsx)("div",{className:"flex flex-wrap gap-1",children:b.map(e=>(0,t.jsx)("button",{type:"button",onClick:()=>p(e.key),className:"rounded-md border border-border/30 bg-black/[0.03] px-2.5 py-1 text-[11px] font-medium text-text-muted transition-colors hover:bg-primary/10 hover:text-primary hover:border-primary/30 dark:bg-white/[0.03]",children:e.label},e.key))})]}),(0,t.jsx)("div",{className:"h-px bg-border/30 mb-3"}),(0,t.jsxs)("div",{className:"flex flex-col gap-2.5",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"text-[10px] font-semibold uppercase tracking-wider text-text-muted mb-1 block",children:n("rangeStart")}),(0,t.jsx)("input",{type:"datetime-local",value:o,onChange:e=>c(e.target.value),className:"w-full rounded-lg border border-border/50 bg-black/[0.04] px-3 py-2 text-sm text-text-main focus:outline-none focus:border-primary dark:bg-white/[0.04]"})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"text-[10px] font-semibold uppercase tracking-wider text-text-muted mb-1 block",children:n("rangeEnd")}),(0,t.jsx)("input",{type:"datetime-local",value:d,onChange:e=>u(e.target.value),className:"w-full rounded-lg border border-border/50 bg-black/[0.04] px-3 py-2 text-sm text-text-main focus:outline-none focus:border-primary dark:bg-white/[0.04]"})]})]}),o&&d&&!h&&(0,t.jsx)("p",{className:"mt-1.5 text-[11px] text-error",children:n("rangeErrorInvalid")}),(0,t.jsxs)("div",{className:"mt-3 flex items-center justify-end gap-2",children:[(0,t.jsx)("button",{type:"button",onClick:i,className:"rounded-lg px-3 py-1.5 text-xs font-medium text-text-muted hover:text-text-main transition-colors",children:n("rangeCancel")}),(0,t.jsx)("button",{type:"button",disabled:!h,onClick:x,className:"rounded-lg bg-primary px-4 py-1.5 text-xs font-semibold text-white shadow-sm transition-colors hover:bg-primary-hover disabled:opacity-40 disabled:cursor-not-allowed",children:n("rangeApply")})]})]})}function Y({title:e,dateLabel:s,value:r,onChange:a}){return(0,t.jsxs)("div",{className:"p-4 border-b border-border flex items-center justify-between flex-wrap gap-2",children:[(0,t.jsx)("h3",{className:"text-sm font-semibold text-text-muted uppercase tracking-wider",children:e}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("input",{type:"date",value:r,onChange:e=>a(e.target.value),"aria-label":s,className:"px-2 py-1 rounded-md text-xs bg-black/[0.03] dark:bg-white/[0.03] border border-black/5 dark:border-white/5"}),r&&(0,t.jsx)("button",{onClick:()=>a(""),className:"text-xs text-text-muted hover:text-text-main",children:(0,t.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:"close"})})]})]})}
1function V({rows:e,sortBy:s,sortOrder:r,onToggleSort:a,dateLabel:l,providerLabel:i,requestsLabel:o,totalLabel:d}){return(0,t.jsx)("div",{className:"overflow-x-auto",children:(0,t.jsxs)("table",{className:"w-full text-sm",children:[(0,t.jsx)("thead",{className:"text-xs text-text-muted uppercase bg-black/[0.02] dark:bg-white/[0.02]",children:(0,t.jsxs)("tr",{children:[(0,t.jsxs)("th",{className:"px-4 py-2.5 text-left cursor-pointer group",onClick:()=>a("date"),children:[l," ",(0,t.jsx)(j,{active:"date"===s,sortOrder:r})]}),(0,t.jsxs)("th",{className:"px-4 py-2.5 text-left cursor-pointer group",onClick:()=>a("provider"),children:[i," ",(0,t.jsx)(j,{active:"provider"===s,sortOrder:r})]}),(0,t.jsxs)("th",{className:"px-4 py-2.5 text-right cursor-pointer group",onClick:()=>a("requests"),children:[o," ",(0,t.jsx)(j,{active:"requests"===s,sortOrder:r})]}),(0,t.jsxs)("th",{className:"px-4 py-2.5 text-right cursor-pointer group",onClick:()=>a("totalTokens"),children:[d," ",(0,t.jsx)(j,{active:"totalTokens"===s,sortOrder:r})]})]})}),(0,t.jsx)("tbody",{className:"divide-y divide-border",children:e.map((e,s)=>(0,t.jsxs)("tr",{className:"hover:bg-black/[0.02] dark:hover:bg-white/[0.02] transition-colors",children:[(0,t.jsx)("td",{className:"px-4 py-2.5 font-mono text-text-muted",children:e.date}),(0,t.jsx)("td",{className:"px-4 py-2.5",children:(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("span",{className:"w-2 h-2 rounded-full shrink-0",style:{backgroundColor:c[s%c.length]}}),(0,t.jsx)("span",{className:"font-medium capitalize",children:e.provider})]})}),(0,t.jsx)("td",{className:"px-4 py-2.5 text-right font-mono font-semibold",children:(0,n.fmtFull)(e.requests)}),(0,t.jsx)("td",{className:"px-4 py-2.5 text-right font-mono text-text-muted",children:(0,n.fmtCompact)(e.totalTokens)})]},`${e.date}::${e.provider}`))})]})})}function X({range:e}){let r=(0,a.useTranslations)("analytics"),i=(0,a.useTranslations)("common"),[n,c]=(0,s.useState)(""),[d,u]=(0,s.useState)("date"),[m,x]=(0,s.use
1State)("desc"),{rows:p,loading:h,error:b}=function(e,t){let r=(0,a.useTranslations)("common"),[l,i]=(0,s.useState)([]),[n,c]=(0,s.useState)(!0),[d,u]=(0,s.useState)(null),m=(0,s.useCallback)(async()=>{try{c(!0);let s=new URLSearchParams;t?s.set("date",t):s.set("range",e);let a=await fetch(`/api/usage/requests-by-provider-date?${s.toString()}`);if(!a.ok)throw Error(await o(a,r("error")));let l=await a.json();i(Array.isArray(l.rows)?l.rows:[]),u(null)}catch(e){u(e.message)}finally{c(!1)}},[e,t,r]);return(0,s.useEffect)(()=>{m()},[m]),{rows:l,loading:n,error:d}}(e,n),f=(0,s.useCallback)(e=>{d===e?x(e=>"asc"===e?"desc":"asc"):(u(e),x("desc"))},[d]),g=(0,s.useMemo)(()=>{let e;return(e=[...p]).sort((e,t)=>{let s=e[d],r=t[d];return"string"==typeof s&&"string"==typeof r?"asc"===m?s.localeCompare(r):r.localeCompare(s):"asc"===m?Number(s)-Number(r):Number(r)-Number(s)}),e},[p,d,m]);return(0,t.jsxs)(l.default,{className:"overflow-hidden",children:[(0,t.jsx)(Y,{title:r("chartRequestsByProviderDate"),dateLabel:r("chartDate"),value:n,onChange:c}),h&&0===p.length?(0,t.jsx)("div",{className:"text-center text-text-muted text-sm py-8",children:i("loading")}):b?(0,t.jsxs)("div",{className:"text-center text-red-500 text-sm py-8",children:[i("errorShort"),": ",b]}):0===g.length?(0,t.jsx)("div",{className:"text-center text-text-muted text-sm py-8",children:r("chartNoData")}):(0,t.jsx)(V,{rows:g,sortBy:d,sortOrder:m,onToggleSort:f,dateLabel:r("chartDate"),providerLabel:r("chartProvider"),requestsLabel:r("chartRequests"),totalLabel:r("chartTotal")})]})}e.s(["default",0,function(){let e=(0,r.useLocale)(),c=(0,a.useTranslations)("analytics"),d=(0,a.useTranslations)("common"),[u,m]=(0,s.useState)("30d"),[x,p]=(0,s.use
1State)(null),[h,b]=(0,s.useState)(!0),[f,g]=(0,s.useState)(null),[v,j]=(0,s.useState)(""),[I,A]=(0,s.useState)(""),[D,K]=(0,s.useState)(!1),L=(0,s.useRef)(null),[M,$]=(0,s.useState)([]),[z,U]=(0,s.useState)([]),q=(0,s.useCallback)(async()=>{try{b(!0);let e=new URLSearchParams;e.set("range",u),"custom"===u&&v&&I&&(e.set("startDate",v),e.set("endDate",I)),M.length>0&&e.set("apiKeyIds",M.join(","));let t=await fetch(`/api/usage/analytics?${e.toString()}`);if(!t.ok)throw Error(await o(t,d("error")));let s=await t.json();if(p(s),g(null),0===M.length&&s.byApiKey?.length>0){let e=new Set,t=[];for(let r of s.byApiKey){let s=r.apiKeyId||r.apiKeyName||d("unknownProvider"),a=r.apiKeyName||r.apiKeyId||d("unknownProvider");e.has(s)||(e.add(s),t.push({id:s,name:a}))}U(t)}}catch(e){g(e.message)}finally{b(!1)}},[u,v,I,M,d]);(0,s.useEffect)(()=>{let e=window.setTimeout(()=>void q(),0);return()=>window.clearTimeout(e)},[q]);let H=(0,s.useCallback)(e=>{"custom"===e?K(!0):(m(e),K(!1))},[]),G=(0,s.useCallback)((e,t)=>{j(e),A(t),m("custom"),K(!1)},[]),Y=(0,s.useMemo)(()=>{if("custom"!==u||!v||!I)return null;let t=t=>new Date(t).toLocaleDateString(e,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"});return`${t(v)} â ${t(I)}`},[u,v,I,e]),V=[{value:"1d",label:c("period1D")},{value:"7d",label:c("period7D")},{value:"30d",label:c("period30D")},{value:"90d",label:c("period90D")},{value:"ytd",label:c("periodYTD")},{value:"all",label:c("periodAll")}],Q=(0,s.useMemo)(()=>{let e=x?.byModel||[];return e.length>0?e[0].model:"â"},[x]),Z=(0,s.useMemo)(()=>{let e=x?.byProvider||[];return e.length>0?e[0].provider:"â"},[x]),ee=(0,s.useMemo)(()=>{let t=x?.weeklyPattern||[];if(!t.length)return"â";let s=t.reduce((e,t)=>e.avgTokens>t.avgTokens?e:t,t[0]);if(s.avgTokens<=0)return"â";let r=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"].indexOf(s.day);return r<0?s.day:new Intl.DateTimeFormat(e,{weekday:"short"}).format(new Date(2024,0,7+r))},[x,e]),et=(0,s.useMemo)(()=>(x?.byProvider||[]).length,[x]),es=(0,s.useMemo)(()=>{let e=x?.byProvider||[];if(e.length<=1)return 0;let t=0;for(let s of e)t+=s.totalRequests||s.apiCalls||0;if(0===t)return 0;let s=0;for(let r of e){let e=(r.totalRequests||r.apiCalls||0)/t;e>0&&(s-=e*Math.log2(e))}let r=Math.log2(e.length);return r>0?s/r*100:0},[x]);if(h&&!x)return(0,t.jsx)(i.CardSkeleton,{});if(f)return(0,t.jsxs)(l.default,{className:"p-6 text-center text-red-500",children:[d("errorShort"),": ",f]});let er=x?.summary||{},ea=er.totalRequests>0?Math.round(er.totalTokens/er.totalRequests):0,el=er.totalRequests>0?er.totalCost/er.totalRequests:0,ei=er.completionTokens>0?(er.promptTokens/er.completionTokens).toFixed(1):"â";return(0,t.jsxs)("div",{className:"flex flex-col gap-5 min-w-0",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between flex-wrap gap-3",children:[(0,t.jsxs)("h2",{className:"text-xl font-semibold flex items-center gap-2",children:[(0,t.jsx)("span",{className:"material-symbols-outlined text-primary text-[22px]",children:"analytics"}),c("usageAnalyticsTitle")]}),(0,t.jsxs)("div",{className:"flex items-center gap-2.5",children:[(0,t.jsx)(W,{available:z,selected:M,onChange:$}),(0,t.jsxs)("div",{className:"relative flex items-center gap-1 bg-black/[0.03] dark:bg-white/[0.03] rounded-lg p-1 border border-black/5 dark:border-white/5",ref:L,children:[V.map(e=>(0,t.jsx)("button",{onClick:()=>H(e.value),className:`px-3 py-1 rounded-md text-xs font-semibold transition-all ${u===e.value?"bg-primary text-white shadow-sm":"text-text-muted hover:text-text-main hover:bg-black/5 dark:hover:bg-white/5"}`,children:e.label},e.value)),(0,t.jsxs)("button",{onClick:()=>H("custom"),className:`px-3 py-1 rounded-md text-xs font-semibold transition-all flex items-center gap-1 ${"custom"===u?"bg-primary text-white shadow-sm":"text-text-muted hover:text-text-main hover:bg-black/5 dark:hover:bg-white/5"}`,children:[(0,t.jsx)("span",{className:"material-symbols-outlined text-[13px]",children:"date_range"}),Y||c("customRange"),"custom"===u&&Y&&(0,t.jsx)("span",{role:"button",onClick:e=>{e.stopPropagation(),m("30d"),j(""),A("")},className:"ml-0.5 opacity-70 hover:opacity-100",children:(0,t.jsx)("span",{className:"material-symbols-outlined text-[11px]",children:"close"})})]}),D&&(0,t.jsx)(J,{start:v,end:I,onApply:G,onClose:()=>K(!1)})]})]})]}),(0,t.jsxs)("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-3",children:[(0,t.jsx)(k,{icon:"generating_tokens",label:c("totalTokens"),value:(0,n.fmtCompact)(er.totalTokens),subValue:`${(0,n.fmtFull)(er.totalRequests)} ${c("chartRequests")}`}),(0,t.jsx)(k,{icon:"input",label:c("inputTokens"),value:(0,n.fmtCompact)(er.promptTokens),color:"text-primary"}),(0,t.jsx)(k,{icon:"output",label:c("outputTokens"),value:(0,n.fmtCompact)(er.completionTokens),color:"text-emerald-500"}),(0,t.jsx)(k,{icon:"payments",label:c("estCost"),value:(0,n.fmtCost)(er.totalCost),color:"text-amber-500"})]}),(0,t.jsx)(N,{sections:[{title:c("infraTitle"),items:[{icon:"group",label:c("infraAccounts"),value:er.uniqueAccounts||0},{icon:"dns",label:c("infraProviders"),value:et,color:"text-indigo-500"},{icon:"vpn_key",label:c("infraApiKeys"),value:er.uniqueApiKeys||0},{icon:"model_training",label:c("infraModels"),value:er.uniqueModels||0}]},{title:c("perfTitle"),items:[{icon:"speed",label:c("perfAvgTokens"),value:(0,n.fmtCompact)(ea),color:"text-cyan-500"},{icon:"request_quote",label:c("perfCostReq"),value:(0,n.fmtCost)(el),color:"text-orange-500"},{icon:"compare_arrows",label:c("perfIoRatio"),value:`${ei}x`,color:"text-violet-500"},{icon:"bolt",label:c("perfFastReq"),value:(0,n.fmtCompact)(er.fastRequests||0),color:"text-sky-500"}]},{title:c("highlightsTitle"),wideValues:!0,items:[{icon:"star",label:c("highlightsTopModel"),value:Q,color:"text-pink-500"},{icon:"cloud",label:c("highlightsTopProvider"),value:Z,color:"text-teal-500"},{icon:"today",label:c("highlightsBusiestDay"),value:ee,color:"text-rose-500"},{icon:"network_node",label:c("highlightsDiversity"),value:`${es.toFixed(1)}%`,color:"text-sky-500"},{icon:"swap_horiz",label:c("highlightsFallbackRate"),value:`${Number(er.fallbackRatePct||0).toFixed(1)}%`,color:"text-amber-500"}]}]}),(0,t.jsxs)("div",{className:"grid grid-cols-1 lg:grid-cols-[2fr_1fr] gap-4 items-stretch",children:[(0,t.jsx)(w,{activityMap:x?.activityMap}),(0,t.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,t.jsx)(C,{activityMap:x?.activityMap}),(0,t.jsx)(T,{activityMap:x?.activityMap})]})]}),(0,t.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[(0,t.jsx)(P,{dailyTrend:x?.dailyTrend}),(0,t.jsx)(F,{byProvider:x?.byProvider})]}),(0,t.jsx)(E,{byServiceTier:x?.byServiceTier,summary:er}),(0,t.jsx)(B,{dailyByModel:x?.dailyByModel,modelNames:x?.modelNames}),(0,t.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[(0,t.jsx)(O,{byAccount:x?.byAccount}),(0,t.jsx)(R,{byApiKey:x?.byApiKey})]}),(0,t.jsx)(_,{byProvider:x?.byProvider}),(0,t.jsx)(X,{range:u}),(0,t.jsx)(S,{byApiKey:x?.byApiKey}),(0,t.jsx)(y,{byModel:x?.byModel,summary:er})]})}],566770)},953789,209991,e=>{"use strict";var t=e.i(843476),s=e.i(271645),r=e.i(618566),a=e.i(948148),l=e.i(393718),i=e.i(1203),n=e.i(954565),o=e.i(484124),c=e.i(243009),d=e.i(624982),u=e.i(768834),m=e.i(579473);let x=(0,u.create)()((0,m.persist)(e=>({emailsVisible:!1,setEmailsVisible:t=>e({emailsVisible:t})}),{name:"omniroute-email-privacy"}));e.s(["default",0,x],209991);let p="loggerRefreshIntervalSec";function h(){return void 0===globalThis.window?null:window.localStorage}function b(e){return Number.isFinite(e)?Math.min(300,Math.max(1,Math.round(e))):10}var f=e.i(475394);function g(e){return(e?.tokens?.in||0)+(e?.tokens?.out||0)}function y(e){let t=e?.tokens?.out||0,s=e?.duration||0;return t<=0||s<=0?0:t/(s/1e3)}let v=(0,s.forwardRef)((e,u)=>{let{initialSelectedId:m}=e,v=(0,a.useTranslations)("requestLogger"),{emailsVisible:j}=x(),k=(0,s.useMemo)(()=>[{key:"all",label:v("statusFilters.all"),icon:""},{key:"error",label:v("statusFilters.error"),icon:"error"},{key:"ok",label:v("statusFilters.success"),icon:"check_circle"},{key:"combo",label:v("statusFilters.combo"),icon:"hub"}],[v]),N=(0,s.useMemo)(()=>[{key:"status",label:v("columns.status")},{key:"cacheSource",label:v("columns.cacheSource")},{key:"model",label:v("columns.model")},{key:"requestedModel",label:v("columns.requested")},{key:"provider",label:v("columns.provider")},{key:"protocol",label:v("columns.protocol")},{key:"account",label:v("columns.account")},{key:"apiKey",label:v("columns.apiKey")},{key:"combo",label:v("columns.combo")},{key:"tokens",label:v("columns.tokens")},{key:"tps",label:v("columns.tps")},{key:"duration",label:v("columns.duration")},{key:"time",label:v("columns.time")}
1],[v]),[w,S]=(0,s.useState)([]),[C,T]=(0,s.useState)(!0),[E,_]=(0,s.useState)(!0),[I,A]=(0,s.useState)(""),[D,K]=(0,s.useState)("all"),[L,M]=(0,s.useState)(""),[O,R]=(0,s.useState)(""),[F,P]=(0,s.useState)(""),[$,z]=(0,s.useState)(""),[B,U]=(0,s.useState)("newest"),[q,W]=(0,s.useState)(null),[H,G]=(0,s.useState)(""),[J,Y]=(0,s.useState)(null),[V,X]=(0,s.useState)(!1),[Q,Z]=(0,s.useState)(!1),ee={status:{desc:"status_desc",asc:"status_asc"},model:{desc:"model_desc",asc:"model_asc"},tokens:{desc:"tokens_desc",asc:"tokens_asc"},tps:{desc:"tps_desc",asc:"tps_asc"},duration:{desc:"duration_desc",asc:"duration_asc"},time:{desc:"newest",asc:"oldest"}},et=(0,s.useCallback)(e=>{let t=ee[e];t&&U(e=>e===t.desc?t.asc:t.desc)},[]),es=(0,s.useCallback)(e=>{let t=ee[e];return t?B===t.desc?" â":B===t.asc?" â":"":""},[B]),[er,ea]=(0,s.useState)(null),[el,ei]=(0,s.useState)(!1),[en,eo]=(0,s.useState)(!1),[ec,ed]=(0,s.useState)(50),[eu,em]=(0,s.useState)(!1),[ex,ep]=(0,s.useState)(10),eh=(0,s.useRef)(null),eb=(0,s.useRef)(10),ef=(0,s.useRef)(""),eg=(0,s.useRef)(!1),ey=(0,s.useRef)(""),ev=(0,s.useRef)(null),ej=(0,s.useRef)(null),ek=(0,s.useRef)(!1),[eN,ew]=(0,s.useState)([]),eS=(0,s.useRef)(!0),[eC,eT]=(0,s.useState)(()=>{let e=Object.fromEntries(N.map(e=>[e.key,!0]));if(void 0===globalThis.window)return e;try{let t=localStorage.getItem("loggerVisibleColumns");return t?{...e,...JSON.parse(t)}:e}catch{return e}}),eE=(0,s.useCallback)(e=>{eT(t=>{let s={...t,[e]:!t[e]};try{localStorage.setItem("loggerVisibleColumns",JSON.stringify(s))}catch{}return s})},[]);(0,s.useEffect)(()=>{let e=function(e=h()){if(!e)return 10;try{let t=e.getItem(p);if(!t)return 10;return b(Number.parseInt(t,10))}catch{return 10}}();eb.current=e,ep(e)},[]),(0,s.useEffect)(()=>{eb.current=ex},[ex]);let e_=(0,s.useCallback)(e=>{let t=eb.current,s=b("function"==typeof e?e(t):e);eb.current=s,function(e,t=h()){if(t)try{t.setItem(p,String(b(e)))}catch{return!1}}(s),ep(s)},[]),eI=(0,s.useCallback)(async(e=!1)=>{e&&T(!0);try{let e=new URLSearchParams;I&&e.set("search",I),"error"===D&&e.set("status","error"),"ok"===D&&e.set("status","ok"),"combo"===D&&e.set("combo","1"),L&&e.set("model",L),F&&e.set("provider",F),O&&e.set("account",O),$&&e.set("apiKey",$),H&&e.set("correlationId",H),e.set("limit",String(ec));let t=await fetch(`/api/usage/call-logs?${e}`);if(t.ok){let e=await t.json();em(Array.isArray(e)&&e.length>=ec);let s=(Array.isArray(e)?e:[]).map(e=>e.id+":"+e.status+":"+e.duration+":"+(e.tokens?.out||0)).join("|");s!==ey.current&&(ey.current=s,S(e))}}catch(e){console.error("Failed to fetch call logs:",e)}finally{e&&T(!1)}},[I,D,L,O,F,$,H,ec]);(0,s.useEffect)(()=>{let e=!eg.current;eg.current=!0,eI(e)},[eI]),(0,s.useEffect)(()=>{fetch("/api/provider-nodes").then(e=>e.ok?e.json():{nodes:[]}).then(e=>ew(e.nodes||[])).catch(()=>{})},[]),(0,s.useEffect)(()=>{fetch("/api/logs/detail?limit=1").then(async e=>e.ok?await e.json():null).then(e=>{e&&ei(!0===e.enabled)}).catch(()=>{})},[]),(0,s.useEffect)(()=>{let e=()=>{let e="visible"===document.visibilityState;eS.current=e,e&&!q&&E&&ec<=50&&eI(!1)},t=()=>{eS.current=!0,!q&&E&&ec<=50&&eI(!1)};return document.addEventListener("visibilitychange",e),window.addEventListener("focus",t),()=>{document.removeEventListener("visibilitychange",e),window.removeEventListener("focus",t)}},[E,ec,eI,q]),(0,s.useEffect)(()=>(eh.current&&clearInterval(eh.current),!q&&E&&ec<=50&&(eh.current=setInterval(()=>{(eS.current||"visible"===document.visibilityState)&&eI(!1)},1e3*ex)),()=>{eh.current&&clearInterval(eh.current)}),[E,eI,ec,ex,q]),(0,s.useEffect)(()=>{ed(50),ek.current=!1},[I,D,L,O,F,$,H]);let eA=(0,s.useCallback)(()=>{ed(e=>e+50)},[]);(0,s.useEffect)(()=>{let e=ev.current;if(!e)return;let t=()=>{e.scrollTop>0&&(ek.current=!0)};return e.addEventListener("scroll",t,{passive:!0}),()=>e.removeEventListener("scroll",t)},[]),(0,s.useEffect)(()=>{let e=ej.current,t=ev.current;if(!e||!eu)return;let s=new IntersectionObserver(e=>{var t;(t={isIntersecting:!!e[0]?.isIntersecting,hasMore:eu,loading:C,hasScrolled:ek.current}).isIntersecting&&t.hasMore&&!t.loading&&t.hasScrolled&&eA()},{root:t,rootMargin:"200px"});return s.observe(e),()=>s.disconnect()},[eu,C,eA]);let eD=(0,s.useMemo)(()=>{let e=w;return"error"===D?e=e.filter(e=>e.status>=400):"ok"===D?e=e.filter(e=>e.status>=200&&e.status<300):"combo"===D&&(e=e.filter(e=>e.comboName)),e},[w,D]),eK=(0,s.useMemo)(()=>
1{if(!V)return eD;let e=new Map,t=[];for(let s of eD){let r=s.correlationId;if(!r){t.push(s);continue}let a=e.get(r);(!a||new Date(s.timestamp).getTime()>new Date(a.timestamp).getTime())&&e.set(r,s)}return[...t,...e.values()]},[eD,V]),eL=(0,s.useMemo)(()=>{let e=[...eK];return e.sort((e,t)=>{switch(B){case"oldest":return new Date(e.timestamp).getTime()-new Date(t.timestamp).getTime();case"tokens_desc":return g(t)-g(e);case"tokens_asc":return g(e)-g(t);case"duration_desc":return(t.duration||0)-(e.duration||0);case"duration_asc":return(e.duration||0)-(t.duration||0);case"tps_desc":return y(t)-y(e);case"tps_asc":return y(e)-y(t);case"status_desc":return(t.status||0)-(e.status||0);case"status_asc":return(e.status||0)-(t.status||0);case"model_asc":return(e.model||"").localeCompare(t.model||"");case"model_desc":return(t.model||"").localeCompare(e.model||"");default:return new Date(t.timestamp).getTime()-new Date(e.timestamp).getTime()}}),e},[eK,B]),eM=(0,s.useMemo)(()=>{let e=new Map;for(let t of eL){let s=t.correlationId;s&&(e.has(s)||e.set(s,[]),e.get(s).push(t))}return eL.map(t=>{let s=t.correlationId;if(!s)return{...t,isRetry:!1,groupSize:1,groupStatus:null};let r=e.get(s);if(!r||r.length<=1)return{...t,isRetry:!1,groupSize:1,groupStatus:null};let a=r[0].id===t.id,l=r.some(e=>e.status>=400||e.active),i=r.some(e=>e.status>=200&&e.status<300);return{...t,isRetry:!a,groupSize:r.length,groupStatus:l&&i?"healed":l?"failed":null}})},[eL]),eO=(0,r.useRouter)(),eR=async e=>{if(!e?.id){try{eF()}catch{}return}let t=`${e.id}:${Date.now()}:${Math.random()}`;ef.current=t,W(e);try{let t=new URL(globalThis.location.href);t.searchParams.set("id",e.id),eO.replace(t.pathname+t.search)}catch(e){}Z(!0),ea(null);try{let s=await fetch(`/api/logs/${e.id}`,{cache:"no-store"});if(s.ok){let e=await s.json();if(ef.current!==t)return;let r=e?.pipelinePayloads&&Object.keys(e.pipelinePayloads||{}).length>0;ea(t=>({...t,...e,pipelinePayloads:r?e.pipelinePayloads:t?.pipelinePayloads})),e&&"object"==typeof e&&W(t=>({...t,...e,active:!0===e.active}))}else{if(ef.current!==t)return;if(404===s.status){if(e.pendingLookup||e.active){W(t=>({...t,id:e.id,status:0,method:t?.method,path:t?.path||""})),ea({detailState:"pending"});return}try{console.warn("Log not found:",e.id)}catch{}try{eF()}catch{}return}try{let e=await s.text().catch(()=>null);if(ef.current!==t)return;ea({error:`Failed to fetch log (status ${s.status})`,body:e})}catch{}}}catch(e){console.error("Failed to fetch log detail:",e)}finally{ef.current===t&&Z(!1)}},eF=()=>{ef.current="",W(null),ea(null);try{let e=new URL(globalThis.location.href);e.searchParams.delete("id"),eO.replace(e.pathname+e.search)}catch(e){}},eP=(0,s.useMemo)(()=>eL,[eL]);(0,s.useImperativeHandle)(u,()=>({openDetail:eR,getSortedLogs:()=>eP}),[eR,eP]);let e$=(0,s.useRef)(!1);(0,s.useEffect)(()=>{m&&!e$.current&&(e$.current=!0,eR({id:m,pendingLookup:!0}
1).then(e=>e).catch(e=>{console.error("Failed to open initial log id:",e)}))},[m]),(0,s.useEffect)(()=>{let e=q?.active===!0;if(!q?.id||!e)return;let t=!1,s=0,r=setInterval(async()=>{if("visible"===document.visibilityState)try{let a=await fetch(`/api/logs/${q.id}`,{cache:"no-store"});if(t)return;if(404===a.status){if(e)return;clearInterval(r);return}if(a.ok){let e=await a.json(),t=!0===e.active;ea(t=>({...t,...e,pipelinePayloads:e?.pipelinePayloads||t?.pipelinePayloads})),W(s=>({...s,...e,active:t})),!t&&++s>=3&&clearInterval(r)}}catch{}},1e3);return()=>{t=!0,clearInterval(r)}},[q?.id,er?.detailState,q?.active,eI]),(0,s.useEffect)(()=>{let e=q?.correlationId;if(!q?.id||!e)return;let t=!1,s=setInterval(async()=>{if("visible"===document.visibilityState)try{let s=await fetch(`/api/usage/call-logs?correlationId=${encodeURIComponent(e)}`,{cache:"no-store"});if(t||!s.ok)return;let r=await s.json();if(!Array.isArray(r)||0===r.length)return;S(e=>{r.map(e=>e.id);let t=!1,s=e.map(e=>{let s=r.find(t=>t.id===e.id);return s?(t=!0,{...e,...s}):e});for(let e of r)s.some(t=>t.id===e.id)||(s.push(e),t=!0);return t?s:e})}catch{}},3e3);return()=>{t=!0,clearInterval(s)}},[q?.id,q?.correlationId]);let ez=(0,s.useMemo)(()=>q?eP.findIndex(e=>e.id===q.id):-1,[q,eP]),eB=(0,s.useCallback)(()=>{let e=ez>0?eP[ez-1]:null;e?.id?eR(e).then(e=>e).catch(e=>{console.error("Failed to open previous log id:",e)}):eF()},[ez,eP]),eU=(0,s.useCallback)(()=>{let e=ez>=0&&ez<eP.length-1?eP[ez+1]:null;e?.id?eR(e).then(e=>e).catch(e=>{console.error("Failed to open previous log id:",e)}):eF()},[ez,eP]),eq=async()=>{eo(!0);try{let e=!el;if(!(await fetch("/api/logs/detail",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({enabled:e})})).ok)throw Error(v("updatePipelineFailed"));ei(e)}catch(e){console.error("Failed to toggle pipeline logging:",e)}finally{eo(!1)}},eW=(0,s.useMemo)(()=>[...new Set(w.map(e=>e.account).filter(e=>e&&"-"!==e))],[w]),eH=(0,s.useMemo)(()=>[...new Set(w.flatMap(e=>[e.model,e.requestedModel]).filter(Boolean))].sort(),[w]),eG=(0,s.useMemo)(()=>[...new Set(w.map(e=>e.provider).filter(e=>e&&"-"!==e))].sort(),[w]),eJ=(0,s.useMemo)(()=>[...new Set(w.map(e=>e.apiKeyId||e.apiKeyName).filter(Boolean))].sort(),[w]),{totalCount:eY,okCount:eV,errorCount:eX,comboCount:eQ,apiKeyCount:eZ,runningCount:e0}=(0,s.useMemo)(()=>({totalCount:eD.length,okCount:eD.filter(e=>e.status>=200&&e.status<300).length,errorCount:eD.filter(e=>e.status>=400).length,comboCount:w.filter(e=>e.comboName).length,apiKeyCount:eJ.length,runningCount:eD.filter(e=>!0===e.active).length}),[eD,w,eJ]);return(0,t.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-3",children:[(0,t.jsxs)("button",{onClick:()=>_(!E),className:`flex items-center gap-2 px-3 py-1.5 rounded-full text-sm font-medium border transition-colors ${E?"bg-red-500/10 border-red-500/30 text-red-700 dark:text-red-400":"bg-bg-subtle border-border text-text-muted"}`,children:[(0,t.jsx)("span",{className:`w-2 h-2 rounded-full ${E?"bg-red-500 animate-pulse":"bg-text-muted"}`}),E?v("recording"):v("paused")]}),(0,t.jsxs)("button",{onClick:eq,disabled:en,className:`flex items-center gap-2 px-3 py-1.5 rounded-full text-sm font-medium border transition-colors disabled:opacity-60 ${el?"bg-amber-500/10 border-amber-500/30 text-amber-700 dark:text-amber-300":"bg-bg-subtle border-border text-text-muted"}`,title:v("capturePipeline"),children:[(0,t.jsx)("span",{className:`w-2 h-2 rounded-full ${el?"bg-amber-500":"bg-text-muted"}`}),en?v("updatingPipelineLogs"):el?v("pipelineLogsOn"):v("pipelineLogsOff")]}),(0,t.jsxs)("div",{className:"flex-1 min-w-[200px] relative",children:[(0,t.jsx)("span",{className:"material-symbols-outlined absolute left-3 top-1/2 -translate-y-1/2 text-text-muted text-[18px]",children:"search"}),(0,t.jsx)("input",{type:"text",placeholder:v("searchPlaceholder"),value:I,onChange:e=>A(e.target.value),className:"w-full pl-10 pr-4 py-2 rounded-lg bg-bg-subtle border border-border text-sm text-text-primary placeholder:text-text-muted focus:outline-none focus:border-primary"})]}),(0,t.jsxs)("div",{className:"min-w-[180px] relative",children:[(0,t.jsx)("span",{className:"material-symbols-outlined absolute left-3 top-1/2 -translate-y-1/2 text-text-muted text-[16px]",children:"tag"}),(0,t.jsx)("input",{type:"text",placeholder:"Correlation ID",value:H,onChange:e=>G(e.target.value),className:"w-full pl-9 pr-3 py-2 rounded-lg bg-bg-subtle border border-border text-sm text-text-primary font-mono placeholder:text-text-muted focus:outline-none focus:border-primary"})]}),(0,t.jsxs)("button",{onClick:()=>X(e=>!e),className:`flex items-center gap-1.5 px-3 py-2 rounded-lg text-sm font-medium border transition-colors ${V?"bg-violet-500/15 border-violet-500/30 text-violet-700 dark:text-violet-300":"bg-bg-subtle border-border text-text-muted hover:text-text-primary"}`,title:V?"Show all rows":"Show latest per correlation ID",children:[(0,t.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:V?"unfold_less":"unfold_more"}),V?"Grouped":"All"]}),(0,t.jsxs)("select",{value:F,onChange:e=>P(e.target.value),className:"px-3 py-2 rounded-lg bg-bg-subtle border border-border text-sm text-text-primary focus:outline-none focus:border-primary appearance-none cursor-pointer min-w-[140px]",children:[(0,t.jsx)("option",{value:"",children:v("allProviders")}),eG.map(e=>{let s=(0,d.getProviderDisplayLabel)(e,eN),r=o.PROVIDER_COLORS[e];return(0,t.jsx)("option",{value:e,children:s||r?.label||e.toUpperCase()},e)})]}),(0,t.jsxs)("select",{value:L,onChange:e=>M(e.target.value),className:"px-3 py-2 rounded-lg bg-bg-subtle border border-border text-sm text-text-primary focus:outline-none focus:border-primary appearance-none cursor-pointer min-w-[180px]",children:[(0,t.jsx)("option",{value:"",children:v("allModels")}),eH.map(e=>(0,t.jsx)("option",{value:e,children:e},e))]}),(0,t.jsxs)("select",{value:O,onChange:e=>R(e.target.value),className:"px-3 py-2 rounded-lg bg-bg-subtle border border-border text-sm text-text-primary focus:outline-none focus:border-primary appearance-none cursor-pointer min-w-[140px]",children:[(0,t.jsx)("option",{value:"",children:v("allAccounts")}),eW.map(e=>(0,t.jsx)("option",{value:e,children:j?e:`${(0,c.maskAccount)(e,!1)} \xb7 #${(0,c.stableAccountSuffix)(e)}`},e))]}),(0,t.jsxs)("select",{value:$,onChange:e=>z(e.target.value),className:"px-3 py-2 rounded-lg bg-bg-subtle border border-border text-sm text-text-primary focus:outline-none focus:border-primary appearance-none cursor-pointer min-w-[160px]",children:[(0,t.jsx)("option",{value:"",children:v("allApiKeys")}),eJ.map(e=>{let s=w.find(t=>
1(t.apiKeyId||t.apiKeyName)===e),r=(0,c.formatApiKeyLabel)(s?.apiKeyName,s?.apiKeyId);return(0,t.jsx)("option",{value:e,children:r},e)})]}),(0,t.jsxs)("div",{className:"flex items-center gap-2 text-xs text-text-muted",children:[(0,t.jsxs)("span",{className:"px-2 py-1 rounded bg-bg-subtle border border-border font-mono",children:[eY," ",v("total")]}),e0>0&&(0,t.jsxs)("span",{className:"px-2 py-1 rounded bg-amber-500/10 text-amber-700 dark:text-amber-400 font-mono",children:[e0," running"]}),(0,t.jsxs)("span",{className:"px-2 py-1 rounded bg-emerald-500/10 text-emerald-700 dark:text-emerald-400 font-mono",children:[eV," ",v("ok")]}),eX>0&&(0,t.jsxs)("span",{className:"px-2 py-1 rounded bg-red-500/10 text-red-700 dark:text-red-400 font-mono",children:[eX," ",v("err")]}),eQ>0&&(0,t.jsxs)("span",{className:"px-2 py-1 rounded bg-violet-500/10 text-violet-700 dark:text-violet-400 font-mono",children:[eQ," ",v("combo")]}),eZ>0&&(0,t.jsxs)("span",{className:"px-2 py-1 rounded bg-primary/10 text-primary font-mono",children:[eZ," ",v("keys")]}),(0,t.jsxs)("span",{className:"px-2 py-1 rounded bg-bg-subtle border border-border font-mono",children:[eL.length," ",v("shown")]})]}),(0,t.jsxs)("select",{value:B,onChange:e=>U(e.target.value),className:"px-3 py-2 rounded-lg bg-bg-subtle border border-border text-sm text-text-primary focus:outline-none focus:border-primary appearance-none cursor-pointer min-w-[150px]",title:v("sortLogs"),children:[(0,t.jsx)("option",{value:"newest",children:v("sortNewest")}),(0,t.jsx)("option",{value:"oldest",children:v("sortOldest")}),(0,t.jsx)("option",{value:"tokens_desc",children:v("sortTokensDesc")}),(0,t.jsx)("option",{value:"tokens_asc",children:v("sortTokensAsc")}),(0,t.jsx)("option",{value:"duration_desc",children:v("sortDurationDesc")}),(0,t.jsx)("option",{value:"duration_asc",children:v("sortDurationAsc")}),(0,t.jsx)("option",{value:"status_desc",children:v("sortStatusDesc")}),(0,t.jsx)("option",{value:"status_asc",children:v("sortStatusAsc")}),(0,t.jsx)("option",{value:"model_asc",children:v("sortModelAsc")}),(0,t.jsx)("option",{value:"model_desc",children:v("sortModelDesc")})]}),(0,t.jsxs)("div",{className:"flex items-center gap-1",children:[(0,t.jsx)("button",{onClick:()=>e_(e=>e-1),className:"w-6 h-6 flex items-center justify-center rounded hover:bg-bg-subtle text-text-muted hover:text-text-primary transition-colors text-sm font-bold",title:"Decrease interval",children:"â"}),(0,t.jsx)("input",{type:"number",min:1,max:300,value:ex,onChange:e=>{let t=Number.parseInt(e.target.value,10);Number.isNaN(t)||e_(t)},className:"w-12 text-center text-[11px] bg-transparent border border-border rounded px-1 py-0.5 text-text-primary [appearance:textfield] [&::-webkit-inner-spin-button]:appearance-none [&::-webkit-outer-spin-button]:appearance-none",title:"Auto-refresh interval in seconds"}),(0,t.jsx)("button",{onClick:()=>e_(e=>e+1),className:"w-6 h-6 flex items-center justify-center rounded hover:bg-bg-subtle text-text-muted hover:text-text-primary transition-colors text-sm font-bold",title:"Increase interval",children:"+"}),(0,t.jsx)("span",{className:"text-[10px] text-text-muted",children:"s"})]}),(0,t.jsx)("button",{onClick:()=>eI(!1),className:"p-2 rounded-lg hover:bg-bg-subtle text-text-muted hover:text-text-primary transition-colors",title:v("refresh"),children:(0,t.jsx)("span",{className:"material-symbols-outlined text-[18px]",children:"refresh"})})]}),(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[k.map(e=>(0,t.jsxs)("button",{onClick:()=>K(D===e.key?"all":e.key),className:`flex items-center gap-1.5 px-3 py-1 rounded-full text-xs font-medium border transition-all ${D===e.key?"error"===e.key?"bg-red-500/20 text-red-700 dark:text-red-400 border-red-500/40":"ok"===e.key?"bg-emerald-500/20 text-emerald-700 dark:text-emerald-400 border-emerald-500/40":"combo"===e.key?"bg-violet-500/20 text-violet-700 dark:text-violet-300 border-violet-500/40":"bg-primary text-white border-primary":"bg-bg-subtle border-border text-text-muted hover:border-text-muted"}`,children:[e.icon&&(0,t.jsx)("span",{className:"material-symbols-outlined text-[14px]",children:e.icon}),e.label]},e.key)),eG.length>0&&(0,t.jsx)("span",{className:"w-px h-5 bg-border mx-1"}),eG.map(e=>{let s=(0,d.getProviderDisplayLabel)(e,eN),r=o.PROVIDER_COLORS[e]||{bg:"#374151",text:"#fff",label:s||e.toUpperCase()},a=s||r.label,l=F===e;return(0,t.jsx)("button",{onClick:()=>P(l?"":e),className:`px-3 py-1 rounded-full text-xs font-bold uppercase border transition-all ${l?"border-white/40 ring-1 ring-white/20":"border-transparent opacity-70 hover:opacity-100"}`,style:{backgroundColor:l?r.bg:`${r.bg}33`,color:l?r.text:r.bg},children:a},e)})]}),(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5",children:[(0,t.jsx)("span",{className:"text-[10px] text-text-muted uppercase tracking-wider mr-1",children:v("columnsLabel")}),N.map(e=>(0,t.jsx)("button",{onClick:()=>eE(e.key),className:`px-2 py-0.5 rounded text-[10px] font-medium border transition-all ${eC[e.key]?"bg-primary/15 text-primary border-primary/30":"bg-bg-subtle text-text-muted border-border opacity-50 hover:opacity-80"}`,children:e.label},e.key))]}),(0,t.jsx)(l.default,{padding:"none",className:"min-h-[460px] resize-y overflow-auto bg-surface",children:(0,t.jsxs)("div",{ref:ev,className:"p-0 overflow-x-auto overflow-y-auto h-full min-h-[460px]",children:[C&&0===w.length?(0,t.jsx)("div",{className:"p-8 text-center text-text-muted",children:v("loadingLogs")}):0===w.length?(0,t.jsxs)("div",{className:"p-8 text-center text-text-muted",children:[(0,t.jsx)("span",{className:"material-symbols-outlined text-[48px] mb-2 block opacity-40",children:"receipt_long"}),v("noLogs")]}):0===eL.length?(0,t.jsx)("div",{className:"p-8 text-center text-text-muted",children:v("noMatchingLogs")}):(0,t.jsxs)("table",{className:f.LOG_TABLE_CLASS,children:[(0,t.jsx)("thead",{className:f.LOG_TABLE_HEAD_CLASS,style:f.LOG_TABLE_HEADER_BG_STYLE,children:(0,t.jsxs)("tr",{className:f.LOG_TABLE_ROW_CLASS,style:f.LOG_TABLE_HEADER_BG_STYLE,children:[eC.status&&(0,t.jsxs)("th",{className:`${f.LOG_TABLE_HEADER_CELL_CLASS} cursor-pointer select-none`,onClick:()=>et("status"),children:[v("columns.status"),es("status")]}),eC.cacheSource&&(0,t.jsx)("th",{className:f.LOG_TABLE_HEADER_CELL_CLASS,children:v("columns.cacheSource")}),eC.model&&(0,t.jsx)("th",{className:f.LOG_TABLE_HEADER_CELL_CLASS,children:v("columns.model")}),eC.requestedModel&&(0,t.jsx)("th",{className:f.LOG_TABLE_HEADER_CELL_CLASS,children:v("columns.requested")}),eC.provider&&(0,t.jsx)("th",{className:f.LOG_TABLE_HEADER_CELL_CLASS,children:v("columns.provider")}),eC.protocol&&(0,t.jsx)("th",{className:f.LOG_TABLE_HEADER_CELL_CLASS,children:v("columns.protocol")}),eC.account&&(0,t.jsx)("th",{className:f.LOG_TABLE_HEADER_CELL_CLASS,children:v("columns.account")}
1),eC.apiKey&&(0,t.jsx)("th",{className:f.LOG_TABLE_HEADER_CELL_CLASS,children:v("columns.apiKey")}),eC.combo&&(0,t.jsx)("th",{className:f.LOG_TABLE_HEADER_CELL_CLASS,children:v("columns.combo")}),eC.tokens&&(0,t.jsxs)("th",{className:`${f.LOG_TABLE_HEADER_CELL_RIGHT_CLASS} cursor-pointer select-none`,onClick:()=>et("tokens"),children:[v("columns.tokens"),es("tokens")]}),eC.tps&&(0,t.jsxs)("th",{className:`${f.LOG_TABLE_HEADER_CELL_RIGHT_CLASS} cursor-pointer select-none`,onClick:()=>et("tps"),children:[v("columns.tps"),es("tps")]}),eC.duration&&(0,t.jsxs)("th",{className:`${f.LOG_TABLE_HEADER_CELL_RIGHT_CLASS} cursor-pointer select-none`,onClick:()=>et("duration"),children:[v("columns.duration"),es("duration")]}),eC.time&&(0,t.jsxs)("th",{className:`${f.LOG_TABLE_HEADER_CELL_RIGHT_CLASS} cursor-pointer select-none`,onClick:()=>et("time"),children:[v("columns.time"),es("time")]})]})}),(0,t.jsx)("tbody",{className:"divide-y divide-border/30",children:eM.map(e=>{let s,r,a=!0===e.active,l=a?null:(0,o.getHttpStatusStyle)(e.status),i=a?null:e.sourceFormat||e.provider,n=i?(0,o.getProtocolColor)(i,e.provider):null,u=(0,d.getProviderDisplayLabel)(e.provider,eN),m=o.PROVIDER_COLORS[e.provider]||{bg:"#374151",text:"#fff",label:u||(e.provider||"-").toUpperCase()},x=e.providerDisplay||u||m.label,p=!a&&e.status>=400,h="semantic"===e.cacheSource?{key:"semantic",className:"bg-emerald-500/15 text-emerald-700 dark:text-emerald-300 border border-emerald-500/30"}:{key:"upstream",className:"bg-sky-500/15 text-sky-700 dark:text-sky-300 border border-sky-500/30"},b=h?.key==="semantic",f=(0,c.maskAccount)(e.account,j);return(0,t.jsxs)("tr",{onClick:()=>eR(e),"data-cid":e.correlationId||void 0,onMouseEnter:()=>e.correlationId&&Y(e.correlationId),onMouseLeave:()=>Y(null),className:`cursor-pointer transition-colors ${p?"bg-red-500/5 hover:bg-red-500/15 dark:hover:bg-red-400/15":"hover:bg-sky-500/10 dark:hover:bg-sky-400/10"} ${e.isRetry?"border-l-2 border-l-amber-500/50":""} ${J&&e.correlationId===J?"bg-violet-500/10 dark:bg-violet-400/10 ring-1 ring-violet-500/20":""}`,style:e.isRetry?{backgroundColor:J&&e.correlationId===J?void 0:"rgba(245,158,11,0.03)"}:void 0,children:[eC.status&&(0,t.jsx)("td",{className:"px-3 py-2",children:a?(0,t.jsx)("span",{className:"inline-flex items-center justify-center w-7 h-7 rounded-full bg-amber-500/15 border border-amber-500/25",title:"In progress",children:(0,t.jsx)("span",{className:"inline-block h-3 w-3 rounded-full border-2 border-amber-500 border-t-transparent animate-spin"})}):(0,t.jsxs)("span",{className:"inline-flex items-center gap-1",children:[(0,t.jsx)("span",{className:"inline-block px-2 py-0.5 rounded text-[10px] font-bold min-w-[36px] text-center",style:{backgroundColor:l.bg,color:l.text},children:e.status||"..."}),"healed"===e.groupStatus&&!e.isRetry&&e.status>=400&&(0,t.jsx)("span",{className:"text-emerald-500 text-[11px]",title:"Recovered by retry",children:"â"}),e.isRetry&&(0,t.jsx)("button",{className:"inline-flex items-center text-amber-500 hover:text-amber-400 text-[11px] ml-0.5",title:"Go to parent request",onClick:t=>{t.stopPropagation();let s=eM.find(t=>t.correlationId===e.correlationId&&!t.isRetry);s&&eR(s)},children:"â³"})]})}),eC.cacheSource&&(0,t.jsx)("td",{className:"px-3 py-2",children:a?(0,t.jsx)("span",{className:"text-text-muted text-[10px]",children:"â"}):(0,t.jsx)("span",{className:`inline-block px-2 py-0.5 rounded text-[9px] font-bold uppercase ${h?.className||""}`,title:b?v("semanticCacheHit"):v("upstreamResponse"),children:b?v("semantic"):v("upstream")})}),eC.model&&(0,t.jsxs)("td",{className:"px-3 py-2 font-medium text-primary font-mono text-[11px]",children:[(0,t.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,t.jsx)("span",{children:e.model}),"healed"===e.groupStatus&&!e.isRetry&&(0,t.jsx)("span",{className:"inline-flex items-center gap-0.5 px-1 py-0 rounded text-[8px] font-bold bg-emerald-500/15 text-emerald-600 dark:text-emerald-400 border border-emerald-500/25",title:`Failed, recovered after ${e.groupSize-1} retry`,children:"healed"}),"failed"===e.groupStatus&&!e.isRetry&&(0,t.jsx)("span",{className:"inline-flex items-center gap-0.5 px-1 py-0 rounded text-[8px] font-bold bg-red-500/15 text-red-600 dark:text-red-400 border border-red-500/25",title:`All ${e.groupSize} attempts failed`,children:"failed"}),e.modelPinned&&(0,t.jsx)("span",{className:"inline-flex items-center gap-0.5 px-1 py-0 rounded text-[8px] font-bold bg-vi
1olet-500/15 text-violet-600 dark:text-violet-400 border border-violet-500/25",title:"Model selected via context-cache session pinning",children:"pinned"})]}),e.correlationId&&!e.isRetry&&e.groupSize>1&&(0,t.jsxs)("div",{className:"text-[9px] text-text-muted font-normal truncate max-w-[120px]",title:e.correlationId,children:[e.correlationId.slice(0,12),"⦠· ",e.groupSize," attempts"]}),e.correlationId&&!e.isRetry&&e.groupSize<=1&&(0,t.jsxs)("div",{className:"text-[9px] text-text-muted font-normal truncate max-w-[120px]",title:e.correlationId,children:[e.correlationId.slice(0,12),"â¦"]}),e.correlationId&&e.isRetry&&(0,t.jsxs)("div",{className:"text-[9px] text-amber-500/70 font-normal truncate max-w-[120px]",title:e.correlationId,children:[e.correlationId.slice(0,12),"â¦"]})]}),eC.requestedModel&&(0,t.jsx)("td",{className:"px-3 py-2 font-mono text-[11px]",children:e.requestedModel?(0,t.jsx)("span",{className:e.requestedModel!==e.model?"text-amber-600 dark:text-amber-400":"text-text-muted",title:e.requestedModel!==e.model?v("requestedRoutedTitle",{requested:e.requestedModel,routed:e.model}):e.requestedModel,children:e.requestedModel}):(0,t.jsx)("span",{className:"text-text-muted text-[10px]",children:"â"})}),eC.provider&&(0,t.jsx)("td",{className:"px-3 py-2",children:(0,t.jsx)("span",{className:"inline-block px-2 py-0.5 rounded text-[9px] font-bold uppercase",style:{backgroundColor:m.bg,color:m.text},children:x})}),eC.protocol&&(0,t.jsx)("td",{className:"px-3 py-2",children:a?(0,t.jsx)("span",{className:"text-text-muted text-[10px]",children:"â"}):(0,t.jsx)("span",{className:"inline-block px-2 py-0.5 rounded text-[9px] font-bold uppercase",style:n?{backgroundColor:n.bg,color:n.text}:{},children:n?.label||"â"})}),eC.account&&(0,t.jsx)("td",{className:"px-3 py-2 text-text-muted truncate max-w-[120px]",title:f,children:f}),eC.apiKey&&(0,t.jsx)("td",{className:"px-3 py-2 text-text-muted truncate max-w-[140px]",title:e.apiKeyName||e.apiKeyId||v("noApiKey"),children:a?(0,t.jsx)("span",{className:"text-text-muted text-[10px]",children:"â"}):(0,c.formatApiKeyLabel)(e.apiKeyName,e.apiKeyId)}),eC.combo&&(0,t.jsx)("td",{className:"px-3 py-2",children:a?(0,t.jsx)("span",{className:"text-text-muted text-[10px]",children:"â"}):e.comboName?(0,t.jsx)("span",{className:"inline-block px-2 py-0.5 rounded-full text-[9px] font-bold bg-violet-500/20 text-violet-800 dark:text-violet-300 border border-violet-500/40",children:e.comboName}):(0,t.jsx)("span",{className:"text-text-muted text-[10px]",children:"â"})}),eC.tokens&&(0,t.jsx)("td",{className:"px-3 py-2 text-right whitespace-nowrap",children:a?(0,t.jsx)("span",{className:"text-text-muted text-[10px]",children:"â"}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("span",{className:"text-text-muted",children:"TI:"})," ",(0,t.jsx)("span",{className:"text-primary",children:e.tokens?.in?.toLocaleString()||0}),(0,t.jsx)("span",{className:"mx-1 text-border",children:"|"}),(0,t.jsx)("span",{className:"text-text-muted",children:"TO:"})," ",(0,t.jsx)("span",{className:"text-emerald-700 dark:text-emerald-400",children:e.tokens?.out?.toLocaleString()||0}),e.tokens?.compressed!=null&&e.tokens.compressed>0&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("span",{className:"mx-1 text-border",children:"|"}),(0,t.jsxs)("span",{className:"text-purple-500 dark:text-purple-400 font-semibold",title:`${e.tokens.compressed.toLocaleString()} tokens compressed`,children:["â",e.tokens.compressed.toLocaleString()]})]})]})}),eC.tps&&(0,t.jsx)("td",{className:"px-3 py-2 text-right whitespace-nowrap font-mono",children:a?(0,t.jsx)("span",{className:"text-text-muted text-[10px]",children:"â"}):(r=(s=y(e))<=0?"text-text-muted":s>=80?"text-emerald-600 dark:text-emerald-400":s>=30?"text-sky-600 dark:text-sky-400":"text-amber-600 dark:text-amber-400",(0,t.jsx)("span",{className:r,title:`${s.toFixed(2)} tokens/sec`,children:s<=0?"â":s>=100?Math.round(s).toLocaleString():s.toFixed(1)}))}),eC.duration&&(0,t.jsx)("td",{className:"px-3 py-2 text-right text-text-muted font-mono",children:(0,c.formatDuration)(e.duration)}),eC.time&&(0,t.jsx)("td",{className:"px-3 py-2 text-right text-text-muted",children:(0,c.formatTime)(e.timestamp)})]},e.id)})})]}),eu&&eL.length>0&&(0,t.jsx)("div",{ref:ej,className:"flex justify-center py-3 border-t border-border/30",children:(0,t.jsx)("button",{type:"button",onClick:eA,className:"px-4 py-1.5 text-xs rounded-md border border-border bg-bg-subtle hover:bg-bg-muted text-text-muted transition-colors",children:C?v("loadingMore"):v("loadMore")})})]})}),(0,t.jsx)("div",{className:"text-[10px] text-text-muted italic",children:v("callLogsInfo",{dataDir:"{DATA_DIR}/call_logs/",retentionDays:"CALL_LOG_RETENTION_DAYS",maxEntries:"CALL_LOG_MAX_ENTRIES"})}),q&&(0,t.jsx)(i.default,{log:q,detail:er,loading:Q,debugEnabled:!!q.active||el,emailsVisible:j,onClose:eF,onCopy:n.copyToClipboard,onPrevious:eB,onNext:eU,relatedLogs:q.correlationId?eM.filter(e=>e.correlationId===q.correlationId):[],onSelectRelated:e=>{eF(),eR(e)}})]})});v.displayName="RequestLoggerV2",e.s(["default",0,v],953789)},621745,e=>{"use strict";var t=e.i(843476),s=e.i(271645),r=e.i(703166),a=e.i(342923),l=e.i(80173);e.s(["default",0,function({isOpen:e,providerId:i="kiro",providerLabel:n="Kiro",onMethodSelect:o,onClose:c}
1){let[d,u]=(0,s.useState)(null),[m,x]=(0,s.useState)(""),[p,h]=(0,s.useState)("us-east-1"),[b,f]=(0,s.useState)(""),[g,y]=(0,s.useState)(""),[v,j]=(0,s.useState)("us-east-1"),[k,N]=(0,s.useState)(null),[w,S]=(0,s.useState)(!1),[C,T]=(0,s.useState)(!1),[E,_]=(0,s.useState)(!1);(0,s.useEffect)(()=>{e||(u(null),x(""),h("us-east-1"),f(""),y(""),j("us-east-1"),N(null))},[e]),(0,s.useEffect)(()=>{"import"===d&&e&&(async()=>{_(!0),N(null);try{let e=await fetch(`/api/oauth/kiro/auto-import?targetProvider=${encodeURIComponent(i)}`),t=await e.json();if(t.found){o("import"),c();return}N(t.error||"Could not auto-detect token")}catch(e){N("Failed to auto-detect token")}finally{_(!1)}})()},[i,d,e,o,c]);let I=e=>{u(e),N(null)},A=()=>{u(null),N(null)},D=async()=>{if(!b.trim())return void N("Please enter a refresh token");S(!0),N(null);try{let e=await fetch(`/api/oauth/kiro/import?targetProvider=${encodeURIComponent(i)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({refreshToken:b.trim()})}),t=await e.json();if(!e.ok)throw Error(t.error||"Import failed");o("import"),c()}catch(e){N(e instanceof Error?e.message:"Import failed")}finally{S(!1)}},K=async()=>{if(!g.trim())return void N("Please enter a Kiro API key");T(!0),N(null);try{let e=await fetch(`/api/oauth/kiro/api-key?targetProvider=${encodeURIComponent(i)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({apiKey:g.trim(),region:v.trim()||"us-east-1"})}),t=await e.json();if(!e.ok)throw Error(t.error?.message||t.error||"API key import failed");o("api-key"),c()}catch(e){N(e instanceof Error?e.message:"API key import failed")}finally{T(!1)}},L=e=>{o("social",{provider:e})};return(0,t.jsx)(r.default,{isOpen:e,title:`Connect ${n}`,onClose:c,size:"lg",children:(0,t.jsxs)("div",{className:"flex flex-col gap-4",children:[!d&&(0,t.jsxs)("div",{className:"space-y-3",children:[(0,t.jsx)("p",{className:"text-sm text-text-muted mb-4",children:"Choose your authentication method:"}),(0,t.jsx)("button",{onClick:()=>o("builder-id"),className:"w-full p-4 text-left border border-border rounded-lg hover:bg-sidebar transition-colors",children:(0,t.jsxs)("div",{className:"flex items-start gap-3",children:[(0,t.jsx)("span",{className:"material-symbols-outlined text-primary mt-0.5",children:"shield"}),(0,t.jsxs)("div",{className:"flex-1",children:[(0,t.jsx)("h3",{className:"font-semibold mb-1",children:"AWS Builder ID"}),(0,t.jsxs)("p",{className:"text-sm text-text-muted",children:["Recommended for most users. Sign in with the AWS account linked to"," ",n,"."]})]})]})}),(0,t.jsx)("button",{onClick:()=>I("idc"),className:"w-full p-4 text-left border border-border rounded-lg hover:bg-sidebar transition-colors",children:(0,t.jsxs)("div",{className:"flex items-start gap-3",children:[(0,t.jsx)("span",{className:"material-symbols-outlined text-primary mt-0.5",children:"business"}),(0,t.jsxs)("div",{className:"flex-1",children:[(0,t.jsx)("h3",{className:"font-semibold mb-1",children:"Your Organization (AWS IAM Identity Center)"}),(0,t.jsx)("p",{className:"text-sm text-text-muted",children:"Use your company SSO start URL (example: https://your-org.awsapps.com/start)."})]})]})}),(0,t.jsx)("button",{onClick:()=>L("google"),className:"w-full p-4 text-left border border-border rounded-lg hover:bg-sidebar transition-colors",children:(0,t.jsxs)("div",{className:"flex items-start gap-3",children:[(0,t.jsx)("span",{className:"material-symbols-outlined text-primary mt-0.5",children:"account_circle"}),(0,t.jsxs)("div",{className:"flex-1",children:[(0,t.jsx)("h3",{className:"font-semibold mb-1",children:"Google Account"}),(0,t.jsx)("p",{className:"text-sm text-text-muted",children:"Login with your Google account."})]})]})}),(0,t.jsx)("button",{onClick:()=>L("github"),className:"w-full p-4 text-left border border-border rounded-lg hover:bg-sidebar transition-colors",children:(0,t.jsxs)("div",{className:"flex items-start gap-3",children:[(0,t.jsx)("span",{className:"material-symbols-outlined text-primary mt-0.5",children:"code"}),(0,t.jsxs)("div",{className:"flex-1",children:[(0,t.jsx)("h3",{className:"font-semibold mb-1",children:"GitHub Account"}),(0,t.jsx)("p",{className:"text-sm text-text-muted",children:"Login with your GitHub account."})]})]})}),(0,t.jsx)("button",{onClick:()=>I("import"),className:"w-full p-4 text-left border border-border rounded-lg hover:bg-sidebar transition-colors",children:(0,t.jsxs)("div",{className:"flex items-start gap-3",children:[(0,t.jsx)("span",{className:"material-symbols-outlined text-primary mt-0.5",children:"file_upload"}),(0,t.jsxs)("div",{className:"flex-1",children:[(0,t.jsx)("h3",{className:"font-semibold mb-1",children:"Import Token"}),(0,t.jsxs)("p",{className:"text-sm text-text-muted",children:["Paste a refresh token exported from ",n,"."]})]})]})}),(0,t.jsx)("button",{onClick:()=>I("api-key"),className:"w-full p-4 text-left border border-border rounded-lg hover:bg-sidebar transition-colors",children:(0,t.jsxs)("div",{className:"flex items-start gap-3",children:[(0,t.jsx)("span",{className:"material-symbols-outlined text-primary mt-0.5",children:"key"}),(0,t.jsxs)("div",{className:"flex-1",children:[(0,t.jsx)("h3",{className:"font-semibold mb-1",children:"API Key"}),(0,t.jsxs)("p",{className:"text-sm text-text-muted",children:["Paste a long-lived ",n," / CodeWhisperer API key. It is stored as a bearer credential with no refresh token; profile discovery is best-effort."]})]})]})})]}),"idc"===d&&(0,t.jsxs)("div",{className:"space-y-4",children:[(0,t.jsxs)("div",{children:[(0,t.jsxs)("label",{className:"block text-sm font-medium mb-2",children:["IDC Start URL ",(0,t.jsx)("span",{className:"text-red-500",children:"*"})]}),(0,t.jsx)(l.default,{value:m,onChange:e=>x(e.target.value),placeholder:"https://your-org.awsapps.com/start",className:"font-mono text-sm"}),(0,t.jsx)("p",{className:"text-xs text-text-muted mt-1",children:"Your organization's AWS IAM Identity Center URL"})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"block text-sm font-medium mb-2",children:"AWS Region"}),(0,t.jsx)(l.default,{value:p,onChange:e=>h(e.target.value),placeholder:"us-east-1",className:"font-mono text-sm"}),(0,t.jsx)("p",{className:"text-xs text-text-muted mt-1",children:"AWS region for your Identity Center (default: us-east-1)"})]}
1),k&&(0,t.jsx)("p",{className:"text-sm text-red-600",children:k}),(0,t.jsxs)("div",{className:"flex gap-2",children:[(0,t.jsx)(a.default,{onClick:()=>{m.trim()?o("idc",{startUrl:m.trim(),region:p}):N("Please enter your IDC start URL")},fullWidth:!0,children:"Continue"}),(0,t.jsx)(a.default,{onClick:A,variant:"ghost",fullWidth:!0,children:"Back"})]})]}),"import"===d&&(0,t.jsxs)("div",{className:"space-y-4",children:[E&&(0,t.jsxs)("div",{className:"text-center py-6",children:[(0,t.jsx)("div",{className:"size-16 mx-auto mb-4 rounded-full bg-primary/10 flex items-center justify-center",children:(0,t.jsx)("span",{className:"material-symbols-outlined text-3xl text-primary animate-spin",children:"progress_activity"})}),(0,t.jsx)("h3",{className:"text-lg font-semibold mb-2",children:"Auto-detecting token..."}),(0,t.jsxs)("p",{className:"text-sm text-text-muted",children:["Reading ",n," credentials from AWS SSO cache"]})]}),!E&&(0,t.jsxs)(t.Fragment,{children:[!k&&(0,t.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,t.jsxs)("div",{className:"flex gap-2",children:[(0,t.jsx)("span",{className:"material-symbols-outlined text-blue-600 dark:text-blue-400",children:"info"}),(0,t.jsxs)("p",{className:"text-sm text-blue-800 dark:text-blue-200",children:[n," token was not auto-detected. Please paste your refresh token manually."]})]})}),(0,t.jsxs)("div",{children:[(0,t.jsxs)("label",{className:"block text-sm font-medium mb-2",children:["Refresh Token ",(0,t.jsx)("span",{className:"text-red-500",children:"*"})]}),(0,t.jsx)(l.default,{type:"password",value:b,onChange:e=>f(e.target.value),placeholder:"Token will be auto-filled...",className:"font-mono text-sm"})]}),k&&(0,t.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,t.jsx)("p",{className:"text-sm text-red-600 dark:text-red-400",children:k})}),(0,t.jsxs)("div",{className:"flex gap-2",children:[(0,t.jsx)(a.default,{onClick:D,fullWidth:!0,disabled:w||!b.trim(),children:w?"Importing...":"Import Token"}),(0,t.jsx)(a.default,{onClick:A,variant:"ghost",fullWidth:!0,children:"Back"})]})]})]}),"api-key"===d&&(0,t.jsxs)("div",{className:"space-y-4",children:[(0,t.jsxs)("div",{children:[(0,t.jsxs)("label",{className:"block text-sm font-medium mb-2",children:["API Key ",(0,t.jsx)("span",{className:"text-red-500",children:"*"})]}),(0,t.jsx)(l.default,{type:"password",value:g,onChange:e=>y(e.target.value),placeholder:`Paste your ${n} API key...`,className:"font-mono text-sm"}),(0,t.jsx)("p",{className:"text-xs text-text-muted mt-1",children:"Stored encrypted as a long-lived bearer credential. There is no refresh flow."})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"block text-sm font-medium mb-2",children:"AWS Region"}),(0,t.jsx)(l.default,{value:v,onChange:e=>j(e.target.value),placeholder:"us-east-1",className:"font-mono text-sm"}),(0,t.jsx)("p",{className:"text-xs text-text-muted mt-1",children:"AWS region for the key (default: us-east-1)"})]}),k&&(0,t.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,t.jsx)("p",{className:"text-sm text-red-600 dark:text-red-400",children:k})}),(0,t.jsxs)("div",{className:"flex gap-2",children:[(0,t.jsx)(a.default,{onClick:K,fullWidth:!0,disabled:C||!g.trim(),children:C?"Validating...":"
1Validate and Save API Key"}),(0,t.jsx)(a.default,{onClick:A,variant:"ghost",fullWidth:!0,children:"Back"})]})]})]})})}])},17517,e=>{"use strict";var t=e.i(843476),s=e.i(271645),r=e.i(703166),a=e.i(342923),l=e.i(954565);e.s(["default",0,function({isOpen:e,provider:i,targetProvider:n,providerLabel:o="Kiro",onSuccess:c,onClose:d}){let[u,m]=(0,s.useState)("loading"),[x,p]=(0,s.useState)(null),[h,b]=(0,s.useState)(""),[f,g]=(0,s.useState)(""),y=(0,s.useRef)(null),v=(0,s.useRef)(c);(0,s.useEffect)(()=>{v.current=c},[c]),(0,s.useEffect)(()=>{if(!e||!i)return;let t=!1,s=()=>{y.current&&clearTimeout(y.current),y.current=null},r=e=>{s(),t||(p(e),m("error"))};return(async()=>{try{p(null),m("loading");let e=await fetch(`/api/oauth/kiro/social-authorize?provider=${i}`),a=await e.json();if(t)return;if(!e.ok)throw Error(a.error||"Failed to start authorization");b(a.userCode||""),g(a.authUrl||""),m("polling");let l=1e3*Math.max(1,Number(a.interval)||5),o=l,c=Date.now()+1e3*Math.max(1,Number(a.expiresIn)||300),d=e=>{t||(y.current=setTimeout(u,e))},u=async()=>{if(y.current=null,!t){if(Date.now()>=c)return void r("Authorization expired. Start the login flow again.");try{var e,l;let c=await fetch("/api/oauth/kiro/social-exchange",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({deviceCode:a.deviceCode,provider:i,targetProvider:n})}),u=await c.json();if(t)return;if(u.success){s(),m("success"),v.current?.();return}if(!u.pending)return void r(u.error||"Authorization failed");e=o,l=u.error,o="slow_down"===l?e+5e3:e,d(o)}catch{d(o)}}};d(l)}catch(e){r(e.message)}})(),()=>{t=!0,s()}},[e,i,n]);let j=()=>{y.current&&(clearTimeout(y.current),y.current=null),d()},k="google"===i?"Google":"GitHub";return(0,t.jsx)(r.default,{isOpen:e,title:`Connect ${o} via ${k}`,onClose:j,size:"lg",children:(0,t.jsxs)("div",{className:"flex flex-col gap-4",children:["loading"===u&&(0,t.jsxs)("div",{className:"text-center py-6",children:[(0,t.jsx)("div",{className:"size-16 mx-auto mb-4 rounded-full bg-primary/10 flex items-center justify-center",children:(0,t.jsx)("span",{className:"material-symbols-outlined text-3xl text-primary animate-spin",children:"progress_activity"})}),(0,t.jsx)("h3",{className:"text-lg font-semibold mb-2",children:"Initializing..."}),(0,t.jsxs)("p",{className:"text-sm text-text-muted",children:["Setting up ",k," authentication"]})]}),"polling"===u&&(0,t.jsxs)("div",{className:"text-center py-6",children:[(0,t.jsx)("div",{className:"size-16 mx-auto mb-4 rounded-full bg-primary/10 flex items-center justify-center",children:(0,t.jsx)("span",{className:"material-symbols-outlined text-3xl text-primary animate-pulse",children:"open_in_browser"})}),(0,t.jsx)("h3",{className:"text-lg font-semibold mb-2",children:"Open this link in an Incognito window"}),(0,t.jsx)("p",{className:"text-sm text-text-muted mb-3",children:"Use an Incognito/Private window to avoid session conflicts with existing accounts."}),f&&(0,t.jsx)("div",{className:"mb-4",children:(0,t.jsxs)("div",{className:"flex items-center gap-2 justify-center",children:[(0,t.jsx)("a",{href:f,target:"_blank",rel:"noopener noreferrer",className:"text-xs font-mono text-primary underline break-all max-w-md inline-block",children:f.length>80?f.slice(0,80)+"...":f}),(0,t.jsx)("button",{onClick:()=>(0,l.copyToClipboard)(f),className:"shrink-0 p-1 rounded hover:bg-sidebar",title:"Copy link",children:(0,t.jsx)("span",{className:"material-symbols-outlined text-base",children:"content_copy"})})]})}),h&&(0,t.jsxs)("div",{className:"mb-4",children:[(0,t.jsx)("p",{className:"text-xs text-text-muted mb-1",children:"Verification code"}),(0,t.jsx)("p",{className:"font-mono text-2xl font-bold tracking-widest",children:h})]}),(0,t.jsxs)("div",{className:"flex items-center justify-center gap-2 text-sm text-text-muted",children:[(0,t.jsx)("span",{className:"material-symbols-outlined text-base animate-spin",children:"progress_activity"}),"Waiting for authorization..."]}),(0,t.jsx)("div",{className:"mt-6",children:(0,t.jsx)(a.default,{onClick:j,variant:"ghost",fullWidth:!0,children:"Cancel"})})]}),"success"===u&&(0,t.jsxs)("div",{className:"text-center py-6",children:[(0,t.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,t.jsx)("span",{className:"material-symbols-outlined text-3xl text-green-600",children:"check_circle"})}),(0,t.jsx)("h3",{className:"text-lg font-semibold mb-2",children:"Connected Successfully!"}),(0,t.jsxs)("p",{className:"text-sm text-text-muted mb-4",children:["Your ",o," account via ",k," has been connected."]}),(0,t.jsx)(a.default,{onClick:j,fullWidth:!0,children:"Done"})]}),"error"===u&&(0,t.jsxs)("div",{className:"text-center py-6",children:[(0,t.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,t.jsx)("span",{className:"material-symbols-outlined text-3xl text-red-600",children:"error"})}),(0,t.jsx)("h3",{className:"text-lg font-semibold mb-2",children:"Connection Failed"}),(0,t.jsx)("p",{className:"text-sm text-red-600 mb-4",children:x}),(0,t.jsx)("div",{className:"flex gap-2",children:(0,t.jsx)(a.default,{onClick:j,variant:"ghost",fullWidth:!0,children:"Close"})})]})]})})}],17517)}
1,567955,e=>{"use strict";var t=e.i(843476),s=e.i(271645),r=e.i(964039),a=e.i(621745),l=e.i(17517);e.s(["default",0,function({isOpen:e,providerInfo:i,onSuccess:n,onClose:o,reauthConnection:c}){let[d,u]=(0,s.useState)(null),[m,x]=(0,s.useState)(null),[p,h]=(0,s.useState)(null),b=(0,s.useCallback)((e,t)=>{"builder-id"===e?u("builder-id"):"idc"===e?(u("idc"),h(t)):"social"===e?(u("social"),x(t.provider)):"import"===e?n?.():"api-key"===e&&n?.()},[n]),f=()=>{u(null),x(null),h(null)},g=(0,s.useCallback)(()=>{u(null),x(null),n?.()},[n]),y=i?.id||"kiro",v=i?.name||"Kiro";return d?"builder-id"===d||"idc"===d?(0,t.jsx)(r.default,{isOpen:e,provider:y,providerInfo:i,onSuccess:()=>{u(null),h(null),n?.()},reauthConnection:c,onClose:f,idcConfig:p}):"social"===d&&m?(0,t.jsx)(l.default,{isOpen:e,provider:m,targetProvider:y,providerLabel:v,onSuccess:g,onClose:f}):null:(0,t.jsx)(a.default,{isOpen:e,providerId:y,providerLabel:v,onMethodSelect:b,onClose:o})}])},419947,e=>{"use strict";var t=e.i(843476),s=e.i(271645),r=e.i(948148),a=e.i(703166),l=e.i(342923),i=e.i(80173);e.s(["default",0,function({isOpen:e,onSuccess:n,onClose:o,reauthConnection:c}){let d=(0,r.useTranslations)("cursorAuthModal"),[u,m]=(0,s.useState)(""),[x,p]=(0,s.use
1State)(""),[h,b]=(0,s.useState)(null),[f,g]=(0,s.useState)(!1),[y,v]=(0,s.useState)(!1),[j,k]=(0,s.useState)(!1);(0,s.useEffect)(()=>{e&&(async()=>{v(!0),b(null),k(!1);try{let e=await fetch("/api/oauth/cursor/auto-import"),t=await e.json();t.found?(m(t.accessToken),p(t.machineId||""),k(!0)):b(t.error||d("errorAutoDetect"))}catch(e){b(d("errorAutoDetectFailed"))}finally{v(!1)}})()},[e]);let N=async()=>{if(!u.trim())return void b(d("errorEnterToken"));g(!0),b(null);try{let e={accessToken:u.trim()};x.trim()&&(e.machineId=x.trim());let t=await fetch("/api/oauth/cursor/import",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),s=await t.json();if(!t.ok)throw Error(s.error||d("errorImportFailed"));n?.(),o()}catch(e){b(e.message)}finally{g(!1)}};return(0,t.jsx)(a.default,{isOpen:e,title:d("title"),onClose:o,children:(0,t.jsxs)("div",{className:"flex flex-col gap-4",children:[y&&(0,t.jsxs)("div",{className:"text-center py-6",children:[(0,t.jsx)("div",{className:"size-16 mx-auto mb-4 rounded-full bg-primary/10 flex items-center justify-center",children:(0,t.jsx)("span",{className:"material-symbols-outlined text-3xl text-primary animate-spin",children:"progress_activity"})}),(0,t.jsx)("h3",{className:"text-lg font-semibold mb-2",children:d("autoDetecting")}),(0,t.jsx)("p",{className:"text-sm text-text-muted",children:d("readingFromCursor")})]}),!y&&(0,t.jsxs)(t.Fragment,{children:[j&&(0,t.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,t.jsxs)("div",{className:"flex gap-2",children:[(0,t.jsx)("span",{className:"material-symbols-outlined text-green-600 dark:text-green-400",children:"check_circle"}),(0,t.jsx)("p",{className:"text-sm text-green-800 dark:text-green-200",children:d("tokensAutoDetected")})]})}),!j&&!h&&(0,t.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,t.jsxs)("div",{className:"flex gap-2",children:[(0,t.jsx)("span",{className:"material-symbols-outlined text-blue-600 dark:text-blue-400",children:"info"}),(0,t.jsx)("p",{className:"text-sm text-blue-800 dark:text-blue-200",children:d("cursorNotDetected")})]})}),(0,t.jsxs)("div",{children:[(0,t.jsxs)("label",{className:"block text-sm font-medium mb-2",children:[d("accessToken")," ",(0,t.jsx)("span",{className:"text-red-500",children:d("required")})]}),(0,t.jsx)("textarea",{value:u,onChange:e=>m(e.target.value),placeholder:d("accessTokenPlaceholder"),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,t.jsxs)("div",{children:[(0,t.jsxs)("label",{className:"block text-sm font-medium mb-2",children:[d("machineId")," ",(0,t.jsx)("span",{className:"text-text-muted text-xs",children:d("optional")})]}),(0,t.jsx)(i.default,{value:x,onChange:e=>p(e.target.value),placeholder:d("machineIdPlaceholder"),className:"font-mono text-sm"})]}),h&&(0,t.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,t.jsx)("p",{className:"text-sm text-red-600 dark:text-red-400",children:h})}),(0,t.jsxs)("div",{className:"flex gap-2",children:[(0,t.jsx)(l.default,{onClick:N,fullWidth:!0,disabled:f||!u.trim(),children:f?d("importing"):d("importToken")}),(0,t.jsx)(l.default,{onClick:o,variant:"ghost",fullWidth:!0,children:d("cancel")})]})]})]})})}])},268226,e=>{"use strict";var t=e.i(843476),s=e.i(271645),r=e.i(703166),a=e.i(342923),l=e.i(80173);e.s(["default",0,function({isOpen:e,onSuccess:i,onClose:n,reauthConnection:o}){let[c,d]=(0,s.useState)(""),[u,m]=(0,s.useState)(""),[x,p]=(0,s.use
1State)(""),[h,b]=(0,s.useState)(""),[f,g]=(0,s.useState)("marscode-us"),[y,v]=(0,s.useState)("marscode"),[j,k]=(0,s.useState)("US-East"),[N,w]=(0,s.useState)(null),[S,C]=(0,s.useState)(!1),[T,E]=(0,s.useState)(!1),_=(0,s.useRef)(null),I=(0,s.useRef)(null);(0,s.useEffect)(()=>{if(!e)return;let t=e=>{let t=e.data;if(!t||"trae-oauth-callback"!==t.type)return;let s=window.location,r="127.0.0.1"===s.hostname?"localhost":"localhost"===s.hostname?"127.0.0.1":null,a=new Set([s.origin]);r&&a.add(`${s.protocol}//${r}${s.port?`:${s.port}`:""}`),!a.has(e.origin)||I.current&&t.loginTraceId===I.current&&(E(!1),t.success?(i?.(),n()):w(t.error||"Authorization failed"))};return window.addEventListener("message",t),()=>window.removeEventListener("message",t)},[e,i,n]);let A=async()=>{if(!c.trim())return void w("Access token is required.");C(!0),w(null);try{let e={accessToken:c.trim()};u.trim()&&(e.webId=u.trim()),x.trim()&&(e.bizUserId=x.trim()),h.trim()&&(e.userUniqueId=h.trim()),f.trim()&&(e.scope=f.trim()),y.trim()&&(e.tenant=y.trim()),j.trim()&&(e.region=j.trim());let t=await fetch("/api/oauth/trae/import",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),s=await t.json();if(!t.ok)throw Error("string"==typeof s.error?s.error:s.error?.message||"Import failed");i?.(),n()}catch(e){w(e instanceof Error?e.message:String(e))}finally{C(!1)}};return(0,t.jsx)(r.default,{isOpen:e,title:"Connect Trae SOLO",onClose:n,children:(0,t.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,t.jsxs)("div",{className:"bg-emerald-50 dark:bg-emerald-900/20 p-4 rounded-lg border border-emerald-200 dark:border-emerald-800",children:[(0,t.jsxs)("p",{className:"text-sm text-emerald-900 dark:text-emerald-200 mb-2",children:["Authorize via ",(0,t.jsx)("span",{className:"font-mono",children:"trae.ai"})," in a popup. The popup will close itself once the token has been imported."]}),(0,t.jsxs)("p",{className:"text-xs text-emerald-800 dark:text-emerald-300 mb-3",children:[(0,t.jsx)("strong",{children:"Important:"})," you must be logged in to"," ",(0,t.jsx)("span",{className:"font-mono",children:"trae.ai"})," in ",(0,t.jsx)("em",{children:"this"}),'browser first. The authorize page only confirms an existing session â it cannot sign you in. If you see "Login Failed", click "Open solo.trae.ai", sign in, then return here.']}),(0,t.jsxs)("div",{className:"flex gap-2",children:[(0,t.jsx)(a.default,{onClick:()=>{var e;let t,s,r,a,l;w(null),E(!0);let i=(t=globalThis.crypto||globalThis.crypto,t?.randomUUID?t.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)}));I.current=i;let n=window.location.port||("https:"===window.location.protocol?"443":"80"),o=(e=`http://127.0.0.1:${n}/authorize`,s=new Uint8Array(32),(globalThis.crypto||globalThis.crypto).getRandomValues(s),r=Array.from(s,e=>e.toString(16).padStart(2,"0")).join(""),l=new URLSearchParams({login_version:"1",auth_from:"solo",login_channel:"native_ide",plugin_version:"2.3.24254",auth_type:"local",client_id:"en1oxy7wnw8j9n",redirect:"0",login_trace_id:i,auth_callback_url:e,machine_id:r,device_id:a=function(){let e="";for(;e.length<19;)e+=Math.floor(1e10*Math.random()).toString();return e.slice(0,19)}(),x_device_id:a,x_machine_id:r,x_device_brand:"Mac14,7",x_device_type:"mac",x_os_version:"macOS 26.4.1",x_env:"",x_app_version:"0.1.7",x_app_type:"stable",hide_saas_login:"true"}),`https://www.trae.ai/authorization?${l.toString()}`),c=window.open(o,"trae-oauth","width=520,height=720");if(!c){E(!1),w("Popup blocked â allow popups for this site, or paste the token manually below.");return}_.current=c;let d=setInterval(()=>{c.closed&&(clearInterval(d),E(e=>(e&&w("Authorization window was closed before completing."),!1)))},700)},disabled:T,fullWidth:!0,children:T?"Waiting for trae.aiâ¦":"Authorize with Browser"}),(0,t.jsx)(a.default,{onClick:()=>window.open("https://solo.trae.ai/","_blank","noopener,noreferrer"),variant:"ghost",fullWidth:!0,children:"Open solo.trae.ai"})]})]}),(0,t.jsxs)("div",{className:"flex items-center gap-3 text-xs text-text-muted",children:[(0,t.jsx)("span",{className:"flex-1 border-t border-border"}),"or paste a token manually",(0,t.jsx)("span",{className:"flex-1 border-t border-border"})]}),(0,t.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,t.jsxs)("p",{className:"text-sm text-blue-800 dark:text-blue-200",children:["Sign in to ",(0,t.jsx)("span",{className:"font-mono",children:"solo.trae.ai"}),", open DevTools â Network, send any chat message, and copy the JWT from the"," ",(0,t.jsx)("span",{className:"font-mono",children:"Authorization: Cloud-IDE-JWT <token>"})," request header. JWT lifetime is ~14 days. Optional identity fields come from"," ",(0,t.jsx)("span",{className:"font-mono",children:"common_params"})," in the same request body."]})}),(0,t.jsxs)("div",{children:[(0,t.jsxs)("label",{className:"block text-sm font-medium mb-2",children:["Access Token (Cloud-IDE-JWT) ",(0,t.jsx)("span",{className:"text-red-500",children:"*"})]}),(0,t.jsx)("textarea",{value:c,onChange:e=>d(e.target.value),placeholder:"eyJhbGciOiJSUzI1NiIs...",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,t.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-3",children:[(0,t.jsxs)("div",{children:[(0,t.jsxs)("label",{className:"block text-sm font-medium mb-1",children:["Web ID ",(0,t.jsx)("span",{className:"text-text-muted text-xs",children:"optional"})]}),(0,t.jsx)(l.default,{value:u,onChange:e=>m(e.target.value),placeholder:"76428...",className:"font-mono text-sm"})]}),(0,t.jsxs)("div",{children:[(0,t.jsxs)("label",{className:"block text-sm font-medium mb-1",children:["Biz User ID ",(0,t.jsx)("span",{className:"text-text-muted text-xs",children:"optional"})]}),(0,t.jsx)(l.default,{value:x,onChange:e=>p(e.target.value),placeholder:"76428...",className:"font-mono text-sm"})]}),(0,t.jsxs)("div",{children:[(0,t.jsxs)("label",{className:"block text-sm font-medium mb-1",children:["User Unique ID ",(0,t.jsx)("span",{className:"text-text-muted text-xs",children:"optional"})]}),(0,t.jsx)(l.default,{value:h,onChange:e=>b(e.target.value),placeholder:"76428...",className:"font-mono text-sm"})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"block text-sm font-medium mb-1",children:"Scope"}),(0,t.jsx)(l.default,{value:f,onChange:e=>g(e.target.value),className:"text-sm"})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"block text-sm font-medium mb-1",children:"Tenant"}),(0,t.jsx)(l.default,{value:y,onChange:e=>v(e.target.value),className:"text-sm"})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"block text-sm font-medium mb-1",children:"Region"}),(0,t.jsx)(l.default,{value:j,onChange:e=>k(e.target.value),className:"text-sm"})]})]}),N&&(0,t.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,t.jsx)("p",{className:"text-sm text-red-600 dark:text-red-400",children:N})}),(0,t.jsxs)("div",{className:"flex gap-2",children:[(0,t.jsx)(a.default,{onClick:A,fullWidth:!0,disabled:S||!c.trim(),children:S?"Importingâ¦":"Import Token"}),(0,t.jsx)(a.default,{onClick:n,variant:"ghost",fullWidth:!0,children:"Cancel"})]})]})})}])},323060,e=>{"use strict";var t=e.i(843476),s=e.i(156132);e.s(["default",0,function({options:e=[],value:r,onChange:a,size:l="md",className:i,"aria-label":n}){let o={sm:"h-7 text-xs",md:"h-9 text-sm",lg:"h-11 text-base"};return(0,t.jsx)("div",{role:"tablist","aria-label":n,className:(0,s.cn)("inline-flex items-center p-1 rounded-lg","bg-black/5 dark:bg-white/5",i),children:e.map(e=>(0,t.jsxs)("button",{role:"tab","aria-selected":r===e.value,tabIndex:r===e.value?0:-1,onClick:()=>
1a(e.value),className:(0,s.cn)("px-4 rounded-md font-medium transition-all",o[l],r===e.value?"bg-white dark:bg-white/10 text-text-main shadow-sm":"text-text-muted hover:text-text-main",e.icon&&"flex items-center"),children:[e.icon&&(0,t.jsx)("span",{className:"material-symbols-outlined text-[16px] mr-1.5","aria-hidden":"true",children:e.icon}),e.label]},e.value))})}])},642440,e=>{"use strict";var t=e.i(843476),s=e.i(618566),r=e.i(522016),a=e.i(948148);let l={dashboard:"dashboard",providers:"providers",combos:"combos",settings:"settings",general:"general",appearance:"appearance",ai:"ai",routing:"routing",resilience:"resilience",advanced:"advanced","access-tokens":"accessTokens","feature-flags":"featureFlags",logs:"logs","audit-log":"auditLog",console:"console",logger:"logger",translator:"translator",playground:"playground",add:"add",edit:"edit",keys:"apiKeys",models:"models","cli-code":"cliCode","cli-agents":"cliAgents","acp-agents":"acpAgents",endpoint:"endpoint","api-manager":"apiManager",context:"context",compression:"compression",services:"services",analytics:"analytics",costs:"costs",health:"health",runtime:"runtime",webhooks:"webhooks",home:"home",activity:"activity","agent-skills":"agentSkills","combo-health":"comboHealth",evals:"evals",search:"search",utilization:"utilization","api-endpoints":"apiEndpoints",audit:"audit",a2a:"a2a",mcp:"mcp",batch:"batch",files:"files",media:"media",cache:"cache",changelog:"changelog",chaos:"chaos","cloud-agents":"cloudAgents",live:"live",studio:"studio",aggressive:"aggressive",caveman:"caveman",ccr:"ccr",headroom:"headroom",lite:"lite",llmlingua:"llmlingua",omniglyph:"omniglyph",rtk:"rtk","session-dedup":"sessionDedup",ultra:"ultra",budget:"budget",pricing:"pricing","quota-share":"quotaShare",discovery:"discovery","free-provider-rankings":"freeProviderRankings","free-tiers":"freeTiers",gamification:"gamification",leaderboard:"leaderboard",limits:"limits",profile:"profile",plugins:"plugins","provider-stats":"providerStats",new:"new",quota:"quota",relay:"relay","search-tools":"searchTools",security:"security",sidebar:"sidebar",tokens:"tokens",tools:"tools","agent-bridge":"agentBridge","traffic-inspector":"trafficInspector",usage:"usage"};e.s(["default",0,function(){let e=(0,s.usePathname)(),i=(0,a.useTranslations)("breadcrumbs");if(!e||"/dashboard"===e)return null;let n=e.split("/").filter(Boolean),o=n.map((e,t)=>{let s;return{label:(s=l[e])?i(s):e.charAt(0).toUpperCase()+e.slice(1),href:"/"+n.slice(0,t+1).join("/"),isLast:t===n.length-1}});return(0,t.jsx)("nav",{"aria-label":i("ariaLabel"),style:{display:"flex",alignItems:"center",gap:"6px",fontSize:"13px",color:"var(--text-secondary, #888)",padding:"8px 0",marginBottom:"8px"},children:o.map((e,s)=>(0,t.jsxs)("span",{style:{display:"flex",alignItems:"center",gap:"6px"},children:[s>0&&(0,t.jsx)("span",{style:{opacity:.4,fontSize:"11px"},"aria-hidden":"true",children:"âº"}),e.isLast?(0,t.jsx)("span",{"aria-current":"page",style:{color:"var(--text-primary, #e0e0e0)",fontWeight:500},children:e.label}):(0,t.jsx)(r.default,{href:e.href,style:{color:"var(--text-secondary, #888)",textDecoration:"none",transition:"color 0.15s"},onMouseEnter:e=>e.currentTarget.style.color="var(--accent, #818cf8)",onMouseLeave:e=>e.currentTarget.style.color="var(--text-secondary, #888)",children:e.label})]},e.href))})}])},629342,e=>{"use strict";var t=e.i(843476),s=e.i(948148);e.s(["default",0,function({icon:e="ð",title:r,description:a="",actionLabel:l="",onAction:i=null}){let n=(0,s.useTranslations)("common"),o=r??n("nothingHere"),c=/^[a-z][a-z0-9_]*$/.test(e);return(0,t.jsxs)("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:"48px 24px",textAlign:"center",minHeight:"200px"},children:[(0,t.jsx)("div",{style:{fontSize:"48px",marginBottom:"16px",opacity:.8,animation:"emptyBounce 2s ease-in-out infinite"},role:"img","aria-hidden":"true",children:c?(0,t.jsx)("span",{className:"material-symbols-outlined",style:{fontSize:"inherit"},children:e}):e}),(0,t.jsx)("h3",{style:{fontSize:"18px",fontWeight:600,color:"var(--text-primary, #e0e0e0)",marginBottom:"8px",margin:0},children:o}),a&&(0,t.jsx)("p",{style:{fontSize:"14px",color:"var(--text-secondary, #888)",maxWidth:"320px",lineHeight:1.5,marginTop:"8px"},children:a}),l&&i&&(0,t.jsx)("button",{onClick:i,style:{marginTop:"20px",padding:"10px 24px",borderRadius:"8px",border:"1px solid rgba(99, 102, 241, 0.4)",background:"rgba(99, 102, 241, 0.15)",color:"#818cf8",fontSize:"14px",fontWeight:500,cursor:"pointer",transition:"all 0.2s ease"},onMouseEnter:e=>{e.currentTarget.style.background="rgba(99, 102, 241, 0.25)",e.currentTarget.style.transform="translateY(-1px)"},onMouseLeave:e=>{e.currentTarget.style.background="rgba(99, 102, 241, 0.15)",e.currentTarget.style.transform="translateY(0)"},children:l}),(0,t.jsx)("style",{children:` 2 @keyframes emptyBounce { 3 0%, 100% { transform: translateY(0); } 4 50% { transform: translateY(-8px); } 5 } 6 `})]})}])},816062,e=>{"use strict";var t=e.i(843476),s=e.i(627949),r=e.i(271645),a=e.i(948148);let l={success:"â",error:"â",warning:"â ",info:"â¹"};function i(e){if("string"==typeof e)return e;if(null==e)return"";if("object"==typeof e){let t=e.message;if("string"==typeof t)return t;try{return JSON.stringify(e)}catch{}}return String(e)}let n="rgba(30, 30, 30, 0.95)",o={success:{bg:n,border:"rgba(16, 185, 129, 0.6)",icon:"#10b981"},error:{bg:n,border:"rgba(239, 68, 68, 0.6)",icon:"#ef4444"},warning:{bg:n,border:"rgba(245, 158, 11, 0.6)",icon:"#fbbf24"},info:{bg:n,border:"rgba(59, 130, 246, 0.6)",icon:"#3b82f6"}};function c({notification:e,onDismiss:s}){let n=(0,a.useTranslations)("common"),[d,u]=(0,r.useState)(!1),m=o[e.type]||o.info;return(0,t.jsxs)("div",{role:"alert","aria-live":"polite",onClick:e.onClick,style:{display:"flex",alignItems:"flex-start",ga
6p:"12px",padding:"14px 16px",borderRadius:"10px",backgroundColor:m.bg,border:`1px solid ${m.border}`,backdropFilter:"blur(12px)",boxShadow:"0 8px 32px rgba(0,0,0,0.2)",minWidth:"320px",maxWidth:"420px",cursor:e.onClick?"pointer":"default",animation:d?"toastOut 0.2s ease-in forwards":"toastIn 0.3s ease-out forwards",transition:"all 0.2s ease"},children:[(0,t.jsx)("span",{style:{fontSize:"18px",color:m.icon,fontWeight:"bold",lineHeight:1,marginTop:"2px"},children:l[e.type]}),(0,t.jsxs)("div",{style:{flex:1,minWidth:0},children:[e.title&&(0,t.jsx)("div",{style:{fontWeight:600,fontSize:"14px",color:"var(--text-primary, #fff)",marginBottom:"2px"},children:i(e.title)}),(0,t.jsx)("div",{style:{fontSize:"13px",color:"var(--text-secondary, #ccc)",lineHeight:1.4},children:i(e.message)})]}),e.dismissible&&(0,t.jsx)("button",{onClick:t=>{t.stopPropagation(),u(!0),setTimeout(()=>s(e.id),200)},"aria-label":n("dismissNotification"),style:{background:"none",border:"none",cursor:"pointer",color:"var(--text-secondary, #999)",fontSize:"16px",padding:"0 2px",lineHeight:1,opacity:.6,transition:"opacity 0.15s"},onMouseEnter:e=>e.currentTarget.style.opacity="1",onMouseLeave:e=>e.currentTarget.style.opacity="0.6",children:"Ã"})]})}e.s(["default",0,function(){let{notifications:e,removeNotification:r}=(0,s.useNotificationStore)();return 0===e.length?null:(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("style",{children:` 7 @keyframes toastIn { 8 from { opacity: 0; transform: translateX(100%) scale(0.95); } 9 to { opacity: 1; transform: translateX(0) scale(1); } 10 } 11 @keyframes toastOut { 12 from { opacity: 1; transform: translateX(0) scale(1); } 13 to { opacity: 0; transform: translateX(100%) scale(0.95); } 14 } 15 `}),(0,t.jsx)("div",{"aria-live":"polite","aria-atomic":"false",style:{position:"fixed",top:"20px",right:"20px",zIndex:9999,display:"flex",flexDirection:"column",gap:"10px",pointerEvents:"none"},children:e.map(e=>(0,t.jsx)("div",{style:{pointerEvents:"auto"},children:(0,t.jsx)(c,{notification:e,onDismiss:r})},e.id))})]})},"toToastText",0,i])},690777,e=>{"use strict";var t=e.i(843476),s=e.i(271645),r=e.i(948148);e.s(["default",0,function({searchValue:e="",onSearchChange:a,placeholder:l,filters:i=[],activeFilters:n={},onFilterChange:o,children:c}){let d=(0,r.useTranslations)("common"),[u,m]=(0,s.useState)(null),x=(0,s.useCallback)(()=>{a(""),i.forEach(e=>o(e.key,"")),m(null)},[a,i,o]),p=e||Object.values(n).some(e=>e&&""!==e);return(0,t.jsxs)("div",{style:{display:"flex",flexWrap:"wrap",gap:"8px",alignItems:"center",padding:"8px 0"},children:[(0,t.jsxs)("div",{style:{position:"relative",flex:"1 1 200px",minWidth:"200px"},children:[(0,t.jsx)("input",{type:"text",value:e,onChange:e=>a(e.target.value),placeholder:l||d("search"),style:{width:"100%",padding:"8px 12px 8px 32px",borderRadius:"6px",border:"1px solid rgba(255,255,255,0.1)",background:"rgba(255,255,255,0.05)",color:"var(--text-primary, #e0e0e0)",fontSize:"13px",outline:"none"}}),(0,t.jsx)("span",{style:{position:"absolute",left:"10px",top:"50%",transform:"translateY(-50%)",opacity:.4,fontSize:"14px",pointerEvents:"none"},children:"ð"})]}),i.map(e=>(0,t.jsxs)("div",{style:{position:"relative"},children:[(0,t.jsxs)("button",{onClick:()=>m(u===e.key?null:e.key),style:{padding:"6px 12px",borderRadius:"6px",border:`1px solid ${n[e.key]?"rgba(99,102,241,0.5)":"rgba(255,255,255,0.1)"}`,background:n[e.key]?"rgba(99,102,241,0.15)":"rgba(255,255,255,0.05)",color:n[e.key]?"#818cf8":"var(--text-secondary, #888)",fontSize:"12px",cursor:"pointer",whiteSpace:"nowrap"},children:[e.label,n[e.key]?` \xb7 ${n[e.key]}`:""]}),u===e.key&&(0,t.jsxs)("div",{style:{position:"absolute",top:"100%",left:0,marginTop:"4px",background:"rgba(20,20,30,0.95)",border:"1px solid rgba(255,255,255,0.1)",borderRadius:"8px",padding:"4px",zIndex:50,minWidth:"120px",backdropFilter:"blur(12px)"},children:[(0,t.jsx)("button",{onClick:()=>{o(e.key,""),m(null)},style:{display:"block",width:"100%",padding:"6px 12px",textAlign:"left",background:"none",border:"none",color:"#888",fontSize:"12px",cursor:"pointer",borderRadius:"4px"},children:d("all")}),(e.options||[]).map(s=>(0,t.jsx)("button",{onClick:()=>{o(e.key,s),m(null)},style:{display:"block",width:"100%",padding:"6px 12px",textAlign:"left",background:n[e.key]===s?"rgba(99,102,241,0.2)":"none",border:"none",color:n[e.key]===s?"#818cf8":"var(--text-primary, #e0e0e0)",fontSize:"12px",cursor:"pointer",borderRadius:"4px"},children:s},s))]})]},e.key)),p&&(0,t.jsx)("button",{onClick:x,style:{padding:"6px 12px",borderRadius:"6px",border:"1px solid rgba(239,68,68,0.3)",background:"rgba(239,68,68,0.1)",color:"#ef4444",fontSize:"12px",cursor:"pointer"},children:d("clear")}),c]})}])},563201,e=>{"use strict";var t=e.i(843476),s=e.i(271645),r=e.i(948148);
15e.s(["default",0,function({columns:e=[],visible:a={},onToggle:l}){let i=(0,r.useTranslations)("common"),[n,o]=(0,s.useState)(!1),c=(0,s.useRef)(null);return(0,s.useEffect)(()=>{if(!n)return;let e=e=>{c.current&&!c.current.contains(e.target)&&o(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[n]),(0,t.jsxs)("div",{ref:c,style:{position:"relative"},children:[(0,t.jsxs)("button",{onClick:()=>o(!n),title:i("toggleColumns"),style:{padding:"6px 10px",borderRadius:"6px",border:"1px solid rgba(255,255,255,0.1)",background:"rgba(255,255,255,0.05)",color:"var(--text-secondary, #888)",fontSize:"13px",cursor:"pointer",display:"flex",alignItems:"center",gap:"4px"},children:[(0,t.jsx)("span",{style:{fontSize:"14px"},children:"âï¸"}),i("columns")]}),n&&(0,t.jsx)("div",{style:{position:"absolute",top:"100%",right:0,marginTop:"4px",background:"rgba(20,20,30,0.95)",border:"1px solid rgba(255,255,255,0.1)",borderRadius:"8px",padding:"8px",zIndex:50,minWidth:"160px",backdropFilter:"blur(12px)"},children:e.map(e=>(0,t.jsxs)("label",{style:{display:"flex",alignItems:"center",gap:"8px",padding:"4px 8px",cursor:"pointer",fontSize:"12px",color:a[e.key]?"var(--text-primary, #e0e0e0)":"var(--text-secondary, #888)",borderRadius:"4px"},children:[(0,t.jsx)("input",{type:"checkbox",checked:a[e.key]??!0,onChange:()=>l(e.key),style:{accentColor:"#6366f1"}}),e.label]},e.key))})]})}])},115243,e=>{"use strict";var t=e.i(843476),s=e.i(948148);e.s(["default",0,function({columns:e=[],data:r=[],renderCell:a,renderHeader:l,onRowClick:i,selectedId:n,loading:o=!1,maxHeight:c="calc(100vh - 320px)",emptyIcon:d="ð",emptyMessage:u}){let m=(0,s.useTranslations)("common"),x=u??m("noData");return o?(0,t.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"48px 24px",color:"var(--color-text-muted)",fontSize:"14px"},children:[(0,t.jsx)("span",{style:{animation:"spin 1s linear infinite",marginRight:"8px"},children:"â³"}),m("loading"),(0,t.jsx)("style",{children:"@keyframes spin { to { transform: rotate(360deg); } }"})]}):0===r.length?(0,t.jsxs)("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:"48px 24px",color:"var(--color-text-muted)",fontSize:"14px"},children:[(0,t.jsx)("span",{style:{fontSize:"32px",marginBottom:"8px",opacity:.6},children:d}),x]}):(0,t.jsx)("div",{style:{overflow:"auto",maxHeight:c,borderRadius:"8px",background:"var(--color-surface)"},children:(0,t.jsxs)("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:"12px",tableLayout:"auto"},children:[(0,t.jsx)("thead",{children:(0,t.jsx)("tr",{children:e.map(e=>(0,t.jsx)("th",{style:{padding:"8px 10px",textAlign:"left",fontWeight:600,color:"var(--color-text-muted)",borderBottom:"1px solid var(--color-border)",position:"sticky",top:0,background:"var(--table-header-bg)",zIndex:1,whiteSpace:"nowrap",fontSize:"11px",textTransform:"uppercase",letterSpacing:"0.5px"},children:l?l(e):e.label},e.key))})}),(0,t.jsx)("tbody",{children:r.map((s,r)=>(0,t.jsx)("tr",{onClick:()=>i?.(s),style:{cursor:i?"pointer":"default",background:s.id===n?"var(--table-row-selected)":r%2==0?"transparent":"var(--table-row-zebra)",transition:"background 0.15s"},onMouseEnter:e=>{s.id!==n&&(e.currentTarget.style.background="var(--table-row-hover)")},onMouseLeave:e=>{s.id!==n&&(e.currentTarget.style.background=r%2==0?"transparent":"var(--table-row-zebra)")},children:e.map(e=>(0,t.jsx)("td",{style:{padding:"6px 10px",borderBottom:"1px solid var(--table-cell-border)",whiteSpace:"nowrap",maxWidth:e.maxWidth||"200px",overflow:"hidden",textOverflow:"ellipsis"},children:a(s,e)},e.key))},s.id||r))})]})})}])},109290,e=>{"use strict";var t=e.i(843476),s=e.i(156132),r=e.i(635055);e.s(["default",0,function({enabled:e,saving:a=!1,onEnabledChange:l,className:i}){return l?(0,t.jsxs)("div",{className:(0,s.cn)("inline-flex items-center gap-2 rounded-md px-1 py-1",i),children:[(0,t.jsx)("span",{className:"text-sm font-medium text-text-main",children:a?"Saving":e?"Enabled":"Disabled"}),(0,t.jsx)(r.default,{size:"lg",checked:e,disabled:a,onChange:l,ariaLabel:"Toggle no-auth provider",title:e?"Disable provider":"Enable provider"})]}):null}])},915139,e=>{"use strict";var t=e.i(843476),s=e.i(948148),r=e.i(393718),a=e.i(109290);e.s(["default",0,function({enabled:e=!0,saving:l=!1,onEnabledChange:i,providerProxyControl:n}){let o=(0,s.useTranslations)("noAuthProvider");return(0,t.jsx)(r.default,{children:(0,t.jsxs)("div",{className:"flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between",children:[(0,t.jsxs)("div",{className:"flex min-w-0 items-center gap-3",children:[(0,t.jsx)("div",{className:"inline-flex shrink-0 items-center justify-center w-10 h-10 rounded-full bg-green-500/10 text-green-500",children:(0,t.jsx)("span",{className:"material-symbols-outlined text-[20px]",children:"lock_o
15pen"})}),(0,t.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,t.jsx)("p",{className:"text-sm font-medium",children:o("title")}),(0,t.jsx)("p",{className:"text-xs text-text-muted",children:o("description")})]})]}),(0,t.jsxs)("div",{className:"flex w-full flex-wrap items-center justify-end gap-2 sm:w-auto sm:flex-nowrap",children:[n,(0,t.jsx)(a.default,{className:"w-full justify-end sm:w-auto",enabled:e,saving:l,onEnabledChange:i})]})]})})}])},247854,e=>{"use strict";var t=e.i(843476),s=e.i(271645);e.s(["default",0,function({onDistribute:e,disabled:r=!1,label:a="Distribute Proxies",size:l="md"}){let[i,n]=(0,s.useState)("idle"),o=(0,s.useRef)(null);(0,s.useEffect)(()=>()=>{o.current&&clearTimeout(o.current)},[]);let c=(0,s.useCallback)(async()=>{if(!r&&"distributing"!==i){n("distributing");try{await e(),n("complete"),o.current=setTimeout(()=>n("idle"),1500)}catch{n("idle")}}},[e,r,i]),d=r||"distributing"===i,u="distributing"===i?"bg-primary/20 border-primary/40 text-primary animate-pulse":"complete"===i?"bg-green-500/15 border-green-500/40 text-green-500":"bg-bg-subtle border-border text-text-muted hover:text-text-primary hover:border-primary/40",m="distributing"===i?"sync":"complete"===i?"check":"swap_horiz",x="distributing"===i?"Distributing...":"complete"===i?"Complete":a;return(0,t.jsxs)("button",{onClick:c,disabled:d,className:`flex items-center gap-1.5 rounded-lg font-medium border transition-colors ${"sm"===l?"px-2 py-1 text-[11px]":"px-3 py-1.5 text-xs"} ${u}`,title:x,"aria-label":x,children:[(0,t.jsx)("span",{className:`material-symbols-outlined text-[14px] ${"distributing"===i?"animate-spin":""}`,children:m}),x]})}])},524578,e=>{"use strict";var t=e.i(843476),s=e.i(271645),r=e.i(948148),a=e.i(393718),l=e.i(342923),i=e.i(247854),n=e.i(109290);let o=[{value:"http",label:"HTTP"},{value:"https",label:"HTTPS"},{value:"socks5",label:"SOCKS5"}];function c(e,t){return e.find(e=>e.fingerprint===t)??null}e.s(["default",0,function({providerId:e,providerName:d,generateAccountId:u,generateApiKey:m,dataKey:x="fingerprints",description:p,addLabel:h,enabled:b=!0,savingEnabled:f=!1,onEnabledChange:g,providerProxyControl:y}){let v=(0,r.useTranslations)("noAuthProvider"),j=p||v("accountDescription"),k=h||v("addAccount"),[N,w]=(0,s.useState)([]),[S,C]=(0,s.useState)(!0),[T,E]=(0,s.useState)(!1),[_,I]=(0,s.use
15State)(null),[A,D]=(0,s.useState)("saved"),[K,L]=(0,s.useState)([]),[M,O]=(0,s.useState)(""),[R,F]=(0,s.useState)("socks5"),[P,$]=(0,s.useState)(""),[z,B]=(0,s.useState)("1080"),[U,q]=(0,s.useState)(""),[W,H]=(0,s.useState)(""),[G,J]=(0,s.useState)(!1),Y=(0,s.useRef)(null),V=(0,s.useCallback)(async()=>{try{let t=await fetch("/api/providers");if(t.ok){let s=((await t.json()).connections||[]).filter(t=>t.provider===e);w(s)}}catch(e){console.error("Failed to fetch connections:",e)}finally{C(!1)}},[e]),X=(0,s.useCallback)(async()=>{try{let e=await fetch("/api/settings/proxies");if(e.ok){let t=await e.json();L(Array.isArray(t?.items)?t.items:[])}}catch(e){console.error("Failed to fetch saved proxies:",e)}},[]);(0,s.useEffect)(()=>{let e=window.setTimeout(()=>{V(),X()},0);return()=>window.clearTimeout(e)},[V,X]),(0,s.useEffect)(()=>{let e=e=>{Y.current&&!Y.current.contains(e.target)&&I(null)};if(_)return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[_]);let Q=N.flatMap(e=>e.providerSpecificData?.[x]||[]),Z=N[0],ee=Z?.providerSpecificData?.accountProxies||[],et=async()=>{E(!0);try{let t=u(),s=m?await m():void 0;if(0===N.length){let r=await fetch("/api/providers",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:e,name:v("accountName",{provider:d,number:1}),...s?{apiKey:s}:{},providerSpecificData:{[x]:[t]}})});if(!r.ok){let e=await r.json().catch(()=>({}));throw Error(e?.error||v("createConnectionFailed"))}}else{let e=[...Q,t];if(!(await fetch(`/api/providers/${Z.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerSpecificData:{[x]:e}})})).ok)throw Error(v("updateConnectionFailed"))}await V()}catch(e){console.error("Failed to add account:",e)}finally{E(!1)}},es=async e=>{if(!Z)return;let t=Q.filter(t=>t!==e),s=ee.filter(t=>t.fingerprint!==e);try{(await fetch(`/api/providers/${Z.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerSpecificData:{[x]:t,accountProxies:s}})})).ok&&await V()}catch(e){console.error("Failed to remove account:",e)}},er=async()=>{if(Z&&_){J(!0);try{let e=ee.filter(e=>e.fingerprint!==_),t=null;if("saved"===A)t=M?{fingerprint:_,proxyId:M}:null;else{let e=P.trim();t=e?{fingerprint:_,proxy:{type:R,host:e,port:Number(z)||1080,...U.trim()?{username:U.trim()}:{},...W.trim()?{password:W.trim()}:{}}}:null}let s=t?[...e,t]:e;(await fetch(`/api/providers/${Z.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerSpecificData:{accountProxies:s}})})).ok&&(await V(),I(null))}catch(e){console.error("Failed to save proxy:",e)}finally{J(!1)}}},ea=async()=>{if(!Z||0===Q.length)return;let e=await fetch("/api/settings/proxies");if(!e.ok)throw Error(v("fetchProxiesFailed"));let t=await e.json(),s=(t?.items||[]).filter(e=>"active"===e.status);if(0===s.length)throw Error(v("noSavedProxiesError"));let r=Q.map((e,t)=>({fingerprint:e,proxyId:s[t%s.length].id}));if(!(await fetch(`/api/providers/${Z.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerSpecificData:{accountProxies:r}})})).ok)throw Error(v("updateConnectionFailed"));await V()};return(0,t.jsxs)(a.default,{children:[(0,t.jsxs)("div",{className:"mb-3 flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[(0,t.jsxs)("div",{className:"flex min-w-0 items-center gap-3",children:[(0,t.jsx)("div",{className:"inline-flex shrink-0 items-center justify-center w-10 h-10 rounded-full bg-green-500/10 text-green-500",children:(0,t.jsx)("span",{className:"material-symbols-outlined text-[20px]",children:"lock_open"})}),(0,t.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,t.jsx)("p",{className:"text-sm font-medium",children:v("title")}),(0,t.jsx)("p",{className:"text-xs text-text-muted",children:j})]})]}),(0,t.jsxs)("div",{className:"flex w-full flex-wrap items-center justify-end gap-2 sm:w-auto sm:flex-nowrap",children:[y,(0,t.jsx)(n.default,{className:"w-full justify-end sm:w-auto",enabled:b,saving:f,onEnabledChange:g})]})]}),(0,t.jsxs)("div",{className:"border-t border-border pt-3 mt-3",children:[(0,t.jsxs)("div",{className:"mb-2 flex items-center justify-between",children:[(0,t.jsx)("span",{className:"text-sm font-medium",children:v("accounts",{count:S?"...":Q.length})}),(0,t.jsxs)("div",{className:"flex items-center justify-end gap-2",children:[!S&&Q.length>0&&(0,t.jsx)(i.default,{onDistribute:ea,disabled:T||!b,size:"sm"}),(0,t.jsx)(l.default,{size:"sm",icon:"add",onClick:et,disabled:T||!b,children:T?v("adding"):k})]})]}),!S&&0===Q.length&&(0,t.jsx)("p",{className:"text-xs text-text-muted py-2",children:v("autoGeneratedAccount",{addLabel:k})}),!S&&Q.length>0&&(0,t.jsx)("div",{"data-testid":"noauth-account-grid",className:"grid max-h-72 grid-cols-1 gap-1.5 overflow-y-auto pr-1 sm:grid-cols-2 lg:grid-cols-3",children:Q.map((e,s)=>{let r=function(e,t){if(!e)return null;if(e.proxyId){let s=t.find(t=>
15t.id===e.proxyId);return s&&s.host?{type:s.type||"socks5",host:s.host,port:Number(s.port)||0}:null}return e.proxy??null}(c(ee,e),K);return(0,t.jsxs)("div",{"data-account-id":e,className:"group flex items-center gap-2 rounded-lg border border-border bg-bg/40 px-2.5 py-2 transition-colors hover:bg-black/[0.03] dark:hover:bg-white/[0.03]",children:[(0,t.jsx)("span",{className:"inline-flex h-5 w-5 shrink-0 items-center justify-center rounded-full bg-bg text-[10px] font-medium text-text-muted",children:s+1}),(0,t.jsxs)("span",{className:"min-w-0 flex-1 truncate font-mono text-xs text-text-muted",children:[e.slice(0,10),"â¦"]}),(0,t.jsx)("button",{type:"button",onClick:()=>{let t;return t=c(ee,e),void(F("socks5"),$(""),B("1080"),q(""),H(""),O(""),t?.proxyId?(D("saved"),O(t.proxyId)):t?.proxy?.host?(D("custom"),F(t.proxy.type),$(t.proxy.host),B(String(t.proxy.port)),q(t.proxy.username||""),H(t.proxy.password||"")):D(K.length>0?"saved":"custom"),I(e))},className:`inline-flex h-6 w-6 shrink-0 items-center justify-center rounded transition-colors hover:bg-black/5 dark:hover:bg-white/5 ${r?"text-blue-400":"text-text-muted"}`,title:r?`Proxy: ${r.type}://${r.host}:${r.port}`:v("configureProxy"),"aria-label":r?v("proxyConfigured",{host:r.host}):v("configureProxy"),children:(0,t.jsx)("span",{className:"material-symbols-outlined text-[16px]",style:r?{fontVariationSettings:"'FILL' 1"}:void 0,children:"shield"})}),(0,t.jsx)("button",{type:"button",onClick:()=>es(e),className:"shrink-0 rounded p-1 text-text-muted opacity-0 transition-colors hover:bg-red-500/10 hover:text-red-500 group-hover:opacity-100","aria-label":v("removeAccount"),children:(0,t.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"delete"})})]},e)})}),_&&(0,t.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/40 p-4",children:(0,t.jsxs)("div",{ref:Y,className:"w-80 max-w-full rounded-lg border border-black/10 bg-surface p-4 shadow-lg dark:border-white/10",children:[(0,t.jsx)("p",{className:"mb-3 text-sm font-medium",children:v("proxyForAccount",{number:Q.indexOf(_)+1})}),(0,t.jsxs)("div",{className:"space-y-3",children:[(0,t.jsxs)("div",{className:"flex gap-1 rounded-lg border border-border bg-bg-subtle p-1",children:[(0,t.jsx)("button",{type:"button",onClick:()=>D("saved"),className:`flex-1 rounded-md px-3 py-1.5 text-xs font-medium transition-colors ${"saved"===A?"bg-primary text-white":"text-text-muted hover:text-text-main"}`,children:v("saved")}),(0,t.jsx)("button",{type:"button",onClick:()=>D("custom"),className:`flex-1 rounded-md px-3 py-1.5 text-xs font-medium transition-colors ${"custom"===A?"bg-primary text-white":"text-text-muted hover:text-text-main"}`,children:v("custom")})]}),"saved"===A?(0,t.jsxs)("select",{value:M,onChange:e=>O(e.target.value),className:"w-full rounded-md border border-black/10 bg-bg px-2.5 py-1.5 text-xs dark:border-white/10",children:[(0,t.jsx)("option",{value:"",children:0===K.length?v("noSavedProxies"):v("directConnection")}),K.map(e=>(0,t.jsxs)("option",{value:e.id,children:[(e.name||e.host)??e.id," (",e.type||"socks5","://",e.host,":",e.port,")"]},e.id))]}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:"flex gap-2",children:[(0,t.jsx)("select",{value:R,onChange:e=>F(e.target.value),className:"flex-shrink-0 rounded-md border border-black/10 bg-bg px-2.5 py-1.5 text-xs dark:border-white/10",children:o.map(e=>(0,t.jsx)("option",{value:e.value,children:e.label},e.value))}),(0,t.jsx)("input",{type:"text",value:P,onChange:e=>$(e.target.value),placeholder:v("host"),className:"flex-1 rounded-md border border-black/10 bg-bg px-2.5 py-1.5 text-xs dark:border-white/10"}),(0,t.jsx)("input",{type:"text",value:z,onChange:e=>B(e.target.value),placeholder:v("port"),className:"w-16 rounded-md border border-black/10 bg-bg px-2.5 py-1.5 text-xs dark:border-white/10"})]}),(0,t.jsx)("input",{type:"text",value:U,onChange:e=>q(e.target.value),placeholder:v("usernameOptional"),className:"w-full rounded-md border border-black/10 bg-bg px-2.5 py-1.5 text-xs dark:border-white/10"}),(0,t.jsx)("input",{type:"password",value:W,onChange:e=>H(e.target.value),placeholder:v("passwordOptional"),className:"w-full rounded-md border border-black/10 bg-bg px-2.5 py-1.5 text-xs dar
15k:border-white/10"})]}),(0,t.jsxs)("div",{className:"flex justify-end gap-2 pt-1",children:[(0,t.jsx)("button",{onClick:()=>I(null),className:"rounded-md px-3 py-1.5 text-xs text-text-muted transition-colors hover:bg-black/5 hover:text-text-main dark:hover:bg-white/5",children:v("cancel")}),(0,t.jsx)("button",{onClick:er,disabled:G,className:"rounded-md bg-primary/10 px-3 py-1.5 text-xs text-primary transition-colors hover:bg-primary/20 disabled:opacity-50",children:G?v("saving"):v("save")})]})]})]})})]})]})}])},515272,e=>{"use strict";var t=e.i(843476),s=e.i(271645),r=e.i(156132);e.s(["default",0,function({title:e,description:a,count:l,defaultOpen:i=!0,children:n,className:o}){let[c,d]=(0,s.useState)(i);return(0,t.jsxs)("div",{className:(0,r.cn)("border border-black/5 dark:border-white/5 rounded-lg",o),children:[(0,t.jsxs)("button",{type:"button",onClick:()=>d(e=>!e),className:(0,r.cn)("flex items-center justify-between w-full px-4 py-3 text-left","hover:bg-black/[0.02] dark:hover:bg-white/[0.02] transition-colors","rounded-t-lg",!c&&"rounded-b-lg"),"aria-expanded":c,children:[(0,t.jsxs)("div",{className:"flex items-center gap-3 min-w-0",children:[(0,t.jsx)("span",{className:"text-sm font-semibold text-text-main truncate",children:e}),null!=l&&(0,t.jsx)("span",{className:"px-2 py-0.5 text-[10px] font-semibold rounded-full bg-black/5 dark:bg-white/10 text-text-muted",children:l}),a&&(0,t.jsx)("span",{className:"text-xs text-text-muted truncate hidden sm:inline",children:a})]}),(0,t.jsx)("span",{className:"material-symbols-outlined text-[20px] text-text-muted transition-transform duration-200 shrink-0",style:{transform:c?"rotate(0deg)":"rotate(-90deg)"},children:"expand_more"})]}),(0,t.jsx)("div",{className:(0,r.cn)("overflow-hidden transition-[max-height] duration-200 ease-in-out",c?"max-h-[2000px]":"max-h-0"),children:(0,t.jsx)("div",{className:"px-4 pb-4 pt-1",children:n})})]})}])},840387,e=>{"use strict";var t=e.i(843476),s=e.i(156132);e.s(["default",0,function({text:e,className:r}){return(0,t.jsxs)("span",{className:(0,s.cn)("relative inline-flex group",r),children:[(0,t.jsx)("span",{className:"material-symbols-outlined text-[16px] text-text-muted cursor-help","aria-label":e,children:"info"}),(0,t.jsx)("span",{role:"tooltip",className:(0,s.cn)("absolute bottom-full left-1/2 -translate-x-1/2 mb-2","px-2.5 py-1.5 text-xs font-medium text-white bg-gray-900/95 rounded-md shadow-lg","whitespace-nowrap pointer-events-none","border border-white/10","opacity-0 group-hover:opacity-100 transition-opacity duration-150","z-50"),children:e})]})}])},110626,e=>{"use strict";var t=e.i(843476),s=e.i(156132);e.s(["default",0,function({value:e,onChange:r,presets:a,min:l=0,max:i=100,step:n=1,className:o}){return(0,t.jsxs)("div",{className:(0,s.cn)("flex flex-col gap-3",o),children:[(0,t.jsx)("div",{className:"flex flex-wrap gap-2",children:a.map(a=>(0,t.jsx)("button",{type:"button",onClick:()=>r(a.value),className:(0,s.cn)("px-3 py-1.5 text-xs font-medium rounded-full transition-colors","border",e===a.value?"bg-primary text-white border-primary":"bg-transparent text-text-muted border-black/10 dark:border-white/10 hover:border-primary/30 hover:text-text-main"),children:a.label},a.value))}),(0,t.jsx)("input",{type:"range",min:l,max:i,step:n,value:e,onChange:e=>r(Number(e.target.value)),className:(0,s.cn)("w-full h-1.5 rounded-full appearance-none cursor-pointer","bg-black/10 dark:bg-white/10","accent-primary")}),(0,t.jsxs)("div",{className:"flex justify-between text-[10px] text-text-muted",children:[(0,t.jsx)("span",{children:l}),(0,t.jsx)("span",{className:"font-medium text-text-main",children:e}),(0,t.jsx)("span",{children:i})]})]})}])},165149,e=>{"use strict";var t=e.i(247167),s=e.i(843476),r=e.i(271645),a=e.i(647829),l=e.i(6998),i=e.i(816062),n=e.i(642440),o=e.i(948148);function c(){let[e,t]=(0,r.useState)(!1),[a,l]=(0,r.useState)(""),i=(0,r.useRef)(0),n=(0,r.useRef)(!1),c=(0,o.useTranslations)("common");return((0,r.useEffect)(()=>{let e=async()=>{let e=new AbortController,s=setTimeout(()=>e.abort("Health check timeout"),8e3);try{(await fetch("/api/health/ping",{signal:e.signal,cache:"no-store"})).ok?(i.current=0,n.current=!1,t(!1),l("")):(i.current+=1,i.current>=2&&!n.current&&(t(!0),l(c("maintenanceServerIssues"))))}catch{i.current+=1,i.current>=2&&!n.current&&(t(!0),l(c("maintenanceServerUnreachable")))}finally{clearTimeout(s)}};e();let s=setInterval(e,1e4);return()=>clearInterval(s)},[c]),e)?(0,s.jsxs)("div",{className:"bg-amber-500/10 border-b border-amber-500/20 px-4 py-2.5 flex items-center justify-between gap-3 animate-in slide-in-from-top",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2.5",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-amber-500 text-[18px] animate-pulse",children:"warning"}),(0,s.jsx)("span",{className:"text-sm text-amber-200",children:a})]}),(0,s.jsx)("button",{onClick:()=>{n.current=!0,t(!1)},className:"p-1 rounded hover:bg-white/5 text-text-muted hover:text-text-main transition-colors","aria-label":c("close"),children:(0,s.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"close"})})]}):null}var d=e.i(618566),u=e.i(241937),m=e.i(513859);function x({isOpen:e,onClose:t}){return e?(0,s.jsx)(p,{onClose:t}):null}function p({onClose:e}){let t=(0,d.useRouter)(),a=(0,o.useTranslations)("sidebar"),l=(0,r.useRef)(null),i=(0,r.useRef)(null),[n,c]=(0,r.useState)(""),[x,h]=(0,r.useState)(0),[b,f]=(0,r.useState)(new Set);(0,r.useEffect)(()=>{let e=new AbortController;return fetch("/api/settings",{signal:e.signal}).then(e=>e.json()).then(e=>{f(new Set((0,u.normalizeHiddenSidebarItems)(e?.[u.HIDDEN_SIDEBAR_ITEMS_SETTING_KEY])))}).catch(()=>{}),()=>e.abort()},[]),(0,r.useEffect)(()=>{let e=setTimeout(()=>l.current?.focus(),30);return()=>clearTimeout(e)},[]);let g=(0,r.useCallback)((e,t)=>{try{return a(e)}catch{return t}},[a]),y=(0,r.useMemo)(()=>m.SIDEBAR_SECTIONS.flatMap(e=>{let t=g(e.titleKey,e.titleFallback);return e.children.flatMap(s=>{if("type"in s&&"group"===s.type){let r=g(s.titleKey,s.titleFallback);return s.items.filter(e=>!b.has(e.id)).map(a=>({id:a.id,href:a.href,icon:a.icon,label:g(a.i18nKey,a.id),subtitle:a.subtitleKey?g(a.subtitleKey,""):void 0,external:a.external??!1,sectionId:e.id,sectionLabel:t,subgroupId:s.id,subgroupLabel:r}))}return b.has(s.id)?[]:[{id:s.id,href:s.href,icon:s.icon,label:g(s.i18nKey,s.id),subtitle:s.subtitleKey?g(s.subtitleKey,""):void 0,external:s.external??!1,sectionId:e.id,sectionLabel:t}]})}),[b,g]),v=(0,r.useMemo)(()=>{let e=n.trim().toLowerCase();return e?y.filter(t=>t.label.toLowerCase().includes(e)||t.subtitle?.toLowerCase().includes(e)||t.sectionLabel.toLowerCase().includes(e)||t.subgroupLabel?.toLowerCase().includes(e)):y},[y,n]),j=(0,r.useMemo)(()=>{let e=[],t=new Map;return v.forEach((s,r)=>{let a=t.get(s.sectionId);a||(a={sectionId:s.sectionId,sectionLabel:s.sectionLabel,subgroups:[]},t.set(s.sectionId,a),e.push(a));let l=s.subgroupId??null,i=a.subgroups.find(e=>e.subgroupId===l);i||(i={subgroupId:l,subgroupLabel:s.subgroupLabel??null,items:[]},a.subgroups.push(i)),i.items.push({item:s,flatIndex:r})}),e},[v]),k=(0,r.useCallback)((s,r)=>{e(),r?window.open(s,"_blank","noopener,noreferrer"):t.push(s)},[e,t]);return(0,r.useEffect)(()=>{let t=t=>{if("Escape"===t.key)return void e();if("ArrowDown"===t.key)t.preventDefault(),h(e=>(e+1)%Math.max(1,v.length));else if("ArrowUp"===t.key)t.preventDefault(),h(e=>(e-1+Math.max(1,v.length))%Math.max(1,v.length));else if("Enter"===t.key){t.preventDefault();let e=v[x];e&&k(e.href,e.external)}};return document.addEventListener("keydown",t),()=>document.removeEventListener("keydown",t)},[v,x,e,k]),(0,r.useEffect)(()=>{let e=i.current;if(!e)return;let t=e.querySelector(`[data-flat-index="${x}"]`);t?.scrollIntoView({block:"nearest"})},[x]),(0,s.jsxs)("div",{className:"fixed inset-0 z-[60] flex items-start justify-center pt-[10vh] px-4",children:[(0,s.jsx)("div",{className:"absolute inset-0 bg-black/40 backdrop-blur-sm",onClick:e,"aria-hidden":"true"}),(0,s.jsxs)("div",{className:"relative w-full max-w-3xl bg-surface border border-black/10 dark:border-white/10 rounded-xl shadow-2xl overflow-hidden animate-in fade-in zoom-in-95 duration-200",role:"dialog","aria-modal":"true","aria-label":"Command palette",children:[(0,s.jsxs)("div",{className:"flex items-center gap-3 px-6 py-4 border-b border-black/5 dark:border-white/5",children:[(0,s.jsx)("span",{className:"material-symbols-outlined text-[20px] text-text-muted shrink-0",children:"search"}),(0,s.jsx)("input",{ref:l,type:"text",className:"flex-1 bg-transparent text-text placeholder:text-text-muted outline-none text-base",placeholder:"Search pages, settings, tools...",value:n,onChange:e=>{c(e.target.value),h(0)},autoComplete:"off",spellCheck:!1}),n&&(0,s.jsx)("button",{className:"text-text-muted hover:text-text transition-colors",onClick:()=>{c(""),h(0)},tabIndex:-1,"aria-label":"Clear search",children:(0,s.jsx)("span",{className:"material-symbols-outlined text-[16px]",children:"close"})}),(0,s.jsx)("kbd",{className:"hidden sm:inline-flex items-center gap-0.5 px-1.5 py-0.5 rounded text-[10px] font-mono bg-black/5 dark:bg-white/5 text-text-muted border border-black/10 dark:border-white/10 shrink-0",children:"Esc"})]}),j.length>0?(0,s.jsx)("ul",{ref:i,className:"py-2 max-h-[60vh] overflow-y-auto custom-scrollbar",role:"listbox",children:j.map(e=>(0,s.jsxs)("li",{role:"presentation",children:[(0,s.jsx)("div",{className:"sticky top-0 z-10 bg-surface/95 backdrop-blur-sm px-6 py-1.5 text-[10px] font-semibold uppercase tracking-wider text-text-muted border-b border-black/5 dark:border-white/5",children:e.sectionLabel}),(0,s.jsx)("ul",{role:"group","aria-label":e.sectionLabel,children:e.subgroups.map(t=>(0,s.jsxs)("li",{role:"presentation",children:[t.subgroupLabel&&(0,s.jsx)("div",{className:"px-6 pt-2 pb-1 text-[10px] font-medium uppercase tracking-wide text-text-muted/70",children:t.subgroupLabel}),(0,s.jsx)("ul",{role:t.subgroupLabel?"group":"presentation","aria-label":t.subgroupLabel??void 0,children:t.items.map(({item:e,flatIndex:r})=>(0,s.jsx)("li",{role:"option","aria-selected":r===x,"data-flat-index":r,children:(0,s.jsxs)("button",{className:`w-full flex items-center gap-3 ${t.subgroupLabel?"pl-10 pr-6":"px-6"} py-2.5 text-left transition-colors ${r===x?"bg-accent/10 text-accent ring-1 ring-inset ring-accent/20":"text-text hover:bg-black/5 dark:hover:bg-white/5"}`,onClick:()=>k(e.href,e.external),onMouseEnter:()=>h(r),children:[(0,s.jsx)("span",{className:`material-symbols-outlined text-[18px] shrink-0 ${r===x?"text-accent":"text-text-muted"}`,children:e.icon}),(0,s.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,s.jsx)("p",{className:"text-sm font-medium truncate",children:e.label}
15),e.subtitle&&(0,s.jsx)("p",{className:`text-xs truncate ${r===x?"text-accent/70":"text-text-muted"}`,children:e.subtitle})]}),e.external&&(0,s.jsx)("span",{className:"material-symbols-outlined text-[14px] text-text-muted shrink-0",children:"open_in_new"})]})},e.id))})]},`${e.sectionId}::${t.subgroupId??"_root"}`))})]},e.sectionId))}):(0,s.jsx)("div",{className:"py-10 text-center text-text-muted text-sm",children:"No results"}),(0,s.jsxs)("div",{className:"flex items-center gap-4 px-4 py-2 border-t border-black/5 dark:border-white/5 text-[11px] text-text-muted",children:[(0,s.jsxs)("span",{className:"flex items-center gap-1",children:[(0,s.jsx)("kbd",{className:"px-1 py-0.5 rounded bg-black/5 dark:bg-white/5 border border-black/10 dark:border-white/10 font-mono",children:"ââ"}),"navigate"]}),(0,s.jsxs)("span",{className:"flex items-center gap-1",children:[(0,s.jsx)("kbd",{className:"px-1 py-0.5 rounded bg-black/5 dark:bg-white/5 border border-black/10 dark:border-white/10 font-mono",children:"âµ"}),"open"]}),(0,s.jsxs)("span",{className:"flex items-center gap-1",children:[(0,s.jsx)("kbd",{className:"px-1 py-0.5 rounded bg-black/5 dark:bg-white/5 border border-black/10 dark:border-white/10 font-mono",children:"Esc"}),"close"]})]})]})]})}function h(){let e=(0,d.usePathname)(),t=(0,d.useSearchParams)(),[a,l]=(0,r.useState)(!1),[i,n]=(0,r.useState)(0),o=(0,r.useRef)(`${e}?${t?.toString()??""}`),c=(0,r.useRef)(null),u=(0,r.useRef)(null),m=(0,r.useRef)(null);return((0,r.useEffect)(()=>{let e=e=>{if(e.defaultPrevented||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey||0!==e.button)return;let t=e.target?.closest?.("a");if(!t||t.target&&""!==t.target&&"_self"!==t.target||t.hasAttribute("download"))return;let s=t.getAttribute("href");if(!(!s||s.startsWith("#"))&&!(s.startsWith("mailto:")||s.startsWith("tel:"))){try{let e=new URL(t.href,window.location.href);if(e.origin!==window.location.origin)return;let s=`${window.location.pathname}?${window.location.search}`,r=`${e.pathname}?${e.search}`;if(s===r)return}catch{return}queueMicrotask(()=>{l(!0),n(8)})}};return document.addEventListener("click",e,!0),()=>document.removeEventListener("click",e,!0)},[]),(0,r.useEffect)(()=>{if(a)return c.current=setInterval(()=>{n(e=>e>=88?e:Math.min(88,e+Math.min(12,Math.max(1,.18*(88-e)))))},150),()=>{c.current&&(clearInterval(c.current),c.current=null)}},[a]),(0,r.useEffect)(()=>{let s=`${e}?${t?.toString()??""}`;if(s!==o.current)return o.current=s,u.current&&clearTimeout(u.current),m.current&&clearTimeout(m.current),u.current=setTimeout(()=>{n(100),m.current=setTimeout(()=>{l(!1),n(0)},320)},220),()=>{u.current&&clearTimeout(u.current),m.current&&clearTimeout(m.current)}},[e,t]),a||0!==i)?(0,s.jsx)("div",{className:"pointer-events-none fixed inset-x-0 top-0 z-[9999] h-0.5","aria-hidden":"true",children:(0,s.jsx)("div",{className:"h-full origin-left bg-gradient-to-r from-primary via-accent to-primary transition-[width,opacity] duration-200 ease-out",style:{width:`${i}%`,opacity:i>=100?0:1,boxShadow:"0 0 10px rgba(99, 102, 241, 0.6), 0 0 4px rgba(229, 77, 94, 0.4)"}})}):null}var b=e.i(70552);let f="x-omniroute-csrf",g=["/api/auth/login","/api/auth/logout","/api/auth/status","/api/auth/oidc/","/api/init","/api/v1/","/api/sync/bundle","/api/oauth/","/api/codex/connect/","/api/cli/connect","/api/usage/om-usage","/api/skills/collect/chaos"],y=null,v=null,j=null,k=0,N=["/chat/completions","/responses","/models","/codex"],w=["/a2a"];function S(e=Date.now()){return y&&y.expiresAtMs-e>3e4?y.token:null}async function C(e){try{let t=await fetch("/api/auth/csrf",{cache:"no-store",credentials:"same-origin"});if(!t.ok)return null;let s=await t.json().catch(()=>null);if("string"!=typeof s?.token||"string"!=typeof s.expiresAt)return y=null,null;let r=Date.parse(s.expiresAt);if(!Number.isFinite(r)||r<=e)return y=null,null;return(y={token:s.token,expiresAtMs:r}).token}catch{return null}}async function T(){let e=S();return e||(v||(v=C(Date.now()).finally(()=>{v=null})),v)}function E(e){return"u">typeof Request&&e instanceof Request?e:null}var _=e.i(554364);let I="sidebar-collapsed",A="1"===t.default.env.NEXT_PUBLIC_OMNIROUTE_E2E_MODE;e.s(["default",0,function({children:e}){let[t,o]=(0,r.useState)(!1),[d,u]=(0,r.useState)(!1),m=(0,b.useIsElectron)(),[p,y]=(0,r.useState)(!1);(0,r.useEffect)(()=>{try{"true"===localStorage.getItem(I)&&setTimeout(()=>y(!0),0)}catch{}},[]);let v=m&&void 0!==globalThis.window&&globalThis.electronAPI?.platform==="darwin";return(0,r.useEffect)(()=>
15{if("u">typeof document)return document.body.classList.toggle("electron-macos",v),()=>{document.body.classList.remove("electron-macos")}},[v]),(0,r.useInsertionEffect)(()=>{let e=(0,_.installBasePathFetch)(),t=function(){if("function"!=typeof globalThis.fetch)return()=>{};0===k&&(j=globalThis.fetch,globalThis.fetch=async(e,t)=>{if(!j||!function(e,t){var s,r,a;let l,i;if(!["POST","PUT","PATCH","DELETE"].includes((t?.method?t.method:E(e)?.method??"GET").toUpperCase()))return!1;let n=(i=E(e))?i.url:e instanceof URL?e.href:"string"==typeof e?e:null;if(!n)return!1;try{l=new URL(n,window.location.href)}catch{return!1}return l.origin===window.location.origin&&(s=l,!!w.some(e=>s.pathname===e||s.pathname.startsWith(e+"/"))||s.pathname.startsWith("/api/")&&"/api/auth/csrf"!==s.pathname&&(r=s.pathname,!g.some(e=>r.startsWith(e)))&&!("/api/v1"===(a=s.pathname)||a.startsWith("/api/v1/")||"/api/v1beta"===a||a.startsWith("/api/v1beta/")||"/v1"===a||a.startsWith("/v1/")||"/v1beta"===a||a.startsWith("/v1beta/")||"/v1/v1"===a||a.startsWith("/v1/v1/")||N.some(e=>a===e||a.startsWith(e+"/"))))}(e,t))return j?j(e,t):fetch(e,t);let s=new Headers(t?.headers??E(e)?.headers);if(s.has(f))return j(e,t);let r=S()??await T();return r?(s.set(f,r),j(e,{...t,headers:s})):j(e,t)}),k++;let e=!0;return()=>{e&&(e=!1,0===(k=Math.max(0,k-1))&&j&&(globalThis.fetch=j,j=null))}}();return T(),()=>{t(),e()}},[]),(0,r.useEffect)(()=>{let e=e=>{(e.metaKey||e.ctrlKey)&&"k"===e.key&&(e.preventDefault(),u(e=>!e))};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[]),(0,s.jsxs)("div",{className:"flex h-dvh min-h-0 w-full overflow-hidden",children:[(0,s.jsx)(r.Suspense,{fallback:null,children:(0,s.jsx)(h,{})}),t&&(0,s.jsx)("div",{className:"fixed inset-0 z-40 bg-black/20 lg:hidden",onClick:()=>o(!1)}),(0,s.jsx)("div",{className:"dashboard-sidebar-desktop",children:(0,s.jsx)(a.default,{collapsed:p,onToggleCollapse:()=>{let e=!p;y(e),localStorage.setItem(I,String(e))},isMacElectron:v})}),(0,s.jsx)("div",{className:`fixed inset-y-0 start-0 z-50 transform lg:hidden transition-transform duration-300 ease-in-out h-dvh overflow-y-auto ${t?"translate-x-0":"-translate-x-full"}`,children:(0,s.jsx)(a.default,{onClose:()=>o(!1),isMacElectron:v})}),(0,s.jsxs)("main",{id:"main-content",className:"relative flex min-h-0 flex-1 min-w-0 flex-col transition-colors duration-300",children:[(0,s.jsx)(l.default,{onMenuClick:()=>o(!0),onOpenCommandPalette:()=>u(!0)}),!A&&(0,s.jsx)(c,{}),(0,s.jsx)("div",{className:"flex-1 min-h-0 overflow-y-auto overflow-x-hidden custom-scrollbar p-4 sm:p-6 lg:p-10",children:(0,s.jsxs)("div",{className:"max-w-[3840px] mx-auto w-full h-full min-h-0 flex flex-col",children:[(0,s.jsx)(n.default,{}),(0,s.jsx)("div",{className:"flex-1 min-h-0",children:e})]})})]}),(0,s.jsx)(i.default,{}),(0,s.jsx)(x,{isOpen:d,onClose:()=>u(!1)})]})}],165149)},359505,e=>{"use strict";var t=e.i(843476),s=e.i(897844);e.s(["default",0,function({children:e}){return(0,t.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,t.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,t.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,t.jsx)("div",{className:"absolute top-6 right-6 z-20",children:(0,t.jsx)(s.default,{variant:"card"})}),(0,t.jsx)("main",{className:"flex-1 flex flex-col items-center justify-center p-4 sm:p-6 z-10 w-full h-full",children:e})]})}])},565650,e=>{"use strict";e.s([],565650),e.i(342923),e.i(80173),e.i(907714),e.i(542055),e.i(905204),e.i(393718),e.i(51130),e.i(703166),e.i(454149),e.i(822124),e.i(969353),e.i(635055),e.i(897844),e.i(450222),e.i(647829),e.i(6998),e.i(982131),e.i(964039),e.i(279743),e.i(629476),e.i(16190),e.i(193464),e.i(548036),e.i(566770),e.i(953789),e.i(471348),e.i(8839),e.i(227404),e.i(621745),e.i(567955),e.i(17517),e.i(419947),e.i(268226),e.i(323060),e.i(642440),e.i(629342),e.i(816062),e.i(690777),e.
15i(563201),e.i(115243),e.i(915139),e.i(524578),e.i(515272),e.i(840387),e.i(110626),e.i(247854),e.i(589800),e.i(165149),e.i(359505)}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.