1import{bs as K,aU as ce,ae as me,r as d,a0 as y,bk as E,x as v,j as e,R as te,U as se,S as ue,L as z,y as pe,ab as xe,B as ae,_ as T,aY as ge,gs as W,a6 as he,as as D,at as L,au as R,av as F,bE as re,bF as ne,aw as P}from"./index-BjuXe62r.js";import{U as fe}from"./unsaved-changes-guard-BNR7xVNV.js";import{I as be}from"./InsightsTableSortHeader-CnqcGRdr.js";import{u as je}from"./WalletContext-ajTjCYaO.js";import{u as we}from"./useWalletMoney-xJTPFOnM.js";import{S as H}from"./switch-C_sxxjta.js";import{i as Ne,I as J,a as _e}from"./template-ai-image-panel-gate-rMlhfvYe.js";import{I as Se}from"./image-Bzxha5sx.js";import{B as ye}from"./bot-DnTexIs2.js";import{D as ve}from"./database-B3N1R-Gf.js";import{S as Ce}from"./save-D7BFGqN2.js";import"./alert-dialog-CMkrTCOL.js";import"./triangle-alert-C22gBlJg.js";import"./arrow-down-BZ2ZsqDi.js";import"./arrow-up-down-C_a-9vGe.js";import"./BillingContext-CM-Njn1R.js";import"./native-wallet-recharge-CGE-Kc27.js";import"./wallet-limits-CkVGEqF7.js";import"./copulse-pricing-KM4KJGHi.js";import"./nurture-fixtures-lw6XEqNO.js";import"./channelCatalog-BpZtdaoB.js";import"./sms-channel-pricing-DyjRwt5E.js";import"./instagram-ClThaO0n.js";const Ae=10;function ke(t){const a=K(t);return a?`/organization/ai-credits/usage?${new URLSearchParams({page_size:String(Ae),from:new Date(a.gteMs).toISOString(),to:new Date(a.lteMs).toISOString()}).toString()}`:null}function Ie(t){const a=K(t);return a?`/organization/ai-credits/usage/export?${new URLSearchParams({from:new Date(a.gteMs).toISOString(),to:new Date(a.lteMs).toISOString()}).toString()}`:null}function Ee(t){const a=K(t);if(!a)return null;const s=new Date(a.gteMs).toISOString().slice(0,10),r=new Date(a.lteMs).toISOString().slice(0,10);return`ai-credits-usage-${s}-to-${r}.csv`}async function Te(t){const a=Ie(t),s=Ee(t);if(!a||!s)throw new Error("Choose a complete date range before exporting.");const r=await ce(a);if(!r.ok){let n="Export failed";try{const p=await r.json();typeof p.error=="string"&&(n=p.error)}catch{}throw new Error(n)}const l=await r.blob(),m=URL.createObjectURL(l),u=document.createElement("a");u.href=m,u.download=s,u.rel="noopener",u.click(),URL.revokeObjectURL(m)}const Me="createdAt",Ue="desc",Oe=["feature","model"];function Y(t,a){return a==="feature"?(t.sourceLabel??"").toLowerCase():t.model.toLowerCase()}function q(t,a){if(a==="createdAt"){const s=Date.parse(t.createdAt);return Number.isFinite(s)?s:0}return a==="estimatedCost"?t.estimatedCost??0:t[a]??0}function De(t,a,s,r){const l=r==="asc"?1:-1;return s==="feature"||s==="model"?Y(t,s).localeCompare(Y(a,s))*l:(q(t,s)-q(a,s))*l}function Le(t,a,s){return t===s?{key:t,direction:a==="asc"?"desc":"asc"}:{key:s,direction:Oe.includes(s)?"asc":"desc"}}const Re=[{id:"7d",label:"7d"},{id:"30d",label:"30d"},{id:"90d",label:"90d"},{id:"custom",label:"Custom"}],X="AI usage",Fe=[{key:"createdAt",label:"When"},{key:"feature",label:"Feature"},{key:"model",label:"Model"},{key:"promptTokens",label:"In",align:"right"},{key:"completionTokens",label:"Out",align:"right"},{key:"estimatedCost",label:"Billed",align:"right"}],$=(t,a)=>t===null||!Number.isFinite(t)?"â":t<=0?W(0,a):W(t,a),C=t=>t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}k`:String(t),Z=t=>{const a=new Date(t);return Number.isNaN(a.getTime())?t:a.toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})};function Pe(){const t=me("30d","updated"),{walletForAiCredits:a,hasOrgWallet:s}=je(),{formatWalletAmount:r}=we(),l=a(),[m,u]=d.useState(null),[n,p]=d.useState(!0),[x,i]=d.useState(!1),[h,b]=d.useState(null),N=d.useMemo(()=>ke(t.apiParams),[t.apiParams]),A=d.useCallback(async()=>{if(!N){u(null),b(null),p(!1);return}p(!0),b(null);try{const f=await y(N);u(f)}catch(f){b(E(f,"Failed to load AI usage"))}finally{p(!1)}},[N]);d.useEffect(()=>{A()},[A]);const j=t.preset==="custom"&&!t.customFrom.trim(),_=d.useCallback(async()=>{if(!j){i(!0);try{await Te(t.apiParams);const f=m?.summary.messageCount??0;v.success(f>0?`Exported ${f.toLocaleString()} AI usage event${f===1?"":"s"}.`:"Export ready â no AI usage in this period.")}catch(f){v.error(E(f,"Export failed"))}finally{i(!1)}}},[t.apiParams,j,m?.summary.messageCount]);return e.jsx(te,{children:e.jsxs(se,{className:"min-w-0 space-y-4 p-4",children:[s?l?e.jsxs("div",{className:"min-w-0 rounded-md border border-border bg-muted/20 p-3",children:[e.jsxs("div",{className:"flex min-w-0 flex-col gap-2 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("p",{className:"flex items-center gap-1.5 text-xs font-semibold",children:[e.jsx(ue,{className:"h-3.5 w-3.5 shrink-0 text-primary"}),"AI Credits budget · ",l.name]}),e.jsx("p",{className:"mt-1 text-[11px] text-muted-foreground",children:l.uses_shared_balance?"No allocation cap â usage draws from the main wallet balance.":"Allocated cap for Copilot and other AI features."})]}),e.jsx(z,{to:"/settings/wallets",className:"shrink-0 text-[11px] font-medium text-primary underline-offset-4 hover:underline",children:"Manage in Wallets"})]}),e.jsxs("div",{className:"mt-3 grid min-w-0 grid-cols-2 gap-3 lg:grid-cols-3",children:[l.uses_shared_balance?null:e.jsx(w,{label:"Allocated",value:r(l.allocated??0)}),e.jsx(w,{label:"Spent",value:r(l.spent??0)}),e.jsx(w,{label:l.uses_shared_balance?"Available":"Remaining",value:r(l.balance)})]})]}):e.jsxs("p",{className:"text-sm text-muted-foreground",children:["No AI Credits sub-wallet yet."," ",e.jsx(z,{to:"/settings/wallets",className:"font-medium text-primary underline-offset-4 hover:underline",children:"Create one in Wallets"})," ","to set a dedicated AI budget."]}):null,e.jsxs("div",{className:"flex min-w-0 flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("h3",{className:"flex items-center gap-2 text-sm font-semibold",children:[e.jsx(pe,{className:"h-4 w-4 shrink-0 text-primary"}),"Copilot usage"]}),e.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[e.jsx(xe,{options:Re,value:t.preset,onChange:t.setPreset,customFrom:t.customFrom,customTo:t.customTo,onCustomFromChange:t.setCustomFrom,onCustomToChange:t.setCustomTo}),e.jsxs(ae,{type:"button",variant:"outline",size:"sm",className:"h-8 shrink-0 touch-manipulation",disabled:j||n||x,onClick:()=>{_()},children:[x?e.jsx(T,{className:"mr-1.5 h-3.5 w-3.5 animate-spin"}):e.jsx(ge,{className:"mr-1.5 h-3.5 w-3.5"}),x?"Exportingâ¦":"Export CSV"]})]})]}),j?e.jsx("p",{className:"text-sm text-muted-foreground",children:"Choose a start date for your custom range."}):n?e.jsxs("div",{className:"flex items-center gap-2 py-6 text-sm text-muted-foreground",children:[e.jsx(T,{className:"h-4 w-4 animate-spin"}),"Loading usageâ¦"]}):h?e.jsx("p",{className:"text-sm text-destructive",children:h}):m?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid min-w-0 grid-cols-2 gap-3 lg:grid-cols-4",children:[e.jsx(w,{label:"Billed spend",value:$(m.summary.estimatedCost,m.currency)}),e.jsx(w,{label:"Input tokens",value:C(m.summary.promptTokens)}),e.jsx(w,{label:"Output tokens",value:C(m.summary.completionTokens)}),e.jsx(w,{label:"Copilot replies",value:String(m.summary.messageCount)})]}),m.items.length>0?e.jsx($e,{items:m.items}):e.jsx("p",{className:"text-sm text-muted-foreground",children:"No AI usage recorded this period yet."})]}):null]})})}function $e({items:t}
1){const[a,s]=d.useState(Me),[r,l]=d.useState(Ue),m=n=>{const p=Le(a,r,n);s(p.key),l(p.direction)},u=d.useMemo(()=>[...t].sort((n,p)=>De(n,p,a,r)),[t,a,r]);return e.jsxs("div",{className:"min-w-0 space-y-2",children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground",children:"Recent activity"}),e.jsxs("div",{className:"hidden min-w-0 divide-y divide-border rounded-md border border-border xl:block",children:[e.jsx("div",{className:"grid grid-cols-[1.2fr_1fr_1fr_0.7fr_0.7fr_0.8fr] gap-2 bg-muted/40 px-3 py-2 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground",children:Fe.map(n=>e.jsx(be,{label:n.label,active:a===n.key,direction:r,align:n.align,onClick:()=>m(n.key)},n.key))}),u.map(n=>e.jsxs("div",{className:"grid grid-cols-[1.2fr_1fr_1fr_0.7fr_0.7fr_0.8fr] gap-2 px-3 py-2 text-[12px]",children:[e.jsx("span",{className:"min-w-0 truncate text-muted-foreground",children:Z(n.createdAt)}),e.jsx("span",{className:"min-w-0 truncate font-medium",children:n.sourceLabel??X}),e.jsx("span",{className:"min-w-0 truncate text-muted-foreground",children:n.model}),e.jsx("span",{className:"text-right tabular-nums",children:C(n.promptTokens)}),e.jsx("span",{className:"text-right tabular-nums",children:C(n.completionTokens)}),e.jsx("span",{className:"text-right tabular-nums",children:$(n.estimatedCost,n.currency)})]},n.messageId))]}),e.jsx("div",{className:"space-y-2 xl:hidden",children:u.map(n=>e.jsxs("div",{className:"min-w-0 rounded-md border border-border p-3 text-[12px]",children:[e.jsxs("div",{className:"flex min-w-0 items-start justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"truncate font-medium",children:n.sourceLabel??X}),e.jsx("p",{className:"truncate text-[11px] text-muted-foreground",children:n.model})]}),e.jsx("span",{className:"shrink-0 text-muted-foreground",children:Z(n.createdAt)})]}),e.jsxs("div",{className:"mt-2 grid grid-cols-3 gap-2 text-[11px] text-muted-foreground",children:[e.jsxs("span",{children:["In: ",C(n.promptTokens)]}),e.jsxs("span",{children:["Out: ",C(n.completionTokens)]}),e.jsx("span",{className:"text-right",children:$(n.estimatedCost,n.currency)})]})]},n.messageId))})]})}function w({label:t,value:a}){return e.jsxs("div",{className:"min-w-0 rounded-md border border-border bg-muted/20 p-3",children:[e.jsx("p",{className:"text-[10px] font-medium uppercase tracking-wide text-muted-foreground",children:t}),e.jsx("p",{className:"mt-1 truncate text-sm font-semibold tabular-nums",children:a})]})}const M=(t,a)=>`${t}:${a}`,Q=t=>{const a=t.indexOf(":");if(a<=0)return null;const s=t.slice(0,a),r=t.slice(a+1);return r?{provider:s,model:r}:null};function Ke({providers:t,catalog:a,value:s,onChange:r,disabled:l=!1}){const m=M(s.process.provider,s.process.model),u=M(s.generate.provider,s.generate.model),n=s.enabled||s.templates_enabled,[p,x]=d.useState(!1);return d.useEffect(()=>{if(!Ne())return;x(!0),document.getElementById(J)?.scrollIntoView({behavior:"smooth",block:"center"})},[]),e.jsxs("div",{className:"min-w-0 space-y-4 border-t border-border pt-4",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("label",{className:"flex items-center gap-1.5 text-xs font-medium",children:[e.jsx(Se,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),"Image AI"]}),e.jsx("p",{className:"mt-1 text-[11px] text-muted-foreground",children:"Agents and templates have separate toggles and limits. Generate model is shared. Phone never uses Image AI."})]}),e.jsxs("div",{className:"flex min-w-0 items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-xs font-medium",children:"Enable Image in AI agents"}),e.jsx("p",{className:"mt-1 text-[11px] text-muted-foreground",children:"Process inbound images and allow the agent generate_image tool."})]}),e.jsx(H,{checked:s.enabled,disabled:l,onCheckedChange:i=>r({...s,enabled:i}),"aria-label":"Enable Image in AI agents"})]}),e.jsxs("div",{className:`grid min-w-0 gap-3 sm:grid-cols-2 ${s.enabled?"":"opacity-60"}`,children:[e.jsx(S,{label:"Agent process max per turn",value:s.process_max_per_turn,disabled:l||!s.enabled,onChange:i=>r({...s,process_max_per_turn:i})}),e.jsx(S,{label:"Agent process max per conversation",value:s.process_max_per_conversation,disabled:l||!s.enabled,onChange:i=>r({...s,process_max_per_conversation:i})}),e.jsx(S,{label:"Agent generate max per turn",value:s.generate_max_per_turn,disabled:l||!s.enabled,onChange:i=>r({...s,generate_max_per_turn:i})}),e.jsx(S,{label:"Agent generate max per conversation",value:s.generate_max_per_conversation,disabled:l||!s.enabled,onChange:i=>r({...s,generate_max_per_conversation:i})})]}),e.jsxs("div",{id:J,className:`scroll-mt-24 flex min-w-0 items-start justify-between gap-3 border-t border-border pt-4 ${p?"rounded-md ring-2 ring-primary/40 ring-offset-2 ring-offset-background":""}`,children:[e.jsxs("div",{className:"min-w-0",children:[p?e.jsxs("div",{className:"mb-3 rounded-md border border-primary/25 bg-primary/5 px-3 py-2.5 text-[11px] text-foreground",role:"status",children:[e.jsx("p",{className:"font-medium",children:"Enable template Image AI"}),e.jsx("p",{className:"mt-1 text-muted-foreground",children:_e})]}):null,e.jsx("p",{className:"text-xs font-medium",children:"Enable Image in templates"}),e.jsx("p",{className:"mt-1 text-[11px] text-muted-foreground",children:"Approve a prompt, then generate images for WhatsApp, email, push, and RCS media slots."})]}),e.jsx(H,{checked:s.templates_enabled,disabled:l,onCheckedChange:i=>r({...s,templates_enabled:i}),"aria-label":"Enable Image in templates"})]}),e.jsxs("div",{className:`grid min-w-0 gap-3 sm:grid-cols-2 ${s.templates_enabled?"":"opacity-60"}`,children:[e.jsx(S,{label:"Template generate max per day",value:s.templates_generate_max_per_day,disabled:l||!s.templates_enabled,onChange:i=>r({...s,templates_generate_max_per_day:i})}),e.jsx(S,{label:"Template generate max per template",value:s.templates_generate_max_per_template,disabled:l||!s.templates_enabled,onChange:i=>r({...s,templates_generate_max_per_template:i})})]}),e.jsxs("div",{className:`grid min-w-0 gap-3 lg:grid-cols-2 ${n?"":"opacity-60"}`,children:[e.jsx(ee,{label:"Process model",hint:"Vision on new inbound agent images.",value:m,providers:t,models:a.process,disabled:l||!s.enabled,onChange:i=>{const h=Q(i);h&&r({...s,process:h})}}),e.jsx(ee,{label:"Generate model",hint:"Shared by agents and templates.",value:u,providers:t,models:a.generate,disabled:l||!n,onChange:i=>{const h=Q(i);h&&r({...s,generate:h})}})]})]})}function ee({label:t,hint:a,value:s,providers:r,models:l,disabled:m,onChange:u}){const n=Object.keys(r).map(x=>({provider:x,label:r[x],models:l.filter(i=>i.provider===x)})).filter(x=>x.models.length>0),p=l.find(x=>M(x.provider,x.id)===s);return e.jsxs("div",{className:"min-w-0",children:[e.jsx("label",{className:"mb-1.5 block text-xs font-medium",children:t}),e.jsxs(D,{value:s,onValueChange:u,disabled:m,children:[e.jsx(L,{className:"h-auto min-h-9 w-full min-w-0 py-2 text-left",children:e.jsx(R,{placeholder:p?.label??"Select model"})}),e.jsx(F,{className:"max-w-[min(100vw-2rem,var(--radix-select-trigger-width))]",children:n.map(x=>e.jsxs(re,{children:[e.jsx(ne,{children:x.label}),x.models.map(i=>e.jsxs(P,{value:M(i.provider,i.id),textValue:i.label,children:[e.jsx("span",{className:"font-medium",children:i.label}),i.description?e.jsx("span",{className:"mt-0.5 block text-[11px] text-muted-foreground",children:i.description}):null]},i.id))]},x.provider))})]}),e.jsx("p",{className:"mt-1 text-[11px] text-muted-foreground",children:a})]})}function S({label:t,value:a,disabled:s,onChange:r}){return e.jsxs("div",{className:"min-w-0",children:[e.jsx("label",{className:"mb-1.5 block text-xs font-medium",children:t}),e.jsx(he,{type:"number",min:1,max:50,value:a,disabled:s,className:"h-9",onChange:l=>{const m=Number.parseInt(l.target.value,10);
1Number.isFinite(m)&&r(Math.min(50,Math.max(1,m)))}})]})}const I=(t,a)=>`${t}:${a}`,O=t=>{const a=t.indexOf(":");if(a<=0)return null;const s=t.slice(0,a),r=t.slice(a+1);return r?{provider:s,model:r}:null};function Ge(){const[t,a]=d.useState(null),[s,r]=d.useState(null),[l,m]=d.useState(null),[u,n]=d.useState(""),[p,x]=d.useState(""),[i,h]=d.useState(null),[b,N]=d.useState("openai_hosted"),[A,j]=d.useState(!0),[_,f]=d.useState(!1),G=d.useCallback(async()=>{j(!0);try{const[o,c,g]=await Promise.all([y("/ai-models/catalog"),y("/organization/ai-models"),y("/organization/knowledge-settings")]);a(o),r(c),m(g),n(I(c.chat.provider,c.chat.model)),x(I(c.embedding.provider,c.embedding.model)),h({...c.image_ai,templates_enabled:c.image_ai.templates_enabled===!0,templates_generate_max_per_day:c.image_ai.templates_generate_max_per_day??20,templates_generate_max_per_template:c.image_ai.templates_generate_max_per_template??5}),N(g.backend)}catch(o){v.error(E(o,"Failed to load AI model settings"))}finally{j(!1)}},[]);d.useEffect(()=>{G()},[G]);const ie=d.useMemo(()=>!s||!l||!i?!1:u!==I(s.chat.provider,s.chat.model)||p!==I(s.embedding.provider,s.embedding.model)||b!==l.backend||JSON.stringify(i)!==JSON.stringify(s.image_ai),[s,l,u,p,b,i]),le=d.useMemo(()=>t?Object.keys(t.providers).map(o=>({provider:o,label:t.providers[o],models:t.chat.filter(c=>c.provider===o)})):[],[t]),U=(t?.knowledge_backends??[]).filter(o=>o.id!=="elasticsearch"),B=d.useMemo(()=>U.find(o=>o.id===b)??null,[U,b]),k=d.useMemo(()=>{if(!t||!u)return null;const o=O(u);return o?t.chat.find(c=>c.provider===o.provider&&c.id===o.model)??null:null},[t,u]),oe=async()=>{const o=O(u),c=O(p);if(!o||!c){v.error("Select valid models");return}f(!0);try{const[g,de]=await Promise.all([y("/organization/ai-models",{method:"PATCH",body:JSON.stringify({chat:o,embedding:c,image_ai:i})}),y("/organization/knowledge-settings",{method:"PATCH",body:JSON.stringify({backend:b})})]);r(g),h({...g.image_ai,templates_enabled:g.image_ai.templates_enabled===!0,templates_generate_max_per_day:g.image_ai.templates_generate_max_per_day??20,templates_generate_max_per_template:g.image_ai.templates_generate_max_per_template??5}),m(de),v.success("AI & knowledge settings updated")}catch(g){v.error(E(g,"Failed to save settings"))}finally{f(!1)}};if(A)return e.jsxs("div",{className:"flex min-w-0 items-center justify-center gap-2 px-4 py-12 text-sm text-muted-foreground",children:[e.jsx(T,{className:"h-4 w-4 animate-spin"})," Loading AI modelsâ¦"]});const V=k?.costMultiple;return e.jsxs("div",{className:"min-w-0 space-y-4 overflow-x-hidden px-4 py-5 md:px-6",children:[e.jsx(fe,{isDirty:ie&&!A&&!_}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("h2",{className:"flex items-center gap-2 font-display text-lg font-semibold",children:[e.jsx(ye,{className:"h-5 w-5 shrink-0 text-primary"})," AI Credits"]}),e.jsx("p",{className:"text-[13px] text-muted-foreground",children:"Track CoPulse Copilot usage, and configure knowledge storage, chat models, and embedding models for grounded answers."})]}),e.jsx(Pe,{}),e.jsx(te,{children:e.jsxs(se,{className:"min-w-0 space-y-5 p-4",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("label",{className:"mb-1.5 flex items-center gap-1.5 text-xs font-medium",children:[e.jsx(ve,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),"Knowledge vector store"]}),e.jsxs(D,{value:b,onValueChange:o=>N(o),children:[e.jsx(L,{className:"h-auto min-h-9 w-full min-w-0 whitespace-normal py-2 text-left lg:max-w-lg",children:B?e.jsx("span",{className:"min-w-0 flex-1 truncate font-medium",children:B.label}):e.jsx(R,{placeholder:"Select vector store"})}),e.jsx(F,{className:"max-w-[min(100vw-2rem,var(--radix-select-trigger-width))]",children:U.map(o=>e.jsx(P,{value:o.id,textValue:o.label,className:"items-start py-2",children:e.jsxs("div",{className:"min-w-0 pr-6",children:[e.jsx("span",{className:"block font-medium leading-snug",children:o.label}),e.jsx("span",{className:"mt-0.5 block text-[11px] leading-snug text-muted-foreground",children:o.description})]})},o.id))})]}),e.jsx("p",{className:"mt-1 text-[11px] text-muted-foreground",children:"Applies to all knowledge bases in this organization. Existing indexed documents are not migrated automaticallyâre-ingest or recreate sources after switching."}
1),l?.openai?.vector_store_id?e.jsxs("p",{className:"mt-1 break-all text-[11px] text-muted-foreground",children:["OpenAI vector store id:"," ",e.jsx("span",{className:"font-mono",children:l.openai.vector_store_id})]}):null]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("label",{className:"mb-1.5 block text-xs font-medium",children:"Chat model"}),e.jsxs(D,{value:u,onValueChange:n,children:[e.jsx(L,{className:"h-auto min-h-9 w-full min-w-0 whitespace-normal py-2 text-left lg:max-w-md",children:k?e.jsxs("div",{className:"min-w-0 flex-1 overflow-hidden text-left",children:[e.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-x-2 gap-y-0.5",children:[e.jsx("span",{className:"truncate font-medium",children:k.label}),V!==void 0?e.jsxs("span",{className:"shrink-0 rounded bg-muted px-1.5 py-0.5 text-[10px] font-bold uppercase tracking-wider text-muted-foreground",children:[V,"x cost"]}):null]}),k.description?e.jsx("p",{className:"mt-0.5 truncate text-[11px] text-muted-foreground",children:k.description}):null]}):e.jsx(R,{placeholder:"Select chat model"})}),e.jsx(F,{className:"max-w-[min(100vw-2rem,var(--radix-select-trigger-width))]",children:le.map(o=>e.jsxs(re,{children:[e.jsx(ne,{children:o.label}),o.models.map(c=>{const g=c.costMultiple;return e.jsx(P,{value:I(c.provider,c.id),textValue:`${c.label} ${c.description??""}`,className:"items-start py-2",children:e.jsxs("div",{className:"min-w-0 pr-6",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1",children:[e.jsx("span",{className:"font-medium leading-snug",children:c.label}),g!==void 0?e.jsxs("span",{className:"shrink-0 rounded bg-muted px-1.5 py-0.5 text-[10px] font-bold uppercase tracking-wider text-muted-foreground",children:[g,"x cost"]}):null]}),c.description?e.jsx("p",{className:"mt-0.5 text-[11px] leading-snug text-muted-foreground",children:c.description}):null]})},c.id)})]},o.provider))})]}),e.jsx("p",{className:"mt-1 text-[11px] text-muted-foreground",children:"Used for Test KB grounded answers and similar retrieval-augmented replies."})]}),t.image_ai&&i?e.jsx(Ke,{providers:t.providers,catalog:t.image_ai,value:i,onChange:h,disabled:_}):null,e.jsx("div",{className:"flex flex-col-reverse gap-2 border-t border-border pt-4 sm:flex-row sm:justify-end",children:e.jsxs(ae,{size:"sm",className:"w-full sm:w-auto",onClick:()=>{oe()},disabled:_,children:[_?e.jsx(T,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(Ce,{className:"h-3.5 w-3.5"}),"Save settings"]})})]})})]})}const ut=Ge;export{ut as component};
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.