import{s as Kt,n as et,r as _t,o as Qt,a as mt}from"../chunks/t7hwNuoe.js";import{S as Wt,i as Xt,d,l as r,a as he,b as t,n as Ne,c as i,e as p,m as $,g,f as S,h as c,j as C,t as M,s as ee,o as vt,p as qe,k as Ke,q as lt,r as de,u as ht}from"../chunks/CZxRa0tt.js";import{e as Ae}from"../chunks/D6YF6ztN.js";function Et(o,e,l){const s=o.slice();return s[78]=e[l],s}function kt(o,e,l){const s=o.slice();return s[64]=e[l],s}function xt(o,e,l){const s=o.slice();return s[75]=e[l],s[77]=l,s}function yt(o,e,l){const s=o.slice();return s[64]=e[l],s}function It(o,e,l){const s=o.slice();return s[57]=e[l],s}function Dt(o,e,l){const s=o.slice();return s[57]=e[l],s}function Pt(o,e,l){const s=o.slice();return s[64]=e[l],s}function Vt(o,e,l){const s=o.slice();return s[54]=e[l],s}function wt(o,e,l){const s=o.slice();return s[57]=e[l][0],s[58]=e[l][1],s}function Tt(o,e,l){const s=o.slice();return s[61]=e[l][0],s[58]=e[l][1],s}function Nt(o,e,l){const s=o.slice();return s[64]=e[l][0],s[58]=e[l][1],s}function jt(o){let e,l;return{c(){e=c("div"),l=M(o[3]),this.h()},l(s){e=i(s,"DIV",{class:!0});var n=p(e);l=S(n,o[3]),n.forEach(d),this.h()},h(){r(e,"class","mb-4 p-3 bg-red-50 text-red-700 rounded-lg border border-red-200")},m(s,n){he(s,e,n),t(e,l)},p(s,n){n[0]&8&&ee(l,s[3])},d(s){s&&d(e)}}}function Zt(o){let e,l,s,n="Create Budget Alert",u,a,h,_,m="Alert Name",v,f,b,k,E,N="Provider (optional)",te,D,x,L="All providers",K,W,z,B="Project (optional)",P,V,ae,F,O,A="Monthly Limit ($)",w,R,ne,H,U,J,Y=o[23]*100+"",oe,ge,ke,le,Ie,re,_e=o[2]?"Creating...":"Create Alert",Be,pe,Q,q,se,fe="Active Alerts",Ve,xe,ue,ye=Ae(o[6]),X=[];for(let j=0;j0?sl:ll}let Me=we(o),y=Me(o);return{c(){e=c("div"),l=c("div"),s=c("h3"),s.textContent=n,u=C(),a=c("div"),h=c("div"),_=c("label"),_.textContent=m,v=C(),f=c("input"),b=C(),k=c("div"),E=c("label"),E.textContent=N,te=C(),D=c("select"),x=c("option"),x.textContent=L;for(let j=0;jo[44].call(D)),r(z,"class","label"),r(V,"type","text"),r(V,"placeholder","Leave empty for all projects"),r(V,"class","input"),r(O,"class","label"),r(R,"type","number"),r(R,"step","0.01"),r(R,"placeholder","1000.00"),r(R,"class","input"),r(U,"class","label"),r(le,"type","range"),r(le,"min","0.5"),r(le,"max","1"),r(le,"step","0.05"),r(le,"class","w-full"),re.disabled=pe=o[2]||!o[19]||!o[22],r(re,"class","btn-primary w-full disabled:opacity-50"),r(a,"class","space-y-4"),r(l,"class","card p-4"),r(se,"class","text-base font-bold text-surface-800 mb-4"),r(q,"class","lg:col-span-2 card p-4"),r(e,"class","grid grid-cols-1 lg:grid-cols-3 gap-4")},m(j,ce){he(j,e,ce),t(e,l),t(l,s),t(l,u),t(l,a),t(a,h),t(h,_),t(h,v),t(h,f),de(f,o[19]),t(a,b),t(a,k),t(k,E),t(k,te),t(k,D),t(D,x);for(let Z=0;Zo[33].call(b)),r(N,"class","label"),L.__value="",de(L,L.__value),r(x,"class","input"),o[7]===void 0&&mt(()=>o[34].call(x)),r(h,"class","grid grid-cols-2 gap-3"),r(P,"class","label"),r(F,"type","number"),r(F,"step","0.01"),r(F,"placeholder","0.00"),r(F,"class","input"),r(w,"class","label"),r(H,"type","date"),r(H,"class","input"),r(z,"class","grid grid-cols-2 gap-3"),r(oe,"class","label"),r(le,"type","number"),r(le,"placeholder","Optional"),r(le,"class","input"),r(_e,"class","label"),r(Q,"type","number"),r(Q,"placeholder","Optional"),r(Q,"class","input"),r(J,"class","grid grid-cols-2 gap-3"),r(fe,"class","label"),r(ue,"type","text"),r(ue,"placeholder","default"),r(ue,"class","input"),r(we,"class","label"),r(j,"type","text"),r(j,"placeholder","Optional description"),r(j,"class","input"),Z.disabled=Le=o[2]||!o[8],r(Z,"class","btn-primary w-full disabled:opacity-50"),r(a,"class","space-y-4"),r(l,"class","card p-4"),r(Ue,"class","text-base font-bold text-surface-800 mb-4"),r(Fe,"class","space-y-3 max-h-[500px] overflow-y-auto"),r(Xe,"class","text-xs text-surface-500 mt-2"),r(Ce,"class","card p-4"),r(e,"class","grid grid-cols-1 lg:grid-cols-2 gap-4")},m(I,Ee){he(I,e,Ee),t(e,l),t(l,s),t(l,u),t(l,a),t(a,h),t(h,_),t(_,m),t(_,f),t(_,b);for(let T=0;T0?"+":""}${o[4].month_over_month_change}%`:"0%",V,ae,F,O,A,w="All Time",R,ne,H=((st=o[4])!=null&&st.all_time_total?me(o[4].all_time_total):"$0.00")+"",U,J,Y,oe,ge="By Provider",ke,le,Ie,re,_e,Be="By Project",pe,Q,q,se,fe,Ve="By Model",xe,ue,ye,X,we,Me="Daily Breakdown",y;function j(G,ie){var ve;return ie[0]&32&&(le=null),le==null&&(le=!!((ve=G[5])!=null&&ve.by_provider&&Object.keys(G[5].by_provider).length>0)),le?rl:nl}let ce=j(o,[-1,-1,-1]),Z=ce(o);function Te(G,ie){var ve;return ie[0]&32&&(Q=null),Q==null&&(Q=!!((ve=G[5])!=null&&ve.by_project&&Object.keys(G[5].by_project).length>0)),Q?cl:il}let He=Te(o,[-1,-1,-1]),Le=He(o);function Qe(G,ie){var ve;return ie[0]&32&&(ue=null),ue==null&&(ue=!!((ve=G[5])!=null&&ve.by_model&&Object.keys(G[5].by_model).length>0)),ue?dl:ul}let ze=Qe(o,[-1,-1,-1]),Ce=ze(o);function Ue(G,ie){var ve;return(ve=G[5])!=null&&ve.daily_breakdown&&G[5].daily_breakdown.length>0?hl:fl}let Re=Ue(o),Se=Re(o);return{c(){e=c("div"),l=c("div"),s=c("div"),n=c("p"),n.textContent=u,a=C(),h=c("p"),m=M(_),v=C(),f=c("div"),b=c("p"),b.textContent=k,E=C(),N=c("p"),D=M(te),x=C(),L=c("div"),K=c("p"),K.textContent=W,z=C(),B=c("p"),V=M(P),F=C(),O=c("div"),A=c("p"),A.textContent=w,R=C(),ne=c("p"),U=M(H),J=C(),Y=c("div"),oe=c("h3"),oe.textContent=ge,ke=C(),Z.c(),Ie=C(),re=c("div"),_e=c("h3"),_e.textContent=Be,pe=C(),Le.c(),q=C(),se=c("div"),fe=c("h3"),fe.textContent=Ve,xe=C(),Ce.c(),ye=C(),X=c("div"),we=c("h3"),we.textContent=Me,y=C(),Se.c(),this.h()},l(G){e=i(G,"DIV",{class:!0});var ie=p(e);l=i(ie,"DIV",{class:!0});var ve=p(l);s=i(ve,"DIV",{class:!0});var De=p(s);n=i(De,"P",{class:!0,"data-svelte-h":!0}),$(n)!=="svelte-85t98o"&&(n.textContent=u),a=g(De),h=i(De,"P",{class:!0});var Je=p(h);m=S(Je,_),Je.forEach(d),De.forEach(d),v=g(ve),f=i(ve,"DIV",{class:!0});var Pe=p(f);b=i(Pe,"P",{class:!0,"data-svelte-h":!0}),$(b)!=="svelte-10wm6t0"&&(b.textContent=k),E=g(Pe),N=i(Pe,"P",{class:!0});var je=p(N);D=S(je,te),je.forEach(d),Pe.forEach(d),x=g(ve),L=i(ve,"DIV",{class:!0});var Ye=p(L);K=i(Ye,"P",{class:!0,"data-svelte-h":!0}),$(K)!=="svelte-1rp8gbm"&&(K.textContent=W),z=g(Ye),B=i(Ye,"P",{class:!0});var Oe=p(B);V=S(Oe,P),Oe.forEach(d),Ye.forEach(d),F=g(ve),O=i(ve,"DIV",{class:!0});var I=p(O);A=i(I,"P",{class:!0,"data-svelte-h":!0}),$(A)!=="svelte-hx77j6"&&(A.textContent=w),R=g(I),ne=i(I,"P",{class:!0});var Ee=p(ne);U=S(Ee,H),Ee.forEach(d),I.forEach(d),ve.forEach(d),J=g(ie),Y=i(ie,"DIV",{class:!0});var T=p(Y);oe=i(T,"H3",{class:!0,"data-svelte-h":!0}),$(oe)!=="svelte-tg6wul"&&(oe.textContent=ge),ke=g(T),Z.l(T),T.forEach(d),Ie=g(ie),re=i(ie,"DIV",{class:!0});var be=p(re);_e=i(be,"H3",{class:!0,"data-svelte-h":!0}),$(_e)!=="svelte-199k9g5"&&(_e.textContent=Be),pe=g(be),Le.l(be),be.forEach(d),q=g(ie),se=i(ie,"DIV",{class:!0});var Ze=p(se);fe=i(Ze,"H3",{class:!0,"data-svelte-h":!0}),$(fe)!=="svelte-q5gb1t"&&(fe.textContent=Ve),xe=g(Ze),Ce.l(Ze),Ze.forEach(d),ye=g(ie),X=i(ie,"DIV",{class:!0});var $e=p(X);we=i($e,"H3",{class:!0,"data-svelte-h":!0}),$(we)!=="svelte-1pp27mx"&&(we.textContent=Me),y=g($e),Se.l($e),$e.forEach(d),ie.forEach(d),this.h()},h(){var G;r(n,"class","text-xs text-surface-600"),r(h,"class","text-xl font-bold text-primary-600"),r(s,"class","card p-4 text-center"),r(b,"class","text-xs text-surface-600"),r(N,"class","text-xl font-bold text-surface-700"),r(f,"class","card p-4 text-center"),r(K,"class","text-xs text-surface-600"),r(B,"class",ae="text-xl font-bold "+(((G=o[4])==null?void 0:G.month_over_month_change)>=0?"text-red-600":"text-green-600")),r(L,"class","card p-4 text-center"),r(A,"class","text-xs text-surface-600"),r(ne,"class","text-xl font-bold text-surface-800"),r(O,"class","card p-4 text-center"),r(l,"class","lg:col-span-3 grid grid-cols-4 gap-3"),r(oe,"class","text-sm font-bold text-surface-800 mb-3"),r(Y,"class","card p-4"),r(_e,"class","text-sm font-bold text-surface-800 mb-3"),r(re,"class","card p-4"),r(fe,"class","text-sm font-bold text-surface-800 mb-3"),r(se,"class","card p-4"),r(we,"class","text-sm font-bold text-surface-800 mb-3"),r(X,"class","lg:col-span-3 card p-4"),r(e,"class","grid grid-cols-1 lg:grid-cols-3 gap-4")},m(G,ie){he(G,e,ie),t(e,l),t(l,s),t(s,n),t(s,a),t(s,h),t(h,m),t(l,v),t(l,f),t(f,b),t(f,E),t(f,N),t(N,D),t(l,x),t(l,L),t(L,K),t(L,z),t(L,B),t(B,V),t(l,F),t(l,O),t(O,A),t(O,R),t(O,ne),t(ne,U),t(e,J),t(e,Y),t(Y,oe),t(Y,ke),Z.m(Y,null),t(e,Ie),t(e,re),t(re,_e),t(re,pe),Le.m(re,null),t(e,q),t(e,se),t(se,fe),t(se,xe),Ce.m(se,null),t(e,ye),t(e,X),t(X,we),t(X,y),Se.m(X,null)},p(G,ie){var ve,De,Je,Pe,je;ie[0]&16&&_!==(_=((ve=G[4])!=null&&ve.this_month_total?me(G[4].this_month_total):"$0.00")+"")&&ee(m,_),ie[0]&16&&te!==(te=((De=G[4])!=null&&De.last_month_total?me(G[4].last_month_total):"$0.00")+"")&&ee(D,te),ie[0]&16&&P!==(P=((Je=G[4])==null?void 0:Je.month_over_month_change)!==void 0?`${G[4].month_over_month_change>0?"+":""}${G[4].month_over_month_change}%`:"0%")&&ee(V,P),ie[0]&16&&ae!==(ae="text-xl font-bold "+(((Pe=G[4])==null?void 0:Pe.month_over_month_change)>=0?"text-red-600":"text-green-600"))&&r(B,"class",ae),ie[0]&16&&H!==(H=((je=G[4])!=null&&je.all_time_total?me(G[4].all_time_total):"$0.00")+"")&&ee(U,H),ce===(ce=j(G,ie))&&Z?Z.p(G,ie):(Z.d(1),Z=ce(G),Z&&(Z.c(),Z.m(Y,null))),He===(He=Te(G,ie))&&Le?Le.p(G,ie):(Le.d(1),Le=He(G),Le&&(Le.c(),Le.m(re,null))),ze===(ze=Qe(G,ie))&&Ce?Ce.p(G,ie):(Ce.d(1),Ce=ze(G),Ce&&(Ce.c(),Ce.m(se,null))),Re===(Re=Ue(G))&&Se?Se.p(G,ie):(Se.d(1),Se=Re(G),Se&&(Se.c(),Se.m(X,null)))},d(G){G&&d(e),Z.d(),Le.d(),Ce.d(),Se.d()}}}function At(o){let e,l=o[64].name+"",s,n;return{c(){e=c("option"),s=M(l),this.h()},l(u){e=i(u,"OPTION",{});var a=p(e);s=S(a,l),a.forEach(d),this.h()},h(){e.__value=n=o[64].name,de(e,e.__value)},m(u,a){he(u,e,a),t(e,s)},p(u,a){a[0]&64&&l!==(l=u[64].name+"")&&ee(s,l),a[0]&64&&n!==(n=u[64].name)&&(e.__value=n,de(e,e.__value))},d(u){u&&d(e)}}}function ll(o){let e,l="No budget alerts configured. Create one to monitor your spending!";return{c(){e=c("div"),e.textContent=l,this.h()},l(s){e=i(s,"DIV",{class:!0,"data-svelte-h":!0}),$(e)!=="svelte-1va7skd"&&(e.textContent=l),this.h()},h(){r(e,"class","text-center py-12 text-surface-500")},m(s,n){he(s,e,n)},p:et,d(s){s&&d(e)}}}function sl(o){let e,l=Ae(o[18]),s=[];for(let n=0;n=100?"bg-red-500":o[78].percent_used>=80?"bg-orange-500":"bg-green-500")),ht(R,"width",Math.min(100,o[78].percent_used)+"%"),r(w,"class","w-full bg-white/50 rounded-full h-2"),r(U,"class","text-xs mt-1 opacity-80"),r(x,"class","mt-3"),r(e,"class",re="p-4 rounded-lg border "+Yt(o[78].status))},m(Q,q){he(Q,e,q),t(e,l),t(l,s),t(s,n),t(n,a),t(s,h),t(s,_),t(_,v),t(_,f),t(_,k),t(l,E),t(l,N),t(e,D),t(e,x),t(x,L),t(L,K),t(K,z),t(K,B),t(L,P),t(L,V),t(V,F),t(V,O),t(x,A),t(x,w),t(w,R),t(x,H),t(x,U),t(U,Y),t(U,oe),t(U,ke),t(U,le),t(e,Ie),_e||(Be=Ne(N,"click",pe),_e=!0)},p(Q,q){o=Q,q[0]&262144&&u!==(u=o[78].name+"")&&ee(a,u),q[0]&262144&&m!==(m=o[78].provider?`Provider: ${o[78].provider}`:"All providers")&&ee(v,m),q[0]&262144&&b!==(b=o[78].project?` | Project: ${o[78].project}`:"")&&ee(k,b),q[0]&262144&&W!==(W=me(o[78].current_spend)+"")&&ee(z,W),q[0]&262144&&ae!==(ae=me(o[78].monthly_limit)+"")&&ee(F,ae),q[0]&262144&&ne!==(ne="h-2 rounded-full transition-all "+(o[78].percent_used>=100?"bg-red-500":o[78].percent_used>=80?"bg-orange-500":"bg-green-500"))&&r(R,"class",ne),q[0]&262144&&ht(R,"width",Math.min(100,o[78].percent_used)+"%"),q[0]&262144&&J!==(J=o[78].percent_used.toFixed(1)+"")&&ee(Y,J),q[0]&262144&&ge!==(ge=me(o[78].remaining)+"")&&ee(ke,ge),q[0]&262144&&re!==(re="p-4 rounded-lg border "+Yt(o[78].status))&&r(e,"class",re)},d(Q){Q&&d(e),_e=!1,Be()}}}function Ot(o){var ke,le,Ie,re,_e,Be;let e,l,s,n="Cheapest Option",u,a,h=((ke=o[17].cheapest)==null?void 0:ke.provider)+"",_,m,v=((le=o[17].cheapest)==null?void 0:le.model)+"",f,b,k,E=me(((Ie=o[17].cheapest)==null?void 0:Ie.total_cost)||0)+"",N,te,D,x,L="Most Expensive",K,W,z=((re=o[17].most_expensive)==null?void 0:re.provider)+"",B,P,V=((_e=o[17].most_expensive)==null?void 0:_e.model)+"",ae,F,O,A=me(((Be=o[17].most_expensive)==null?void 0:Be.total_cost)||0)+"",w,R,ne,H,U="Potential Savings",J,Y,oe=me(o[17].savings_potential||0)+"",ge;return{c(){e=c("div"),l=c("div"),s=c("p"),s.textContent=n,u=C(),a=c("p"),_=M(h),m=M(" / "),f=M(v),b=C(),k=c("p"),N=M(E),te=C(),D=c("div"),x=c("p"),x.textContent=L,K=C(),W=c("p"),B=M(z),P=M(" / "),ae=M(V),F=C(),O=c("p"),w=M(A),R=C(),ne=c("div"),H=c("p"),H.textContent=U,J=C(),Y=c("p"),ge=M(oe),this.h()},l(pe){e=i(pe,"DIV",{class:!0});var Q=p(e);l=i(Q,"DIV",{class:!0});var q=p(l);s=i(q,"P",{class:!0,"data-svelte-h":!0}),$(s)!=="svelte-8c2gb8"&&(s.textContent=n),u=g(q),a=i(q,"P",{class:!0});var se=p(a);_=S(se,h),m=S(se," / "),f=S(se,v),se.forEach(d),b=g(q),k=i(q,"P",{class:!0});var fe=p(k);N=S(fe,E),fe.forEach(d),q.forEach(d),te=g(Q),D=i(Q,"DIV",{class:!0});var Ve=p(D);x=i(Ve,"P",{class:!0,"data-svelte-h":!0}),$(x)!=="svelte-z0lzb0"&&(x.textContent=L),K=g(Ve),W=i(Ve,"P",{class:!0});var xe=p(W);B=S(xe,z),P=S(xe," / "),ae=S(xe,V),xe.forEach(d),F=g(Ve),O=i(Ve,"P",{class:!0});var ue=p(O);w=S(ue,A),ue.forEach(d),Ve.forEach(d),R=g(Q),ne=i(Q,"DIV",{class:!0});var ye=p(ne);H=i(ye,"P",{class:!0,"data-svelte-h":!0}),$(H)!=="svelte-1llj33a"&&(H.textContent=U),J=g(ye),Y=i(ye,"P",{class:!0});var X=p(Y);ge=S(X,oe),X.forEach(d),ye.forEach(d),Q.forEach(d),this.h()},h(){r(s,"class","text-xs text-green-600"),r(a,"class","text-sm font-bold text-green-700"),r(k,"class","text-lg font-bold text-green-800"),r(l,"class","p-3 bg-green-50 rounded-lg border border-green-200"),r(x,"class","text-xs text-red-600"),r(W,"class","text-sm font-bold text-red-700"),r(O,"class","text-lg font-bold text-red-800"),r(D,"class","p-3 bg-red-50 rounded-lg border border-red-200"),r(H,"class","text-xs text-blue-600"),r(Y,"class","text-lg font-bold text-blue-800"),r(ne,"class","p-3 bg-blue-50 rounded-lg border border-blue-200"),r(e,"class","mt-4 space-y-2")},m(pe,Q){he(pe,e,Q),t(e,l),t(l,s),t(l,u),t(l,a),t(a,_),t(a,m),t(a,f),t(l,b),t(l,k),t(k,N),t(e,te),t(e,D),t(D,x),t(D,K),t(D,W),t(W,B),t(W,P),t(W,ae),t(D,F),t(D,O),t(O,w),t(e,R),t(e,ne),t(ne,H),t(ne,J),t(ne,Y),t(Y,ge)},p(pe,Q){var q,se,fe,Ve,xe,ue;Q[0]&131072&&h!==(h=((q=pe[17].cheapest)==null?void 0:q.provider)+"")&&ee(_,h),Q[0]&131072&&v!==(v=((se=pe[17].cheapest)==null?void 0:se.model)+"")&&ee(f,v),Q[0]&131072&&E!==(E=me(((fe=pe[17].cheapest)==null?void 0:fe.total_cost)||0)+"")&&ee(N,E),Q[0]&131072&&z!==(z=((Ve=pe[17].most_expensive)==null?void 0:Ve.provider)+"")&&ee(B,z),Q[0]&131072&&V!==(V=((xe=pe[17].most_expensive)==null?void 0:xe.model)+"")&&ee(ae,V),Q[0]&131072&&A!==(A=me(((ue=pe[17].most_expensive)==null?void 0:ue.total_cost)||0)+"")&&ee(w,A),Q[0]&131072&&oe!==(oe=me(pe[17].savings_potential||0)+"")&&ee(ge,oe)},d(pe){pe&&d(e)}}}function al(o){let e,l="Enter token counts and click Compare to see pricing across all providers";return{c(){e=c("div"),e.textContent=l,this.h()},l(s){e=i(s,"DIV",{class:!0,"data-svelte-h":!0}),$(e)!=="svelte-gwvzcu"&&(e.textContent=l),this.h()},h(){r(e,"class","text-center py-12 text-surface-500")},m(s,n){he(s,e,n)},p:et,d(s){s&&d(e)}}}function ol(o){let e,l,s,n='Provider Model Input Cost Output Cost Total',u,a,h=Ae(o[17].comparisons),_=[];for(let m=0;mo.amount;function pl(o,e,l){let s,n="dashboard",u=!1,a="",h=null,_=null,m=[],v="openai",f="",b="",k="",E="",N="default",te="",D=new Date().toISOString().split("T")[0],x="",L=1e6,K=5e5,W=null,z=[],B="",P="",V="",ae="",F=.8;Qt(async()=>{await Promise.all([O(),A(),w(),R()])});async function O(){try{const y=await fetch("http://localhost:8000/api/v1/costs/stats");y.ok&&l(4,h=await y.json())}catch(y){console.error("Failed to load stats:",y)}}async function A(){try{const y=await fetch("http://localhost:8000/api/v1/costs/summary");y.ok&&l(5,_=await y.json())}catch(y){console.error("Failed to load summary:",y)}}async function w(){try{const y=await fetch("http://localhost:8000/api/v1/costs/providers");if(y.ok){const j=await y.json();l(6,m=j.providers||[])}}catch(y){console.error("Failed to load providers:",y)}}async function R(){try{const y=await fetch("http://localhost:8000/api/v1/costs/alerts");if(y.ok){const j=await y.json();l(18,z=j.alerts||[])}}catch(y){console.error("Failed to load alerts:",y)}}async function ne(){if(!b){l(3,a="Please enter an amount");return}l(2,u=!0),l(3,a=""),l(14,x="");try{const y=await fetch("http://localhost:8000/api/v1/costs/log",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:v,model:f||null,amount:parseFloat(b),input_tokens:k?parseInt(k):null,output_tokens:E?parseInt(E):null,project:N,description:te||null,entry_date:D})});if(!y.ok){const ce=await y.json();throw new Error(ce.detail||"Failed to log cost")}const j=await y.json();l(14,x=`Cost logged: $${b} for ${v}`),l(8,b=""),l(9,k=""),l(10,E=""),l(12,te=""),await Promise.all([O(),A()])}catch(y){l(3,a=y instanceof Error?y.message:"Failed to log cost")}finally{l(2,u=!1)}}async function H(){l(2,u=!0),l(3,a="");try{const y=await fetch(`http://localhost:8000/api/v1/costs/compare-providers?input_tokens=${L}&output_tokens=${K}`);if(!y.ok)throw new Error("Failed to compare costs");l(17,W=await y.json())}catch(y){l(3,a=y instanceof Error?y.message:"Failed to compare costs")}finally{l(2,u=!1)}}async function U(){if(!B||!ae){l(3,a="Please enter alert name and limit");return}l(2,u=!0),l(3,a="");try{if(!(await fetch("http://localhost:8000/api/v1/costs/alerts",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:B,provider:P||null,project:V||null,monthly_limit:parseFloat(ae),alert_threshold:F})})).ok)throw new Error("Failed to create alert");l(19,B=""),l(20,P=""),l(21,V=""),l(22,ae=""),await R()}catch(y){l(3,a=y instanceof Error?y.message:"Failed to create alert")}finally{l(2,u=!1)}}async function J(y){try{await fetch(`http://localhost:8000/api/v1/costs/alerts/${y}`,{method:"DELETE"}),await R()}catch(j){console.error("Failed to delete alert:",j)}}function Y(y){const j=m.find(ce=>ce.name===y);return j?j.models.map(ce=>ce.name):[]}const oe=()=>l(1,n="dashboard"),ge=()=>l(1,n="log"),ke=()=>l(1,n="compare"),le=()=>l(1,n="alerts");function Ie(){v=vt(this),l(0,v),l(6,m)}function re(){f=vt(this),l(7,f),l(24,s),l(0,v)}function _e(){b=qe(this.value),l(8,b)}function Be(){D=this.value,l(13,D)}function pe(){k=qe(this.value),l(9,k)}function Q(){E=qe(this.value),l(10,E)}function q(){N=this.value,l(11,N)}function se(){te=this.value,l(12,te)}function fe(){L=qe(this.value),l(15,L)}function Ve(){K=qe(this.value),l(16,K)}function xe(){B=this.value,l(19,B)}function ue(){P=vt(this),l(20,P),l(6,m)}function ye(){V=this.value,l(21,V)}function X(){ae=qe(this.value),l(22,ae)}function we(){F=qe(this.value),l(23,F)}const Me=y=>J(y.id);return o.$$.update=()=>{o.$$.dirty[0]&1&&l(24,s=Y(v))},[v,n,u,a,h,_,m,f,b,k,E,N,te,D,x,L,K,W,z,B,P,V,ae,F,s,ne,H,U,J,oe,ge,ke,le,Ie,re,_e,Be,pe,Q,q,se,fe,Ve,xe,ue,ye,X,we,Me]}class gl extends Wt{constructor(e){super(),Xt(this,e,pl,_l,Kt,{},null,[-1,-1,-1])}}export{gl as component};