1import{s as me,e as g,t as K,k as P,c as p,a as v,b as $,d as f,o as W,S as Ue,f as u,i as x,g as _,B as ie,u as j,h as ee,n as we,H as ke,p as Re,j as he,q as ft,y as _e,P as ct,l as Ze,r as dt,R as Ke,v as ht,w as _t,x as mt,O as Oe,D as $e,E as et,A as Ae,C as Ne,Q as gt,N as tt}from"../chunks/vexCXLX9.js";import{S as ge,i as pe,t as M,g as ze,c as je,a as L,b as te,d as se,m as le,e as re,h as Ce,f as Me}from"../chunks/Cdll-xsj.js";import{e as Be}from"../chunks/DNXpXRYa.js";import{t as pt}from"../chunks/DT5uOxbm.js";import{g as vt}from"../chunks/vcqg7ZRj.js";import{c as bt,a as wt,u as kt,m as yt,e as Et}from"../chunks/DFca5BX5.js";import{c as Dt}from"../chunks/C-pQywFn.js";import{s as It}from"../chunks/BXo7R043.js";import{aG as Vt}from"../chunks/DQk9-YBX.js";import{C as Tt}from"../chunks/D8_ibWhm.js";import{P as Nt}from"../chunks/BM7xxx70.js";import{C as Ct}from"../chunks/B5WJB5_d.js";import{f as st,s as lt}from"../chunks/DOlMLN9E.js";function Bt(l){let e,s,t,r=l[4].t(l[0].role)+"",i,n,o,a,d,D,h,c,k,m='<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" class="w-5 h-5"><path stroke-linecap="round" stroke-linejoin="round" d="M15 12H9m12 0a9 9 0 1 1-18 0 9 9 0 0 1 18 0Z"></path></svg>',E,b;return{c(){e=g("div"),s=g("div"),t=g("div"),i=K(r),n=P(),o=g("div"),a=g("textarea"),h=P(),c=g("div"),k=g("button"),k.innerHTML=m,this.h()},l(w){e=p(w,"DIV",{class:!0});var I=v(e);s=p(I,"DIV",{class:!0});var B=v(s);t=p(B,"DIV",{class:!0});var S=v(t);i=$(S,r),S.forEach(f),B.forEach(f),n=W(I),o=p(I,"DIV",{class:!0});var N=v(o);a=p(N,"TEXTAREA",{id:!0,class:!0,placeholder:!0,rows:!0}),v(a).forEach(f),N.forEach(f),h=W(I),c=p(I,"DIV",{class:!0});var T=v(c);k=p(T,"BUTTON",{class:!0,"data-svelte-h":!0}),Ue(k)!=="svelte-7qrvne"&&(k.innerHTML=m),T.forEach(f),I.forEach(f),this.h()},h(){u(t,"class","px-2 py-1 text-sm font-semibold uppercase min-w-[6rem] text-left rounded-lg transition"),u(s,"class","flex items-start pt-1"),u(a,"id",d=l[0].role+"-"+l[1]+"-textarea"),u(a,"class","w-full bg-transparent outline-hidden rounded-lg p-2 text-sm resize-none overflow-hidden"),u(a,"placeholder",D=l[4].t("Enter {{role}} message here",{role:l[0].role==="user"?l[4].t("a user"):l[4].t("an assistant")})),u(a,"rows","1"),u(o,"class","flex-1"),u(k,"class","group-hover:text-gray-500 dark:text-gray-900 dark:hover:text-gray-300 transition"),u(c,"class","pt-1"),u(e,"class","flex gap-2 group")},m(w,I){x(w,e,I),_(e,s),_(s,t),_(t,i),_(e,n),_(e,o),_(o,a),l[6](a),ie(a,l[0].content),_(e,h),_(e,c),_(c,k),E||(b=[j(a,"input",l[7]),j(a,"focus",l[8]),j(a,"input",l[9]),j(k,"click",l[10])],E=!0)},p(w,[I]){I&17&&r!==(r=w[4].t(w[0].role)+"")&&ee(i,r),I&3&&d!==(d=w[0].role+"-"+w[1]+"-textarea")&&u(a,"id",d),I&17&&D!==(D=w[4].t("Enter {{role}} message here",{role:w[0].role==="user"?w[4].t("a user"):w[4].t("an assistant")}))&&u(a,"placeholder",D),I&1&&ie(a,w[0].content)},i:we,o:we,d(w){w&&f(e),l[6](null),E=!1,ke(b)}}}function Ht(l,e,s){let t;const r=Re("i18n");he(l,r,m=>s(4,t=m));let{message:i}=e,{idx:n}=e,{onDelete:o}=e,a;ft(()=>{s(3,a.style.height="",a),s(3,a.style.height=a.scrollHeight+"px",a)});function d(m){_e[m?"unshift":"push"](()=>{a=m,s(3,a)})}const D=m=>{s(3,a.style.height="",a),s(3,a.style.height=a.scrollHeight+"px",a)},h=m=>{s(3,a.style.height="",a),s(3,a.style.height=a.scrollHeight+"px",a)};function c(){i.content=this.value,s(0,i)}const k=()=>{o()};return l.$$set=m=>{"message"in m&&s(0,i=m.message),"idx"in m&&s(1,n=m.idx),"onDelete"in m&&s(2,o=m.onDelete)},[i,n,o,a,t,r,d,D,h,c,k]}class St extends ge{constructor(e){super(),pe(this,e,Ht,Bt,me,{message:0,idx:1,onDelete:2})}}function rt(l,e,s){const t=l.slice();return t[3]=e[s],t[5]=s,t}function at(l){let e,s;function t(){return l[1](l[5])}return e=new St({props:{message:l[3],idx:l[5],onDelete:t}}),{c(){te(e.$$.fragment)},l(r){se(e.$$.fragment,r)},m(r,i){le(e,r,i),s=!0},p(r,i){l=r;const n={};i&1&&(n.message=l[3]),i&1&&(n.onDelete=t),e.$set(n)},i(r){s||(M(e.$$.fragment,r),s=!0)},o(r){L(e.$$.fragment,r),s=!1},d(r){re(e,r)}}}function xt(l){let e,s,t=Be(l[0]),r=[];for(let n=0;n<t.length;n+=1)r[n]=at(rt(l,t,n));const i=n=>L(r[n],1,1,()=>
1{r[n]=null});return{c(){e=g("div");for(let n=0;n<r.length;n+=1)r[n].c();this.h()},l(n){e=p(n,"DIV",{class:!0});var o=v(e);for(let a=0;a<r.length;a+=1)r[a].l(o);o.forEach(f),this.h()},h(){u(e,"class","py-3 space-y-3")},m(n,o){x(n,e,o);for(let a=0;a<r.length;a+=1)r[a]&&r[a].m(e,null);s=!0},p(n,[o]){if(o&1){t=Be(n[0]);let a;for(a=0;a<t.length;a+=1){const d=rt(n,t,a);r[a]?(r[a].p(d,o),M(r[a],1)):(r[a]=at(d),r[a].c(),M(r[a],1),r[a].m(e,null))}for(ze(),a=t.length;a<r.length;a+=1)i(a);je()}},i(n){if(!s){for(let o=0;o<t.length;o+=1)M(r[o]);s=!0}},o(n){r=r.filter(Boolean);for(let o=0;o<r.length;o+=1)L(r[o]);s=!1},d(n){n&&f(e),ct(r,n)}}}function At(l,e,s){Re("i18n");let{messages:t=[]}=e;const r=i=>{s(0,t=t.filter((n,o)=>o!==i))};return l.$$set=i=>{"messages"in i&&s(0,t=i.messages)},[t,r]}class Mt extends ge{constructor(e){super(),pe(this,e,At,xt,me,{messages:0})}}function nt(l){let e,s,t,r,i,n,o,a,d,D,h;const c=l[6].default,k=dt(c,l,l[5],null);return{c(){e=g("div"),t=P(),r=g("div"),i=g("div"),k&&k.c(),this.h()},l(m){e=p(m,"DIV",{class:!0}),v(e).forEach(f),t=W(m),r=p(m,"DIV",{class:!0});var E=v(r);i=p(E,"DIV",{class:!0,style:!0});var b=v(i);k&&k.l(b),b.forEach(f),E.forEach(f),this.h()},h(){u(e,"class","absolute z-20 top-0 right-0 left-0 bottom-0 bg-white/20 dark:bg-black/5 w-full min-h-full h-full flex justify-center overflow-hidden overscroll-contain"),u(i,"class",n=l[3]+" h-full"),Ke(i,"width",l[0]?l[2]:"0px"),u(r,"class",o="absolute z-30 shadow-xl "+(l[1]==="right"?"right-0":"left-0")+" top-0 bottom-0")},m(m,E){x(m,e,E),x(m,t,E),x(m,r,E),_(r,i),k&&k.m(i,null),d=!0,D||(h=j(e,"mousedown",l[7]),D=!0)},p(m,E){l=m,k&&k.p&&(!d||E&32)&&ht(k,c,l,l[5],d?mt(c,l[5],E,null):_t(l[5]),null),(!d||E&8&&n!==(n=l[3]+" h-full"))&&u(i,"class",n),(!d||E&5)&&Ke(i,"width",l[0]?l[2]:"0px"),(!d||E&2&&o!==(o="absolute z-30 shadow-xl "+(l[1]==="right"?"right-0":"left-0")+" top-0 bottom-0"))&&u(r,"class",o)},i(m){d||(m&&Oe(()=>{d&&(s||(s=Ce(e,st,{duration:l[4]},!0)),s.run(1))}),M(k,m),m&&Oe(()=>{d&&(a||(a=Ce(r,lt,{duration:l[4],axis:l[1]==="right"?"x":"y"},!0)),a.run(1))}),d=!0)},o(m){m&&(s||(s=Ce(e,st,{duration:l[4]},!1)),s.run(0)),L(k,m),m&&(a||(a=Ce(r,lt,{duration:l[4],axis:l[1]==="right"?"x":"y"},!1)),a.run(0)),d=!1},d(m){m&&(f(e),f(t),f(r)),m&&s&&s.end(),k&&k.d(m),m&&a&&a.end(),D=!1,h()}}}function Ut(l){let e,s,t=l[0]&&nt(l);return{c(){t&&t.c(),e=Ze()},l(r){t&&t.l(r),e=Ze()},m(r,i){t&&t.m(r,i),x(r,e,i),s=!0},p(r,[i]){r[0]?t?(t.p(r,i),i&1&&M(t,1)):(t=nt(r),t.c(),M(t,1),t.m(e.parentNode,e)):t&&(ze(),L(t,1,1,()=>{t=null}),je())},i(r){s||(M(t),s=!0)},o(r){L(t),s=!1},d(r){r&&f(e),t&&t.d(r)}}}function Ot(l,e,s){let{$$slots:t={},$$scope:r}=e,{show:i=!1}=e,{side:n="right"}=e,{width:o="200px"}=e,{className:a=""}=e,{duration:d=100}=e;const D=()=>{s(0,i=!1)};return l.$$set=h=>{"show"in h&&s(0,i=h.show),"side"in h&&s(1,n=h.side),"width"in h&&s(2,o=h.width),"className"in h&&s(3,a=h.className),"duration"in h&&s(4,d=h.duration),"$$scope"in h&&s(5,r=h.$$scope)},[i,n,o,a,d,r,t,D]}class Rt extends ge{constructor(e){super(),pe(this,e,Ot,Ut,me,{show:0,side:1,width:2,className:3,duration:4})}}function zt(l){let e,s;return{c(){e=$e("svg"),s=$e("path"),this.h()},l(t){e=et(t,"svg",{xmlns:!0,fill:!0,viewBox:!0,"stroke-width":!0,stroke:!0,class:!0});var r=v(e);s=et(r,"path",{"stroke-linecap":!0,"stroke-linejoin":!0,d:!0}),v(s).forEach(f),r.forEach(f),this.h()},h(){u(s,"stroke-linecap","round"),u(s,"stroke-linejoin","round"),u(s,"d","M13.5 4.5 21 12m0 0-7.5 7.5M21 12H3"),u(e,"xmlns","http://www.w3.org/2000/svg"),u(e,"fill","none"),u(e,"viewBox","0 0 24 24"),u(e,"stroke-width",l[1]),u(e,"stroke","currentColor"),u(e,"class",l[0])},m(t,r){x(t,e,r),_(e,s)},p(t,[r]){r&2&&u(e,"stroke-width",t[1]),r&1&&u(e,"class",t[0])},i:we,o:we,d(t){t&&f(e)}}}function jt(l,e,s){let{className:t="size-4"}=e,{strokeWidth:r="1.5"}=e;return l.$$set=i=>{"className"in i&&s(0,t=i.className),"strokeWidth"in i&&s(1,r=i.strokeWidth)},[t,r]}class Pt extends ge{constructor(e){super(),pe(this,e,jt,zt,me,{className:0,strokeWidth:1})}}function ot(l,e,s){const t=l.slice();return t[41]=e[s],t}function it(l){let e,s=l[41].name+"",t,r;return{c(){e=g("option"),t=K(s),this.h()},l(i){e=p(i,"OPTION",{class:!0});var n=v(e);
1t=$(n,s),n.forEach(f),this.h()},h(){e.__value=r=l[41].id,ie(e,e.__value),u(e,"class","bg-gray-50 dark:bg-gray-700")},m(i,n){x(i,e,n),_(e,t)},p(i,n){n[0]&1024&&s!==(s=i[41].name+"")&&ee(t,s),n[0]&1024&&r!==(r=i[41].id)&&(e.__value=r,ie(e,e.__value))},d(i){i&&f(e)}}}function Wt(l){let e,s,t,r="Settings",i,n,o,a,d,D,h,c,k="Model",m,E,b,w,I,B;a=new Pt({props:{className:"size-3",strokeWidth:"2.5"}});let S=Be(l[10]),N=[];for(let T=0;T<S.length;T+=1)N[T]=it(ot(l,S,T));return{c(){e=g("div"),s=g("div"),t=g("div"),t.textContent=r,i=P(),n=g("div"),o=g("button"),te(a.$$.fragment),d=P(),D=g("div"),h=g("div"),c=g("div"),c.textContent=k,m=P(),E=g("div"),b=g("select");for(let T=0;T<N.length;T+=1)N[T].c();this.h()},l(T){e=p(T,"DIV",{class:!0});var U=v(e);s=p(U,"DIV",{class:!0});var C=v(s);t=p(C,"DIV",{class:!0,"data-svelte-h":!0}),Ue(t)!=="svelte-1dw76ku"&&(t.textContent=r),i=W(C),n=p(C,"DIV",{class:!0});var O=v(n);o=p(O,"BUTTON",{class:!0});var F=v(o);se(a.$$.fragment,F),F.forEach(f),O.forEach(f),C.forEach(f),d=W(U),D=p(U,"DIV",{class:!0});var A=v(D);h=p(A,"DIV",{});var G=v(h);c=p(G,"DIV",{class:!0,"data-svelte-h":!0}),Ue(c)!=="svelte-vz1bvh"&&(c.textContent=k),m=W(G),E=p(G,"DIV",{class:!0});var ae=v(E);b=p(ae,"SELECT",{class:!0});var X=v(b);for(let J=0;J<N.length;J+=1)N[J].l(X);X.forEach(f),ae.forEach(f),G.forEach(f),A.forEach(f),U.forEach(f),this.h()},h(){u(t,"class","font-medium text-base"),u(o,"class","p-1.5 bg-transparent hover:bg-white/5 transition rounded-lg"),u(n,"class","translate-x-1.5"),u(s,"class","flex justify-between items-center mb-2"),u(c,"class","text-xs font-medium mb-1"),u(b,"class","w-full bg-transparent border border-gray-100 dark:border-gray-850 rounded-lg py-1 px-2 -mx-0.5 text-sm outline-hidden"),l[1]===void 0&&Oe(()=>l[18].call(b)),u(E,"class","w-full"),u(D,"class","mt-1"),u(e,"class","flex flex-col px-5 py-3 text-sm")},m(T,U){x(T,e,U),_(e,s),_(s,t),_(s,i),_(s,n),_(n,o),le(a,o,null),_(e,d),_(e,D),_(D,h),_(h,c),_(h,m),_(h,E),_(E,b);for(let C=0;C<N.length;C+=1)N[C]&&N[C].m(b,null);tt(b,l[1],!0),w=!0,I||(B=[j(o,"click",l[17]),j(b,"change",l[18])],I=!0)},p(T,U){if(U[0]&1024){S=Be(T[10]);let C;for(C=0;C<S.length;C+=1){const O=ot(T,S,C);N[C]?N[C].p(O,U):(N[C]=it(O),N[C].c(),N[C].m(b,null))}for(;C<N.length;C+=1)N[C].d(1);N.length=S.length}U[0]&1026&&tt(b,T[1])},i(T){w||(M(a.$$.fragment,T),w=!0)},o(T){L(a.$$.fragment,T),w=!1},d(T){T&&f(e),re(a),ct(N,T),I=!1,ke(B)}}}function ut(l){let e,s;return{c(){e=g("div"),s=K(l[6]),this.h()},l(t){e=p(t,"DIV",{class:!0});var r=v(e);s=$(r,l[6]),r.forEach(f),this.h()},h(){u(e,"class","flex-1 text-gray-500 line-clamp-1")},m(t,r){x(t,e,r),_(e,s)},p(t,r){r[0]&64&&ee(s,t[6])},d(t){t&&f(e)}}}function Lt(l){let e,s;return e=new Nt({props:{className:"size-3.5"}}),{c(){te(e.$$.fragment)},l(t){se(e.$$.fragment,t)},m(t,r){le(e,t,r),s=!0},i(t){s||(M(e.$$.fragment,t),s=!0)},o(t){L(e.$$.fragment,t),s=!1},d(t){re(e,t)}}}function qt(l){let e,s;return e=new Tt({props:{className:"size-3.5"}}),{c(){te(e.$$.fragment)},l(t){se(e.$$.fragment,t)},m(t,r){le(e,t,r),s=!0},i(t){s||(M(e.$$.fragment,t),s=!0)},o(t){L(e.$$.fragment,t),s=!1},d(t){re(e,t)}}}function Xt(l){let e,s,t=l[11].t("System Instructions")+"",r,i,n,o,a,d,D,h,c=!l[0]&&ut(l);const k=[qt,Lt],m=[];function E(b,w){return b[0]?0:1}return d=E(l),D=m[d]=k[d](l),{c(){e=g("div"),s=g("div"),r=K(t),i=P(),c&&c.c(),n=P(),o=g("div"),a=g("button"),D.c(),this.h()},l(b){e=p(b,"DIV",{class:!0});var w=v(e);s=p(w,"DIV",{class:!0});var I=v(s);r=$(I,t),I.forEach(f),i=W(w),c&&c.l(w),n=W(w),o=p(w,"DIV",{class:!0});var B=v(o);a=p(B,"BUTTON",{class:!0});var S=v(a);D.l(S),S.forEach(f),B.forEach(f),w.forEach(f),this.h()},h(){u(s,"class","shrink-0 font-medium ml-1.5"),u(a,"class","p-1.5 bg-transparent hover:bg-white/5 transition rounded-lg"),u(o,"class","shrink-0"),u(e,"class","flex gap-2 justify-between items-center")},m(b,w){x(b,e,w),_(e,s),_(s,r),_(e,i),c&&c.m(e,null),_(e,n),_(e,o),_(o,a),m[d].m(a,null),h=!0},p(b,w){(!h||w[0]&2048)&&t!==(t=b[11].t("System Instructions")+"")&&ee(r,t),b[0]?c&&(c.d(1),c=null):c?c.p(b,w):(c=ut(b),c.c(),c.m(e,n));let I=d;d=E(b),d!==I&&(ze(),L(m[I],1,1,()=>{m[I]=null}),je(),D=m[d],D||(D=m[d]=k[d](b),D.c()),M(D,1),D.m(a,null))},i(b){h||(M(D),h=!0)},o(b){L(D),h=!1},d(b){b&&f(e),c&&c.d(),m[d].d()}}}function Yt(l){let e,s,t,r,i,n;return{c(){e=g("div"),s=g("div"),t=g("textarea"),this.h()},l(o){e=p(o,"DIV",{slot:!0});var a=v(e);s=p(a,"DIV",{class:!0});var d=v(s);t=p(d,"TEXTAREA",{class:!0,placeholder:!0,rows:!0}),v(t).forEach(f),d.forEach(f),a.forEach(f),this.h()},h(){u(t,"class","w-full h-full bg-transparent resize-none outline-hidden text-sm"),u(t,"placeholder",r=l[11].t("You're a helpful assistant.")),u(t,"rows","4"),u(s,"class","pt-1 px-1.5"),u(e,"slot","content")},m(o,a){x(o,e,a),_(e,s),_(s,t),l[20](t),ie(t,l[6]),i||(n=[j(t,"input",l[21]),j(t,"input",l[22])],i=!0)},p(o,a){a[0]&2048&&r!==(r=o[11].t("You're a helpful assistant."))&&u(t,"placeholder",r),a[0]&64&&ie(t,o[6])},d(o){o&&f(e),l[20](null),i=!1,ke(n)}}}function Ft(l){let e=l[11].t("Assistant")+"",s;return{c(){s=K(e)},l(t){s=$(t,e)},m(t,r){x(t,s,r)},p(t,r){r[0]&2048&&e!==(e=t[11].t("Assistant")+"")&&ee(s,e)},d(t){t&&f(s)}}}function Gt(l){let e=l[11].t("User")+"",s;return{c(){s=K(e)},l(t){s=$(t,e)},m(t,r){x(t,s,r)},p(t,r){r[0]&2048&&e!==(e=t[11].t("User")+"")&&ee(s,e)},d(t){t&&f(s)}}}function Jt(l){let e,s=l[11].t("Cancel")+"",t,r,i;return{c(){e=g("button"),t=K(s),this.h()},l(n){e=p(n,"BUTTON",{class:!0});var o=v(e);t=$(o,s),o.forEach(f),this.h()},h(){u(e,"class","px-3 py-1.5 text-sm font-medium bg-gray-300 text-black transition rounded-lg")},m(n,o){x(n,e,o),_(e,t),r||(i=j(e,"click",l[33]),r=!0)},p(n,o){o[0]&2048&&s!==(s=n[11].t("Cancel")+"")&&ee(t,s)},d(n){n&&f(e),r=!1,i()}}}function Qt(l){let e,s=l[11].t("Add")+"",t,r,i,n,o=l[11].t("Run")+"",a,d,D;return{c(){e=g("button"),t=K(s),i=P(),n=g("button"),a=K(o),this.h()},l(h){e=p(h,"BUTTON",{class:!0});var c=v(e);
1t=$(c,s),c.forEach(f),i=W(h),n=p(h,"BUTTON",{class:!0});var k=v(n);a=$(k,o),k.forEach(f),this.h()},h(){e.disabled=r=l[8]==="",u(e,"class","px-3.5 py-1.5 text-sm font-medium disabled:bg-gray-50 dark:disabled:hover:bg-gray-850 disabled:cursor-not-allowed bg-gray-50 hover:bg-gray-100 text-gray-900 dark:bg-gray-850 dark:hover:bg-gray-800 dark:text-gray-200 transition rounded-lg"),u(n,"class","px-3.5 py-1.5 text-sm font-medium bg-black hover:bg-gray-900 text-white dark:bg-white dark:text-black dark:hover:bg-gray-100 transition rounded-lg")},m(h,c){x(h,e,c),_(e,t),x(h,i,c),x(h,n,c),_(n,a),d||(D=[j(e,"click",l[31]),j(n,"click",l[32])],d=!0)},p(h,c){c[0]&2048&&s!==(s=h[11].t("Add")+"")&&ee(t,s),c[0]&256&&r!==(r=h[8]==="")&&(e.disabled=r),c[0]&2048&&o!==(o=h[11].t("Run")+"")&&ee(a,o)},d(h){h&&(f(e),f(i),f(n)),d=!1,ke(D)}}}function Zt(l){let e,s,t,r,i,n,o,a,d,D,h,c,k,m,E,b,w,I,B,S,N,T,U,C,O,F,A,G,ae,X,J,Z,ve,ne,oe,be,ye;function He(y){l[19](y)}let Ee={className:" bg-white dark:bg-gray-900",width:"300px",$$slots:{default:[Wt]},$$scope:{ctx:l}};l[5]!==void 0&&(Ee.show=l[5]),t=new Rt({props:Ee}),_e.push(()=>Me(t,"show",He));function Se(y){l[23](y)}let De={className:"w-full flex-1",buttonClassName:"w-full rounded-lg text-sm border border-gray-100 dark:border-gray-850 w-full py-1 px-1.5",grow:!0,$$slots:{content:[Yt],default:[Xt]},$$scope:{ctx:l}};l[0]!==void 0&&(De.open=l[0]),a=new Vt({props:De}),_e.push(()=>Me(a,"open",Se)),k=new Ct({});function xe(y){l[25](y)}let V={};l[9]!==void 0&&(V.messages=l[9]),I=new Mt({props:V}),_e.push(()=>Me(I,"messages",xe));function ce(y,H){return y[7]==="user"?Gt:Ft}let de=ce(l),R=de(l);function ue(y,H){return y[2]?Jt:Qt}let fe=ue(l),z=fe(l);return{c(){e=g("div"),s=g("div"),te(t.$$.fragment),i=P(),n=g("div"),o=g("div"),te(a.$$.fragment),D=P(),h=g("div"),c=g("button"),te(k.$$.fragment),m=P(),E=g("div"),b=g("div"),w=g("div"),te(I.$$.fragment),S=P(),N=g("div"),T=g("div"),U=K(l[1]),C=P(),O=g("div"),F=g("div"),A=g("textarea"),ae=P(),X=g("div"),J=g("div"),Z=g("button"),R.c(),ve=P(),ne=g("div"),z.c(),this.h()},l(y){e=p(y,"DIV",{class:!0});var H=v(e);s=p(H,"DIV",{class:!0});var Y=v(s);se(t.$$.fragment,Y),i=W(Y),n=p(Y,"DIV",{class:!0});var q=v(n);o=p(q,"DIV",{class:!0});var Q=v(o);se(a.$$.fragment,Q),D=W(Q),h=p(Q,"DIV",{class:!0});var Pe=v(h);c=p(Pe,"BUTTON",{class:!0});var We=v(c);se(k.$$.fragment,We),We.forEach(f),Pe.forEach(f),Q.forEach(f),m=W(q),E=p(q,"DIV",{class:!0,id:!0});var Le=v(E);b=p(Le,"DIV",{class:!0});var qe=v(b);w=p(qe,"DIV",{class:!0});var Xe=v(w);se(I.$$.fragment,Xe),Xe.forEach(f),qe.forEach(f),Le.forEach(f),S=W(q),N=p(q,"DIV",{class:!0});var Ie=v(N);T=p(Ie,"DIV",{class:!0});var Ye=v(T);U=$(Ye,l[1]),Ye.forEach(f),C=W(Ie),O=p(Ie,"DIV",{class:!0});var Ve=v(O);F=p(Ve,"DIV",{class:!0});var Fe=v(F);A=p(Fe,"TEXTAREA",{class:!0,placeholder:!0,rows:!0}),v(A).forEach(f),Fe.forEach(f),ae=W(Ve),X=p(Ve,"DIV",{class:!0});var Te=v(X);J=p(Te,"DIV",{});var Ge=v(J);Z=p(Ge,"BUTTON",{class:!0});var Je=v(Z);R.l(Je),Je.forEach(f),Ge.forEach(f),ve=W(Te),ne=p(Te,"DIV",{});var Qe=v(ne);z.l(Qe),Qe.forEach(f),Te.forEach(f),Ve.forEach(f),Ie.forEach(f),q.forEach(f),Y.forEach(f),H.forEach(f),this.h()},h(){u(c,"class","p-1.5 bg-transparent hover:bg-white/5 transition rounded-lg"),u(h,"class","translate-y-1"),u(o,"class","flex w-full items-start gap-1.5"),u(w,"class","flex-1 p-1"),u(b,"class","h-full w-full flex flex-col"),u(E,"class","pb-2.5 flex flex-col justify-between w-full flex-auto overflow-auto h-0"),u(E,"id","messages-container"),u(T,"class","text-xs font-medium text-gray-500 px-2 py-1"),u(A,"class","w-full h-full bg-transparent resize-none outline-hidden text-sm"),u(A,"placeholder",G=l[11].t("Enter {{role}} message here",{role:l[7]==="user"?l[11].t("a user"):l[11].t("an assistant")})),u(A,"rows","2"),u(F,"class","py-0.5"),u(Z,"class","px-3.5 py-1.5 text-sm font-medium bg-gray-50 hover:bg-gray-100 text-gray-900 dark:bg-gray-850 dark:hover:bg-gray-800 dark:text-gray-200 transition rounded-lg"),u(X,"class","flex justify-between"),u(O,"class","border border-gray-100 dark:border-gray-850 w-full px-3 py-2.5 rounded-xl"),u(N,"class","pb-3"),u(n,"class","flex flex-col h-full px-3.5"),u(s,"class","mx-auto w-full md:px-0 h-full relative"),u(e,"class","flex flex-col justify-between w-full overflow-y-auto h-full")},m(y,H){x(y,e,H),_(e,s),le(t,s,null),_(s,i),_(s,n),_(n,o),le(a,o,null),_(o,D),_(o,h),_(h,c),le(k,c,null),_(n,m),_(n,E),_(E,b),_(b,w),le(I,w,null),l[26](E),_(n,S),_(n,N),_(N,T),_(T,U),_(N,C
1),_(N,O),_(O,F),_(F,A),ie(A,l[8]),_(O,ae),_(O,X),_(X,J),_(J,Z),R.m(Z,null),_(X,ve),_(X,ne),z.m(ne,null),oe=!0,be||(ye=[j(c,"click",l[24]),j(A,"input",l[27]),j(A,"input",l[28]),j(A,"focus",l[29]),j(Z,"click",l[30])],be=!0)},p(y,H){const Y={};H[0]&1058|H[1]&8192&&(Y.$$scope={dirty:H,ctx:y}),!r&&H[0]&32&&(r=!0,Y.show=y[5],Ae(()=>r=!1)),t.$set(Y);const q={};H[0]&2121|H[1]&8192&&(q.$$scope={dirty:H,ctx:y}),!d&&H[0]&1&&(d=!0,q.open=y[0],Ae(()=>d=!1)),a.$set(q);const Q={};!B&&H[0]&512&&(B=!0,Q.messages=y[9],Ae(()=>B=!1)),I.$set(Q),(!oe||H[0]&2)&&ee(U,y[1]),(!oe||H[0]&2176&&G!==(G=y[11].t("Enter {{role}} message here",{role:y[7]==="user"?y[11].t("a user"):y[11].t("an assistant")})))&&u(A,"placeholder",G),H[0]&256&&ie(A,y[8]),de===(de=ce(y))&&R?R.p(y,H):(R.d(1),R=de(y),R&&(R.c(),R.m(Z,null))),fe===(fe=ue(y))&&z?z.p(y,H):(z.d(1),z=fe(y),z&&(z.c(),z.m(ne,null)))},i(y){oe||(M(t.$$.fragment,y),M(a.$$.fragment,y),M(k.$$.fragment,y),M(I.$$.fragment,y),oe=!0)},o(y){L(t.$$.fragment,y),L(a.$$.fragment,y),L(k.$$.fragment,y),L(I.$$.fragment,y),oe=!1},d(y){y&&f(e),re(t),re(a),re(k),re(I),l[26](null),R.d(),z.d(),be=!1,ke(ye)}}}function Kt(l,e,s){let t,r,i,n,o;he(l,bt,V=>s(36,t=V)),he(l,wt,V=>s(37,r=V)),he(l,kt,V=>s(38,i=V)),he(l,yt,V=>s(10,n=V));const a=Re("i18n");he(l,a,V=>s(11,o=V));let d="",D=!1,h=!1,c,k,m=!1,E=!1,b="",w="user",I="",B=[];const S=()=>{const V=k;V&&(V.scrollTop=V==null?void 0:V.scrollHeight)},N=()=>{h=!0,console.log("stopResponse")},T=async()=>{await Ne(),c&&(s(3,c.style.height="",c),s(3,c.style.height=Math.min(c.scrollHeight,555)+"px",c))},U=async()=>{var fe;if(d===""){pt.error(o.t("Please select a model."));return}const V=n.find(z=>z.id===d);if(!V){s(1,d="");return}const[ce,de]=await Dt(localStorage.token,{model:V.id,stream:!0,messages:[b?{role:"system",content:b}:void 0,...B].filter(z=>z)},`${Et}/api`);let R;((fe=B.at(-1))==null?void 0:fe.role)==="assistant"?R=B.at(-1):(R={role:"assistant",content:""},B.push(R),s(9,B)),await Ne();const ue=document.getElementById(`assistant-${B.length-1}-textarea`);if(ce&&ce.ok){const z=ce.body.pipeThrough(new TextDecoderStream).pipeThrough(It(` 2`)).getReader();for(;;){const{value:y,done:H}=await z.read();if(H||h){h&&de.abort("User: Stop Response");break}try{let Y=y.split(` 3`);for(const q of Y)if(q!=="")if(console.log(q),q==="data: [DONE]")s(9,B);else{let Q=JSON.parse(q.replace(/^data: /,""));if(console.log(Q),R.content==""&&Q.choices[0].delta.content==` 4`)continue;ue.style.height=ue.scrollHeight+"px",R.content+=Q.choices[0].delta.content??"",s(9,B),ue.style.height=ue.scrollHeight+"px",await Ne()}}catch(Y){console.log(Y)}S()}}},C=async()=>{I&&(B.push({role:w,content:I}),s(9,B),s(8,I=""),await Ne(),S())},O=async()=>{d&&(await C(),s(2,D=!0),await U(),s(2,D=!1),h=!1)};ft(async()=>{(i==null?void 0:i.role)!=="admin"&&await vt("/"),r!=null&&r.models?s(1,d=r==null?void 0:r.models[0]):t!=null&&t.default_models?s(1,d=t==null?void 0:t.default_models.split(",")[0]):s(1,d="")});const F=()=>{s(5,E=!E)};function A(){d=gt(this),s(1,d)}function G(V){E=V,s(5,E)}function ae(V){_e[V?"unshift":"push"](()=>{c=V,s(3,c)})}function X(){b=this.value,s(6,b)}const J=()=>{T()};function Z(V){m=V,s(0,m)}const ve=()=>{s(5,E=!E)};function ne(V){B=V,s(9,B)}function oe(V){_e[V?"unshift":"push"](()=>{k=V,s(4,k)})}function be(){I=this.value,s(8,I)}const ye=V=>{V.target.style.height="",V.target.style.height=Math.min(V.target.scrollHeight,150)+"px"},He=V=>{V.target.style.height="",V.target.style.height=Math.min(V.target.scrollHeight,150)+"px"},Ee=()=>{s(7,w=w==="user"?"assistant":"user")},Se=()=>{C(),s(7,w=w==="user"?"assistant":"user")},De=()=>{O()},xe=()=>{N()};return l.$$.update=()=>{l.$$.dirty[0]&1&&m&&T()},[m,d,D,c,k,E,b,w,I,B,n,o,a,N,T,C,O,F,A,G,ae,X,J,Z,ve,ne,oe,be,ye,He,Ee,Se,De,xe]}class $t extends ge{constructor(e){super(),pe(this,e,Kt,Zt,me,{},null,[-1,-1])}}function es(l){let e,s;return e=new $t({}),{c(){te(e.$$.fragment)},l(t){se(e.$$.fragment,t)},m(t,r){le(e,t,r),s=!0},p:we,i(t){s||(M(e.$$.fragment,t),s=!0)},o(t){L(e.$$.fragment,t),s=!1},d(t){re(e,t)}}}class _s extends ge{constructor(e){super(),pe(this,e,null,es,me,{})}}export{_s as component}; 5//# sourceMappingURL=18.BJajaWN-.js.map
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.