import{Cg as e,Dh as t,Eg as n,Hy as r,Mg as i,Sg as a,Tg as o,Ua as s,Zv as c,ap as l,dg as u,eg as d,jg as f,kh as p,lh as m,m_ as h,mv as g,n as _,pc as v,ph as y,tv as b,ty as x,wg as S,xg as C}from"./index-DDwwBb9e.js";import{t as w}from"./SettingsLayout-DkhRoxt1.js";var T=r();function E(r){let{openDrawer:d}=_(),{hasPermission:p}=l(),g=m.llmModelCost.getAllForProject.useQuery({projectId:r.projectId??``},{enabled:!!r.projectId});return(0,T.jsxs)(u,{gap:0,paddingTop:2,width:`full`,align:`start`,children:[(0,T.jsxs)(s.Header,{withBorder:!1,children:[(0,T.jsxs)(h,{children:[(0,T.jsx)(x,{children:`LLM Model Costs`}),g.data&&(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(c,{fontSize:`md`,children:`·`}),(0,T.jsxs)(c,{fontSize:`md`,color:`fg.muted`,children:[g.data?.length,` models`]})]})]}),(0,T.jsx)(f,{}),(0,T.jsxs)(s.HeaderButton,{onClick:()=>d(`llmModelCost`,{}),disabled:!p(`project:manage`),children:[(0,T.jsx)(t,{size:20}),(0,T.jsx)(c,{children:`Add New Model`})]})]}),(0,T.jsx)(u,{width:`full`,gap:0,align:`start`,paddingY:4,paddingX:4,paddingBottom:12,children:(0,T.jsxs)(o,{variant:`line`,width:`full`,maxWidth:`100%`,wordBreak:`break-all`,style:{tableLayout:`fixed`},children:[(0,T.jsx)(S,{width:`full`,children:(0,T.jsxs)(n,{width:`full`,children:[(0,T.jsx)(e,{width:`24%`,children:`Model name`}),(0,T.jsx)(e,{width:`24%`,children:`Regex match rule`}),(0,T.jsx)(e,{children:`Input cost`}),(0,T.jsx)(e,{children:`Output cost`}),(0,T.jsx)(e,{children:`Cache read`}),(0,T.jsx)(e,{children:`Cache write`}),(0,T.jsx)(e,{width:`64px`,padding:1})]})}),(0,T.jsxs)(C,{width:`full`,children:[g.isLoading&&Array.from({length:3}).map((e,t)=>(0,T.jsxs)(n,{children:[Array.from({length:6}).map((e,t)=>(0,T.jsx)(a,{children:(0,T.jsx)(i,{height:`20px`})},t)),(0,T.jsx)(a,{padding:1})]},t)),g.data?.map(e=>(0,T.jsxs)(n,{width:`full`,children:[(0,T.jsx)(a,{children:(0,T.jsx)(c,{truncate:!0,color:e.updatedAt?`green.500`:void 0,children:e.model})}),(0,T.jsx)(a,{padding:0,children:(0,T.jsx)(h,{justifyContent:`space-between`,paddingX:4,marginX:2,maxWidth:`100%`,children:(0,T.jsx)(b,{truncate:!0,color:e.updatedAt?`green.500`:void 0,height:`32px`,lineHeight:`22px`,borderRadius:`6px`,border:`1px solid`,borderColor:`border`,bg:`bg.subtle`,paddingY:1,paddingX:2,children:e.regex})})}),(0,T.jsx)(a,{padding:0,children:(0,T.jsx)(c,{justifyContent:`space-between`,paddingX:4,marginX:2,color:e.id?`green.500`:void 0,children:e.inputCostPerToken?.toLocaleString(`fullwide`,{useGrouping:!1,maximumSignificantDigits:20})})}),(0,T.jsx)(a,{padding:0,children:(0,T.jsx)(c,{justifyContent:`space-between`,paddingX:4,marginX:2,color:e.id?`green.500`:void 0,children:e.outputCostPerToken?.toLocaleString(`fullwide`,{useGrouping:!1,maximumSignificantDigits:20})})}),(0,T.jsx)(a,{padding:0,children:(0,T.jsx)(c,{justifyContent:`space-between`,paddingX:4,marginX:2,color:e.id?`green.500`:void 0,children:e.cacheReadCostPerToken?.toLocaleString(`fullwide`,{useGrouping:!1,maximumSignificantDigits:20})})}),(0,T.jsx)(a,{padding:0,children:(0,T.jsx)(c,{justifyContent:`space-between`,paddingX:4,marginX:2,color:e.id?`green.500`:void 0,children:e.cacheCreationCostPerToken?.toLocaleString(`fullwide`,{useGrouping:!1,maximumSignificantDigits:20})})}),(0,T.jsx)(a,{padding:1,children:(0,T.jsx)(D,{id:e.id,model:e.model,projectId:e.projectId})})]},e.model))]})]})})]})}function D({id:e,model:t,projectId:n}){let{openDrawer:r}=_(),i=m.llmModelCost.getAllForProject.useQuery({projectId:n??``},{enabled:!!n}),a=m.llmModelCost.delete.useMutation();return(0,T.jsxs)(v.Root,{children:[(0,T.jsx)(v.Trigger,{minWidth:0,asChild:!0,children:(0,T.jsx)(g,{variant:`ghost`,children:(0,T.jsx)(p,{})})}),(0,T.jsxs)(v.Content,{children:[!e&&(0,T.jsx)(v.Item,{value:`clone`,onClick:e=>{e.stopPropagation(),r(`llmModelCost`,{cloneModel:t})},children:`Clone`}),e&&(0,T.jsx)(v.Item,{value:`edit`,onClick:t=>{t.stopPropagation(),r(`llmModelCost`,{id:e})},children:`Edit`}),e&&(0,T.jsx)(v.Item,{value:`delete`,color:`red.600`,onClick:t=>{t.stopPropagation(),a.mutate({projectId:n??``,id:e},{onSuccess:()=>{y.create({title:`Success`,description:`LLM model cost deleted successfully`,type:`success`,meta:{closable:!0}}),i.refetch()},onError:e=>{d(e)||y.create({title:`Error`,description:`Error deleting LLM model cost`,type:`error`,meta:{closable:!0}})}})},children:`Delete`})]})]})}function O(){let{project:e}=l();return(0,T.jsx)(w,{children:(0,T.jsx)(E,{projectId:e?.id})})}export{O as default};
//# sourceMappingURL=model-costs-COI6fAMQ.js.map