From 33b844fe5e60202ade907f4d3a9da23d7993d2cf Mon Sep 17 00:00:00 2001 From: morgan9e Date: Tue, 24 Jun 2025 05:24:11 +0000 Subject: [PATCH] deploy: 55a78b2a02c1f2358ac3d2cacd1c4971de32f2c5 --- assets/{index-fd273403.js => index-97ea1bbf.js} | 4 ++-- index.html | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) rename assets/{index-fd273403.js => index-97ea1bbf.js} (99%) diff --git a/assets/index-fd273403.js b/assets/index-97ea1bbf.js similarity index 99% rename from assets/index-fd273403.js rename to assets/index-97ea1bbf.js index 0889ada..b5489fa 100644 --- a/assets/index-fd273403.js +++ b/assets/index-97ea1bbf.js @@ -129,7 +129,7 @@ Initial scene: `;n.forEach(s=>{const o=s.role,I=s.content,m=`## ${o} ${I} -`;a+=m});const r=new Blob([a],{type:"text/markdown"}),c=URL.createObjectURL(r),i=document.createElement("a");i.download=`${t.name}.md`,i.href=c,document.body.appendChild(i),i.click(),document.body.removeChild(i)},nh=async l=>{const e=JSON.parse(JSON.stringify(Kn(l)));for(let c=0;c{const t=Tt(il).find(s=>s.id===l),n=JSON.parse(JSON.stringify(t.settings));Object.keys(a0()).forEach(s=>{delete n[s]});const a=JSON.stringify(n),r=new Blob([a],{type:"text/json"}),c=URL.createObjectURL(r),i=document.createElement("a");i.download=`${n.profileName}.json`,i.href=c,document.body.appendChild(i),i.click(),document.body.removeChild(i)};var Hs={};Object.defineProperty(Hs,"__esModule",{value:!0});var z1=Hs.clickOutside=void 0;function rh(l,e){var t=function(n){return l&&!l.contains(n.target)&&!n.defaultPrevented&&e()};return document.addEventListener("click",t,!0),{destroy:function(){document.removeEventListener("click",t,!0)}}}z1=Hs.clickOutside=rh;function b9(l){let e,t,n,a,r,c,i,s,o,I,m,u,p,R,E,W,X,f,Q,F,A,Y,J,k,ae,P,j,B,re,ge;function we(M,Ie){return M[3]?ih:ch}let Ae=we(l),x=Ae(l);return{c(){e=_("div"),t=_("div"),n=he(),a=_("div"),r=_("article"),c=_("div"),i=_("p"),s=ut(l[1]),o=he(),I=_("button"),m=he(),u=_("div"),x.c(),p=he(),R=_("div"),E=_("div"),W=_("div"),X=he(),f=_("div"),Q=_("div"),F=_("button"),A=ut(l[4]),J=he(),k=_("div"),ae=_("button"),P=ut(l[6]),h(t,"class","modal-background"),h(I,"class","delete"),h(I,"aria-label","close"),h(I,"type","button"),h(c,"class","message-header"),h(u,"class","message-body"),h(W,"class","level-right"),h(F,"class",Y="button "+l[5]),h(F,"type","button"),h(Q,"class","level-item"),h(ae,"class",j="button "+l[7]),h(ae,"type","button"),h(k,"class","level-item"),h(f,"class","level-right"),h(E,"class","level is-mobile"),h(R,"class","message-footer"),h(r,"class",B="message "+l[8]),h(a,"class","modal-content nomax"),h(e,"class","modal is-active")},m(M,Ie){D(M,e,Ie),V(e,t),V(e,n),V(e,a),V(a,r),V(r,c),V(c,i),V(i,s),V(c,o),V(c,I),V(r,m),V(r,u),x.m(u,null),V(r,p),V(r,R),V(R,E),V(E,W),V(E,X),V(E,f),V(f,Q),V(Q,F),V(F,A),V(f,J),V(f,k),V(k,ae),V(ae,P),re||(ge=[Qe(t,"click",l[9]),Qe(I,"click",l[9]),Qe(F,"click",l[10]),Qe(ae,"click",l[9]),Qe(e,"modal-esc",l[9])],re=!0)},p(M,Ie){Ie&2&&bl(s,M[1]),Ae===(Ae=we(M))&&x?x.p(M,Ie):(x.d(1),x=Ae(M),x&&(x.c(),x.m(u,null))),Ie&16&&bl(A,M[4]),Ie&32&&Y!==(Y="button "+M[5])&&h(F,"class",Y),Ie&64&&bl(P,M[6]),Ie&128&&j!==(j="button "+M[7])&&h(ae,"class",j),Ie&256&&B!==(B="message "+M[8])&&h(r,"class",B)},d(M){M&&z(e),x.d(),re=!1,Hl(ge)}}}function ch(l){let e;return{c(){e=ut(l[2])},m(t,n){D(t,e,n)},p(t,n){n&4&&bl(e,t[2])},d(t){t&&z(e)}}}function ih(l){let e,t;return{c(){e=new c2(!1),t=vt(),e.a=t},m(n,a){e.m(l[2],n,a),D(n,t,a)},p(n,a){a&4&&e.p(n[2])},d(n){n&&z(t),n&&e.d()}}}function sh(l){let e,t=l[0]&&b9(l);return{c(){t&&t.c(),e=vt()},m(n,a){t&&t.m(n,a),D(n,e,a)},p(n,[a]){n[0]?t?t.p(n,a):(t=b9(n),t.c(),t.m(e.parentNode,e)):t&&(t.d(1),t=null)},i:lt,o:lt,d(n){t&&t.d(n),n&&z(e)}}}function oh(l,e,t){let{isOpen:n}=e,{title:a}=e,{message:r}=e,{asHtml:c=!1}=e,{onConfirm:i}=e,{onCancel:s=null}=e,{confirmButton:o="Yes"}=e,{confirmButtonClass:I="is-info"}=e,{cancelButton:m="No"}=e,{cancelButtonClass:u=""}=e,{class:p=""}=e;const R=()=>{K2(),s&&s()},E=()=>{K2(),i()};return l.$$set=W=>{"isOpen"in W&&t(0,n=W.isOpen),"title"in W&&t(1,a=W.title),"message"in W&&t(2,r=W.message),"asHtml"in W&&t(3,c=W.asHtml),"onConfirm"in W&&t(11,i=W.onConfirm),"onCancel"in W&&t(12,s=W.onCancel),"confirmButton"in W&&t(4,o=W.confirmButton),"confirmButtonClass"in W&&t(5,I=W.confirmButtonClass),"cancelButton"in W&&t(6,m=W.cancelButton),"cancelButtonClass"in W&&t(7,u=W.cancelButtonClass),"class"in W&&t(8,p=W.class)},[n,a,r,c,o,I,m,u,p,R,E,i,s]}class Ka extends Ht{constructor(e){super(),Qt(this,e,oh,sh,yt,{isOpen:0,title:1,message:2,asHtml:3,onConfirm:11,onCancel:12,confirmButton:4,confirmButtonClass:5,cancelButton:6,cancelButtonClass:7,class:8})}}function Ih(l){let e,t,n,a;return t=new Rt({props:{icon:Q7}}),{c(){e=_("span"),fe(t.$$.fragment),n=ut(" Hide Summarized Messages"),h(e,"class","menu-icon")},m(r,c){D(r,e,c),Fe(t,e,null),D(r,n,c),a=!0},p:lt,i(r){a||(H(t.$$.fragment,r),a=!0)},o(r){L(t.$$.fragment,r),a=!1},d(r){r&&z(e),Ye(t),r&&z(n)}}}function dh(l){let e,t,n,a;return t=new Rt({props:{icon:L7}}),{c(){e=_("span"),fe(t.$$.fragment),n=ut(" Show Summarized Messages"),h(e,"class","menu-icon")},m(r,c){D(r,e,c),Fe(t,e,null),D(r,n,c),a=!0},p:lt,i(r){a||(H(t.$$.fragment,r),a=!0)},o(r){L(t.$$.fragment,r),a=!1},d(r){r&&z(e),Ye(t),r&&z(n)}}}function mh(l){let e,t,n,a,r,c,i,s,o,I,m,u,p,R,E,W,X,f,Q,F,A,Y,J,k,ae,P,j,B,re,ge,we,Ae,x,M,Ie,Xe,Ge,Ze,oe,_e,se,pe,Ee,Te,ue,bt,He,Ue,gt,ht,ye,tt,Et,Je,Ce,it,Zt,et,_t,kt,zt,Dt,ze,xe,Wt,Xt,Jt,ol,gl,Il,ct,Dl,Ml,Ct,De,Wl,cn,rl,Ll,sn,Tl,Cl,jl,ql,$l,xt,ll,at,Pt,nl,kl,Yn,Ln,on,Bl,ln,xn,wn,_l,en,pt,te,Oe,Ke,Bt,al,Fl,El,Jl,Nn,Zl,In,dn,fl,ka,qt;r=new Rt({props:{icon:Fs}}),m=new Rt({props:{icon:T7}}),f=new Rt({props:{icon:Xs}}),J=new Rt({props:{icon:th}}),B=new Rt({props:{icon:k7}}),Ie=new Rt({props:{icon:sG}}),_e=new Rt({props:{icon:oG}}),ue=new Rt({props:{icon:$G}}),tt=new Rt({props:{icon:w0}}),Zt=new Rt({props:{icon:V0}}),Dt=new Rt({props:{icon:mG}}),gl=new Rt({props:{icon:V0}}),Wl=new Rt({props:{icon:V0}}),Tl=new Rt({props:{icon:w0}}),at=new Rt({props:{icon:sr}}),Ln=new Rt({props:{icon:Pp}});const s2=[dh,Ih],Tn=[];function o2(Me,Rl){return Me[6].hideSummarized?0:1}return _l=o2(l),en=Tn[_l]=s2[_l](l),al=new Rt({props:{icon:H7}}),{c(){e=_("div"),t=_("div"),n=_("button"),a=_("span"),fe(r.$$.fragment),c=he(),i=_("div"),s=_("div"),o=_("a"),I=_("span"),fe(m.$$.fragment),u=ut(" Chat Profile Settings"),p=he(),R=_("hr"),E=he(),W=_("a"),X=_("span"),fe(f.$$.fragment),Q=ut(" New Chat from Default"),F=he(),A=_("a"),Y=_("span"),fe(J.$$.fragment),k=ut(" New Chat from Current"),ae=he(),P=_("a"),j=_("span"),fe(B.$$.fragment),re=ut(" Clone Chat"),ge=he(),we=_("hr"),Ae=he(),x=_("a"),M=_("span"),fe(Ie.$$.fragment),Xe=ut(" Restart Chat Session"),Ge=he(),Ze=_("a"),oe=_("span"),fe(_e.$$.fragment),se=ut(" Clear Chat Messages"),pe=he(),Ee=_("a"),Te=_("span"),fe(ue.$$.fragment),bt=ut(" Clear Chat Usage"),He=he(),Ue=_("hr"),gt=he(),ht=_("a"),ye=_("span"),fe(tt.$$.fragment),Et=ut(" Backup Chat JSON"),Je=he(),Ce=_("a"),it=_("span"),fe(Zt.$$.fragment),et=ut(" Restore Chat JSON"),_t=he(),kt=_("a"),zt=_("span"),fe(Dt.$$.fragment),ze=ut(" Export Chat Markdown"),xe=he(),Wt=_("hr"),Xt=he(),Jt=_("a"),ol=_("span"),fe(gl.$$.fragment),Il=ut(" Restore Profile JSON"),ct=he(),Dl=_("hr"),Ml=he(),Ct=_("a"),De=_("span"),fe(Wl.$$.fragment),cn=ut(" Dump All Data"),rl=he(),Ll=_("a"),sn=_("span"),fe(Tl.$$.fragment),Cl=ut(" Load All Data"),jl=he(),ql=_("hr"),$l=he(),xt=_("a"),ll=_("span"),fe(at.$$.fragment),Pt=ut(" Delete Chat"),nl=he(),kl=_("a"),Yn=_("span"),fe(Ln.$$.fragment),on=ut(" Delete ALL Chats"),Bl=he(),ln=_("hr"),xn=he(),wn=_("a"),en.c(),pt=he(),te=_("hr"),Oe=he(),Ke=_("a"),Bt=_("span"),fe(al.$$.fragment),Fl=ut(" API Setting"),Nn=he(),Zl=_("input"),In=he(),dn=_("input"),h(a,"class","icon "),h(n,"class","button is-ghost default-text"),h(n,"aria-haspopup","true"),h(n,"aria-controls","dropdown-menu3"),h(t,"class","dropdown-trigger"),h(I,"class","menu-icon"),h(o,"href","#"),h(o,"class","dropdown-item"),ve(o,"is-disabled",!l[0]),h(R,"class","dropdown-divider"),h(X,"class","menu-icon"),h(W,"href","#"),h(W,"class","dropdown-item"),ve(W,"is-disabled",!fn()),h(Y,"class","menu-icon"),h(A,"href","#"),h(A,"class","dropdown-item"),ve(A,"is-disabled",!l[0]),h(j,"class","menu-icon"),h(P,"href","#"),h(P,"class","dropdown-item"),ve(P,"is-disabled",!l[0]),h(we,"class","dropdown-divider"),h(M,"class","menu-icon"),h(x,"href","#"),h(x,"class","dropdown-item"),ve(x,"is-disabled",!l[0]),h(oe,"class","menu-icon"),h(Ze,"href","#"),h(Ze,"class","dropdown-item"),ve(Ze,"is-disabled",!l[0]),h(Te,"class","menu-icon"),h(Ee,"href","#"),h(Ee,"class","dropdown-item"),ve(Ee,"is-disabled",!l[0]),h(Ue,"class","dropdown-divider"),h(ye,"class","menu-icon"),h(ht,"href","#"),h(ht,"class","dropdown-item"),ve(ht,"is-disabled",!l[0]),h(it,"class","menu-icon"),h(Ce,"href","#"),h(Ce,"class","dropdown-item"),ve(Ce,"is-disabled",!fn()),h(zt,"class","menu-icon"),h(kt,"href","#"),h(kt,"class","dropdown-item"),ve(kt,"is-disabled",!l[0]),h(Wt,"class","dropdown-divider"),h(ol,"class","menu-icon"),h(Jt,"href","#"),h(Jt,"class","dropdown-item"),ve(Jt,"is-disabled",!fn()),h(Dl,"class","dropdown-divider"),h(De,"class","menu-icon"),h(Ct,"href","#"),h(Ct,"class","dropdown-item"),h(sn,"class","menu-icon"),h(Ll,"href","#"),h(Ll,"class","dropdown-item"),h(ql,"class","dropdown-divider"),h(ll,"class","menu-icon"),h(xt,"href","#"),h(xt,"class","dropdown-item"),ve(xt,"is-disabled",!l[0]),h(Yn,"class","menu-icon"),h(kl,"href","#"),h(kl,"class","dropdown-item"),ve(kl,"is-disabled",l[2]&&!l[2][0]),h(ln,"class","dropdown-divider"),h(wn,"href","#"),h(wn,"class","dropdown-item"),h(te,"class","dropdown-divider"),h(Bt,"class","menu-icon"),h(Ke,"href","#/"),h(Ke,"class","dropdown-item"),h(s,"class","dropdown-content"),h(i,"class","dropdown-menu"),h(i,"id","dropdown-menu3"),h(i,"role","menu"),h(e,"class",El="dropdown "+l[1]),ve(e,"is-active",l[3]),On(Zl,"display","none"),h(Zl,"type","file"),h(Zl,"accept",".json"),On(dn,"display","none"),h(dn,"type","file"),h(dn,"accept",".json")},m(Me,Rl){D(Me,e,Rl),V(e,t),V(t,n),V(n,a),Fe(r,a,null),V(e,c),V(e,i),V(i,s),V(s,o),V(o,I),Fe(m,I,null),V(o,u),V(s,p),V(s,R),V(s,E),V(s,W),V(W,X),Fe(f,X,null),V(W,Q),V(s,F),V(s,A),V(A,Y),Fe(J,Y,null),V(A,k),V(s,ae),V(s,P),V(P,j),Fe(B,j,null),V(P,re),V(s,ge),V(s,we),V(s,Ae),V(s,x),V(x,M),Fe(Ie,M,null),V(x,Xe),V(s,Ge),V(s,Ze),V(Ze,oe),Fe(_e,oe,null),V(Ze,se),V(s,pe),V(s,Ee),V(Ee,Te),Fe(ue,Te,null),V(Ee,bt),V(s,He),V(s,Ue),V(s,gt),V(s,ht),V(ht,ye),Fe(tt,ye,null),V(ht,Et),V(s,Je),V(s,Ce),V(Ce,it),Fe(Zt,it,null),V(Ce,et),V(s,_t),V(s,kt),V(kt,zt),Fe(Dt,zt,null),V(kt,ze),V(s,xe),V(s,Wt),V(s,Xt),V(s,Jt),V(Jt,ol),Fe(gl,ol,null),V(Jt,Il),V(s,ct),V(s,Dl),V(s,Ml),V(s,Ct),V(Ct,De),Fe(Wl,De,null),V(Ct,cn),V(s,rl),V(s,Ll),V(Ll,sn),Fe(Tl,sn,null),V(Ll,Cl),V(s,jl),V(s,ql),V(s,$l),V(s,xt),V(xt,ll),Fe(at,ll,null),V(xt,Pt),V(s,nl),V(s,kl),V(kl,Yn),Fe(Ln,Yn,null),V(kl,on),V(s,Bl),V(s,ln),V(s,xn),V(s,wn),Tn[_l].m(wn,null),V(s,pt),V(s,te),V(s,Oe),V(s,Ke),V(Ke,Bt),Fe(al,Bt,null),V(Ke,Fl),D(Me,Nn,Rl),D(Me,Zl,Rl),l[36](Zl),D(Me,In,Rl),D(Me,dn,Rl),l[38](dn),fl=!0,ka||(qt=[Qe(n,"click",g2(Vt(l[17]))),Qe(o,"click",Vt(l[18])),Qe(W,"click",Vt(l[19])),Qe(A,"click",Vt(l[20])),Qe(P,"click",Vt(l[21])),Qe(x,"click",Vt(l[22])),Qe(Ze,"click",Vt(l[23])),Qe(Ee,"click",Vt(l[24])),Qe(ht,"click",Vt(l[25])),Qe(Ce,"click",Vt(l[26])),Qe(kt,"click",Vt(l[27])),Qe(Jt,"click",Vt(l[28])),Qe(Ct,"click",Vt(l[29])),Qe(Ll,"click",Vt(l[30])),Qe(xt,"click",Vt(l[31])),Qe(kl,"click",Vt(l[32])),Qe(wn,"click",Vt(l[33])),Qe(Ke,"click",l[11]),Oi(Jl=z1.call(null,e,l[34])),Qe(Zl,"change",l[35]),Qe(dn,"change",l[37])],ka=!0)},p(Me,Rl){(!fl||Rl[0]&1)&&ve(o,"is-disabled",!Me[0]),(!fl||Rl[0]&1)&&ve(A,"is-disabled",!Me[0]),(!fl||Rl[0]&1)&&ve(P,"is-disabled",!Me[0]),(!fl||Rl[0]&1)&&ve(x,"is-disabled",!Me[0]),(!fl||Rl[0]&1)&&ve(Ze,"is-disabled",!Me[0]),(!fl||Rl[0]&1)&&ve(Ee,"is-disabled",!Me[0]),(!fl||Rl[0]&1)&&ve(ht,"is-disabled",!Me[0]),(!fl||Rl[0]&1)&&ve(kt,"is-disabled",!Me[0]),(!fl||Rl[0]&1)&&ve(xt,"is-disabled",!Me[0]),(!fl||Rl[0]&4)&&ve(kl,"is-disabled",Me[2]&&!Me[2][0]);let ta=_l;_l=o2(Me),_l===ta?Tn[_l].p(Me,Rl):(ot(),L(Tn[ta],1,1,()=>{Tn[ta]=null}),It(),en=Tn[_l],en?en.p(Me,Rl):(en=Tn[_l]=s2[_l](Me),en.c()),H(en,1),en.m(wn,null)),(!fl||Rl[0]&2&&El!==(El="dropdown "+Me[1]))&&h(e,"class",El),Jl&&$a(Jl.update)&&Rl[0]&8&&Jl.update.call(null,Me[34]),(!fl||Rl[0]&10)&&ve(e,"is-active",Me[3])},i(Me){fl||(H(r.$$.fragment,Me),H(m.$$.fragment,Me),H(f.$$.fragment,Me),H(J.$$.fragment,Me),H(B.$$.fragment,Me),H(Ie.$$.fragment,Me),H(_e.$$.fragment,Me),H(ue.$$.fragment,Me),H(tt.$$.fragment,Me),H(Zt.$$.fragment,Me),H(Dt.$$.fragment,Me),H(gl.$$.fragment,Me),H(Wl.$$.fragment,Me),H(Tl.$$.fragment,Me),H(at.$$.fragment,Me),H(Ln.$$.fragment,Me),H(en),H(al.$$.fragment,Me),fl=!0)},o(Me){L(r.$$.fragment,Me),L(m.$$.fragment,Me),L(f.$$.fragment,Me),L(J.$$.fragment,Me),L(B.$$.fragment,Me),L(Ie.$$.fragment,Me),L(_e.$$.fragment,Me),L(ue.$$.fragment,Me),L(tt.$$.fragment,Me),L(Zt.$$.fragment,Me),L(Dt.$$.fragment,Me),L(gl.$$.fragment,Me),L(Wl.$$.fragment,Me),L(Tl.$$.fragment,Me),L(at.$$.fragment,Me),L(Ln.$$.fragment,Me),L(en),L(al.$$.fragment,Me),fl=!1},d(Me){Me&&z(e),Ye(r),Ye(m),Ye(f),Ye(J),Ye(B),Ye(Ie),Ye(_e),Ye(ue),Ye(tt),Ye(Zt),Ye(Dt),Ye(gl),Ye(Wl),Ye(Tl),Ye(at),Ye(Ln),Tn[_l].d(),Ye(al),Me&&z(Nn),Me&&z(Zl),l[36](null),Me&&z(In),Me&&z(dn),l[38](null),ka=!1,Hl(qt)}}}function bh(){try{let l={};for(let i=0;it(6,a=ue)),tl(l,Dn,ue=>t(40,r=ue)),tl(l,pa,ue=>t(41,c=ue)),tl(l,il,ue=>t(2,i=ue)),tl(l,M1,ue=>t(7,s=ue));let{chatId:o}=e;const I=(ue=!0)=>{t(3,u=ue)};let{style:m="is-right"}=e,u=!1,p,R;const E=ue=>{f();const bt=ue.target.files[0];ue.target.value=null;const He=new FileReader;He.readAsText(bt),He.onload=Ue=>{const gt=(Ue.target||{}).result;AG(gt)}},W=()=>{f(),ma(Ka,{title:"Delete Chat",message:"Are you sure you want to delete this chat?",class:"is-warning",confirmButtonClass:"is-warning",confirmButton:"Delete Chat",onConfirm:()=>{const ue=Kn(o),bt=n.indexOf(ue),He=n[bt-1],gt=n[bt+1]||He;gt?ia(`/chat/${gt.id}`).then(()=>{z2(o)}):ia("/").then(()=>{z2(o)})}})},X=()=>{n.length&&(f(),ma(Ka,{title:"Delete ALL Chat",message:"Are you sure you want to delete ALL of your chats?",class:"is-danger",confirmButtonClass:"is-danger",confirmButton:"Delete ALL",onConfirm:()=>{ia("/").then(()=>{z2(o)}),fG()}}))},f=()=>{wl(pa,c=!1,c),t(3,u=!1)},Q=()=>{f(),q2(o),wl(Dn,r++,r)},F=()=>{f(),wa("hideSummarized",!a.hideSummarized)},A=()=>{ma(Ka,{title:"Clear Chat Usage",message:"Are you sure you want to clear your token usage stats for the current chat?",class:"is-warning",confirmButtonClass:"is-warning",confirmButton:"Clear Usage",onConfirm:()=>{const ue=Kn(o);ue.usage={},vn()}})},Y=ue=>{const bt=ue.target.files[0];ue.target.value=null;const He=new FileReader;He.onload=Ue=>{const gt=(Ue.target||{}).result;try{const ht=JSON.parse(gt);ht.profileName=U1(ht.profileName||""),ht.profile=null,w1(ht),ma(Ka,{title:"Profile Restored",class:"is-info",message:"Profile restored as:
"+Ku(ht.profileName)+"

Start new chat with this profile?",asHtml:!0,onConfirm:()=>{$i(o,ht)},onCancel:()=>{}})}catch(ht){hn("Unable to import profile:",ht)}},He.onerror=Ue=>{hn("Unable to import profile:",new Error("Unknown error"))},He.readAsText(bt)},J=()=>{t(3,u=!u)},k=()=>{o&&f(),wl(M1,s=!0,s)},ae=()=>{fn()&&f(),fn()&&$i()},P=()=>{o&&f(),o&&ju(o)},j=()=>{o&&f(),HG(o)},B=()=>{o&&Q()},re=()=>{o&&f(),tm(o)},ge=()=>{o&&f(),A()},we=()=>{f(),nh(o)},Ae=()=>{o&&f(),p.click()},x=()=>{o&&f(),lh(o)},M=()=>{o&&f(),R.click()},Ie=()=>{f(),bh()},Xe=()=>{o&&f(),ph(),uh()},Ge=()=>{o&&f(),W()},Ze=()=>{X()},oe=()=>{o&&F()},_e=()=>{t(3,u=!1)},se=ue=>E(ue);function pe(ue){_n[ue?"unshift":"push"](()=>{p=ue,t(4,p)})}const Ee=ue=>Y(ue);function Te(ue){_n[ue?"unshift":"push"](()=>{R=ue,t(5,R)})}return l.$$set=ue=>{"chatId"in ue&&t(0,o=ue.chatId),"style"in ue&&t(1,m=ue.style)},l.$$.update=()=>{l.$$.dirty[0]&4&&(n=i.sort((ue,bt)=>bt.id-ue.id))},[o,m,i,u,p,R,a,s,E,W,X,f,Q,F,A,Y,I,J,k,ae,P,j,B,re,ge,we,Ae,x,M,Ie,Xe,Ge,Ze,oe,_e,se,pe,Ee,Te]}class am extends Ht{constructor(e){super(),Qt(this,e,Gh,mh,yt,{chatId:0,show:16,style:1},null,[-1,-1])}get show(){return this.$$.ctx[16]}}function hh(l){let e,t,n,a,r,c;return n=new Rt({props:{icon:qp}}),{c(){e=_("button"),t=_("span"),fe(n.$$.fragment),h(t,"class","icon"),h(e,"class","button")},m(i,s){D(i,e,s),V(e,t),Fe(n,t,null),a=!0,r||(c=Qe(e,"click",g2(l[4])),r=!0)},p:lt,i(i){a||(H(n.$$.fragment,i),a=!0)},o(i){L(n.$$.fragment,i),a=!1},d(i){i&&z(e),Ye(n),r=!1,c()}}}function Zh(l){let e,t,n,a,r,c;return n=new Rt({props:{icon:IG}}),{c(){e=_("button"),t=_("span"),fe(n.$$.fragment),h(t,"class","icon"),h(e,"class","button")},m(i,s){D(i,e,s),V(e,t),Fe(n,t,null),a=!0,r||(c=Qe(e,"click",g2(l[3])),r=!0)},p:lt,i(i){a||(H(n.$$.fragment,i),a=!0)},o(i){L(n.$$.fragment,i),a=!1},d(i){i&&z(e),Ye(n),r=!1,c()}}}function Rh(l){let e,t,n,a,r,c,i,s,o,I,m,u,p,R,E,W;const X=[Zh,hh],f=[];function Q(Y,J){return Y[1]?0:1}a=Q(l),r=f[a]=X[a](l);function F(Y){l[5](Y)}let A={};return l[0]!==void 0&&(A.chatId=l[0]),R=new am({props:A}),_n.push(()=>_2(R,"chatId",F)),{c(){e=_("nav"),t=_("div"),n=_("div"),r.c(),c=he(),i=_("a"),s=_("img"),I=he(),m=_("p"),m.textContent="ChatGPT-web",u=he(),p=_("div"),fe(R.$$.fragment),h(n,"class","navbar-item"),e2(s.src,o=nm)||h(s,"src",o),h(s,"alt","ChatGPT-web"),h(s,"width","24"),h(s,"height","24"),h(m,"class","ml-2 is-size-6 has-text-weight-bold"),h(i,"class","navbar-item"),h(i,"href","#/"),h(p,"class","chat-option-menu navbar-item is-pulled-right"),h(t,"class","navbar-brand"),h(e,"class","navbar is-fixed-top"),h(e,"aria-label","main navigation")},m(Y,J){D(Y,e,J),V(e,t),V(t,n),f[a].m(n,null),V(t,c),V(t,i),V(i,s),V(i,I),V(i,m),V(t,u),V(t,p),Fe(R,p,null),W=!0},p(Y,[J]){let k=a;a=Q(Y),a===k?f[a].p(Y,J):(ot(),L(f[k],1,1,()=>{f[k]=null}),It(),r=f[a],r?r.p(Y,J):(r=f[a]=X[a](Y),r.c()),H(r,1),r.m(n,null));const ae={};!E&&J&1&&(E=!0,ae.chatId=Y[0],y2(()=>E=!1)),R.$set(ae)},i(Y){W||(H(r),H(R.$$.fragment,Y),W=!0)},o(Y){L(r),L(R.$$.fragment,Y),W=!1},d(Y){Y&&z(e),f[a].d(),Ye(R)}}}function Nh(l,e,t){let n,a,r;tl(l,T1,o=>t(2,a=o)),tl(l,pa,o=>t(1,r=o));const c=()=>{wl(pa,r=!1,r)},i=()=>{wl(pa,r=!0,r)};function s(o){n=o,t(0,n),t(2,a)}return l.$$.update=()=>{l.$$.dirty&4&&t(0,n=a&&a.chatId?parseInt(a.chatId):void 0)},[n,r,a,c,i,s]}class gh extends Ht{constructor(e){super(),Qt(this,e,Nh,Rh,yt,{})}}function Wh(l){let e,t,n,a,r,c,i=(l[0].name||`Chat ${l[0].id}`)+"",s,o,I,m,u;const p=[vh,Vh],R=[];function E(W,X){return W[3]?0:1}return t=E(l),n=R[t]=p[t](l),c=new Rt({props:{class:"mr-2 chat-icon",size:"xs",icon:qG}}),{c(){e=_("a"),n.c(),a=he(),r=_("span"),fe(c.$$.fragment),s=ut(i),h(r,"class","chat-item-name"),h(e,"href",o=`#/chat/${l[0].id}`),h(e,"class","chat-menu-item"),ve(e,"is-waiting",l[3]),ve(e,"is-disabled",!fn()),ve(e,"is-active",l[1]===l[0].id)},m(W,X){D(W,e,X),R[t].m(e,null),V(e,a),V(e,r),Fe(c,r,null),V(r,s),I=!0,m||(u=Qe(e,"click",l[15]),m=!0)},p(W,X){let f=t;t=E(W),t===f?R[t].p(W,X):(ot(),L(R[f],1,1,()=>{R[f]=null}),It(),n=R[t],n?n.p(W,X):(n=R[t]=p[t](W),n.c()),H(n,1),n.m(e,a)),(!I||X&1)&&i!==(i=(W[0].name||`Chat ${W[0].id}`)+"")&&bl(s,i),(!I||X&1&&o!==(o=`#/chat/${W[0].id}`))&&h(e,"href",o),(!I||X&8)&&ve(e,"is-waiting",W[3]),(!I||X&3)&&ve(e,"is-active",W[1]===W[0].id)},i(W){I||(H(n),H(c.$$.fragment,W),I=!0)},o(W){L(n),L(c.$$.fragment,W),I=!1},d(W){W&&z(e),R[t].d(),Ye(c),m=!1,u()}}}function Eh(l){let e,t,n,a;return{c(){e=_("div"),h(e,"id",t="chat-menu-item-"+l[0].id),h(e,"class","chat-name-editor"),h(e,"contenteditable",""),l[0].name===void 0&&Y0(()=>l[11].call(e))},m(r,c){D(r,e,c),l[0].name!==void 0&&(e.innerText=l[0].name),n||(a=[Qe(e,"keydown",l[5]),Qe(e,"input",l[11]),Qe(e,"blur",l[6])],n=!0)},p(r,c){c&1&&t!==(t="chat-menu-item-"+r[0].id)&&h(e,"id",t),c&1&&r[0].name!==e.innerText&&(e.innerText=r[0].name)},i:lt,o:lt,d(r){r&&z(e),n=!1,Hl(a)}}}function Vh(l){let e,t,n,a,r,c,i,s;return t=new Rt({props:{icon:jp}}),r=new Rt({props:{icon:sr}}),{c(){e=_("a"),fe(t.$$.fragment),n=he(),a=_("a"),fe(r.$$.fragment),h(e,"class","is-pulled-right is-hidden px-1 py-0 has-text-weight-bold edit-button"),h(e,"href","$"),h(a,"class","is-pulled-right is-hidden px-1 py-0 has-text-weight-bold delete-button"),h(a,"href","$")},m(o,I){D(o,e,I),Fe(t,e,null),D(o,n,I),D(o,a,I),Fe(r,a,null),c=!0,i||(s=[Qe(e,"click",Vt(l[13])),Qe(a,"click",Vt(l[14]))],i=!0)},p:lt,i(o){c||(H(t.$$.fragment,o),H(r.$$.fragment,o),c=!0)},o(o){L(t.$$.fragment,o),L(r.$$.fragment,o),c=!1},d(o){o&&z(e),Ye(t),o&&z(n),o&&z(a),Ye(r),i=!1,Hl(s)}}}function vh(l){let e,t,n,a,r;return t=new Rt({props:{icon:ir}}),{c(){e=_("a"),fe(t.$$.fragment),h(e,"class","is-pulled-right is-hidden px-1 py-0 has-text-weight-bold delete-button"),h(e,"href","$")},m(c,i){D(c,e,i),Fe(t,e,null),n=!0,a||(r=Qe(e,"click",Vt(l[12])),a=!0)},p:lt,i(c){n||(H(t.$$.fragment,c),n=!0)},o(c){L(t.$$.fragment,c),n=!1},d(c){c&&z(e),Ye(t),a=!1,r()}}}function yh(l){let e,t,n,a;const r=[Eh,Wh],c=[];function i(s,o){return s[2]?0:1}return t=i(l),n=c[t]=r[t](l),{c(){e=_("li"),n.c()},m(s,o){D(s,e,o),c[t].m(e,null),a=!0},p(s,[o]){let I=t;t=i(s),t===I?c[t].p(s,o):(ot(),L(c[I],1,1,()=>{c[I]=null}),It(),n=c[t],n?n.p(s,o):(n=c[t]=r[t](s),n.c()),H(n,1),n.m(e,null))},i(s){a||(H(n),a=!0)},o(s){L(n),a=!1},d(s){s&&z(e),c[t].d()}}}function _h(l,e,t){let n;tl(l,pa,F=>t(4,n=F));let{chat:a}=e,{activeChatId:r}=e,{prevChat:c}=e,{nextChat:i}=e,s=!1,o,I=0;sa(async()=>{a.name||t(0,a.name=`Chat ${a.id}`,a)});const m=F=>{F.key==="Escape"&&(F.stopPropagation(),F.preventDefault(),t(0,a.name=o,a),t(2,s=!1)),(F.key==="Tab"||F.key==="Enter")&&(F.stopPropagation(),F.preventDefault(),u())},u=()=>{if(t(2,s=!1),!a.name){t(0,a.name=o,a);return}vn()},p=()=>{if(!I){t(3,I=setTimeout(()=>{t(3,I=0)},1e3));return}if(clearTimeout(I),t(3,I=0),r===a.id){const F=i||c;F?ia(`/chat/${F.id}`).then(()=>{z2(a.id)}):ia("/").then(()=>{z2(a.id)})}else z2(a.id)},R=()=>{o=a.name,t(2,s=!0),setTimeout(()=>{const F=document.getElementById(`chat-menu-item-${a.id}`);F&&F.focus()},0)};function E(){a.name=this.innerText,t(0,a)}const W=()=>p(),X=()=>R(),f=()=>p(),Q=()=>{wl(pa,n=!1,n)};return l.$$set=F=>{"chat"in F&&t(0,a=F.chat),"activeChatId"in F&&t(1,r=F.activeChatId),"prevChat"in F&&t(9,c=F.prevChat),"nextChat"in F&&t(10,i=F.nextChat)},[a,r,s,I,n,m,u,p,R,c,i,E,W,X,f,Q]}class Xh extends Ht{constructor(e){super(),Qt(this,e,_h,yh,yt,{chat:0,activeChatId:1,prevChat:9,nextChat:10})}}function u9(l,e,t){const n=l.slice();return n[18]=e[t],n}function p9(l,e,t){const n=l.slice();return n[21]=e[t],n[23]=t,n}function Fh(l){let e=l[0],t,n,a=Z9(l);return{c(){a.c(),t=vt()},m(r,c){a.m(r,c),D(r,t,c),n=!0},p(r,c){c&1&&yt(e,e=r[0])?(ot(),L(a,1,1,lt),It(),a=Z9(r),a.c(),H(a,1),a.m(t.parentNode,t)):a.p(r,c)},i(r){n||(H(a),n=!0)},o(r){L(a),n=!1},d(r){r&&z(t),a.d(r)}}}function Yh(l){let e;return{c(){e=_("li"),e.innerHTML='No chats yet...'},m(t,n){D(t,e,n)},p:lt,i:lt,o:lt,d(t){t&&z(e)}}}function G9(l){let e,t;return e=new Xh({props:{activeChatId:l[5],chat:l[21],prevChat:l[4][l[23]-1],nextChat:l[4][l[23]+1]}}),{c(){fe(e.$$.fragment)},m(n,a){Fe(e,n,a),t=!0},p(n,a){const r={};a&32&&(r.activeChatId=n[5]),a&16&&(r.chat=n[21]),a&16&&(r.prevChat=n[4][n[23]-1]),a&16&&(r.nextChat=n[4][n[23]+1]),e.$set(r)},i(n){t||(H(e.$$.fragment,n),t=!0)},o(n){L(e.$$.fragment,n),t=!1},d(n){Ye(e,n)}}}function h9(l){let e=l[21].id,t,n,a=G9(l);return{c(){a.c(),t=vt()},m(r,c){a.m(r,c),D(r,t,c),n=!0},p(r,c){c&16&&yt(e,e=r[21].id)?(ot(),L(a,1,1,lt),It(),a=G9(r),a.c(),H(a,1),a.m(t.parentNode,t)):a.p(r,c)},i(r){n||(H(a),n=!0)},o(r){L(a),n=!1},d(r){r&&z(t),a.d(r)}}}function Z9(l){let e,t,n=l[4],a=[];for(let c=0;cL(a[c],1,1,()=>{a[c]=null});return{c(){for(let c=0;c_2(m,"chatId",He));const gt=[Yh,Fh],ht=[];function ye(et,_t){return et[4].length===0?0:1}E=ye(l),W=ht[E]=gt[E](l),k=new Rt({props:{icon:l[1].icon}});let tt=Object.values(j2),Et=[];for(let et=0;etL(Et[et],1,1,()=>{Et[et]=null});x=new Rt({props:{icon:V0}}),Ze=new Rt({props:{icon:w0}});const Ce=[Ah,wh],it=[];function Zt(et,_t){return et[2]?1:0}return se=Zt(l),pe=it[se]=Ce[se](l),{c(){e=_("aside"),t=_("div"),t.textContent="V25-06-15 21:23:21",n=he(),a=_("div"),r=_("div"),c=_("a"),i=_("img"),o=he(),I=_("div"),fe(m.$$.fragment),p=he(),R=_("ul"),W.c(),X=he(),f=_("div"),Q=_("div"),F=_("div"),A=_("div"),Y=_("button"),J=_("span"),fe(k.$$.fragment),ae=he(),P=_("div"),j=_("div");for(let et=0;etu=!1)),m.$set(kt);let zt=E;E=ye(et),E===zt?ht[E].p(et,_t):(ot(),L(ht[zt],1,1,()=>{ht[zt]=null}),It(),W=ht[E],W?W.p(et,_t):(W=ht[E]=gt[E](et),W.c()),H(W,1),W.m(R,null));const Dt={};if(_t&2&&(Dt.icon=et[1].icon),k.$set(Dt),_t&10){tt=Object.values(j2);let xe;for(xe=0;xe{it[ze]=null}),It(),pe=it[se],pe?pe.p(et,_t):(pe=it[se]=Ce[se](et),pe.c()),H(pe,1),pe.m(_e,null)),Ee&&$a(Ee.update)&&_t&64&&Ee.update.call(null,et[16]),(!Te||_t&64)&&ve(e,"pinned",et[6])},i(et){if(!Te){H(m.$$.fragment,et),H(W),H(k.$$.fragment,et);for(let _t=0;_tt(0,r=A)),tl(l,il,A=>t(7,c=A)),tl(l,T1,A=>t(8,i=A)),tl(l,pa,A=>t(6,s=A));let o=Pr(),I=fn();const m=(...A)=>{t(1,o=Pr()),t(4,n=c.sort(o.sortFn)),t(2,I=fn())};let u=!1;sa(()=>{});function p(A){a=A,t(5,a),t(8,i)}const R=()=>{t(3,u=!u)},E=A=>{t(3,u=!1),UG(A.value)},W=()=>{t(3,u=!1)},X=()=>{Qh()},f=()=>{Sh()},Q=()=>{wl(pa,s=!1,s),$i()},F=()=>{wl(pa,s=!1,s)};return l.$$.update=()=>{l.$$.dirty&128&&t(4,n=c.sort(Pr().sortFn)),l.$$.dirty&256&&t(5,a=i&&i.chatId?parseInt(i.chatId):void 0),l.$$.dirty&1&&m(r)},[r,o,I,u,n,a,s,c,i,p,R,E,W,X,f,Q,F]}class Lh extends Ht{constructor(e){super(),Qt(this,e,Hh,fh,yt,{})}}function Th(l){let e,t,n,a,r,c,i;const s=l[4].default,o=ul(s,l,l[3],null);return{c(){e=_("div"),t=he(),n=_("div"),a=he(),r=_("div"),o&&o.c(),h(e,"class","lower-mask section-footer-mask"),ve(e,"pin-footer",l[1]),h(n,"class","lower-mask2"),ve(n,"strong-mask",l[2]),h(r,"class",c="section-footer "+l[0]),ve(r,"pin-footer",l[1])},m(I,m){D(I,e,m),D(I,t,m),D(I,n,m),D(I,a,m),D(I,r,m),o&&o.m(r,null),i=!0},p(I,[m]){(!i||m&2)&&ve(e,"pin-footer",I[1]),(!i||m&4)&&ve(n,"strong-mask",I[2]),o&&o.p&&(!i||m&8)&&Gl(o,s,I,I[3],i?pl(s,I[3],m,null):hl(I[3]),null),(!i||m&1&&c!==(c="section-footer "+I[0]))&&h(r,"class",c),(!i||m&3)&&ve(r,"pin-footer",I[1])},i(I){i||(H(o,I),i=!0)},o(I){L(o,I),i=!1},d(I){I&&z(e),I&&z(t),I&&z(n),I&&z(a),I&&z(r),o&&o.d(I)}}}function Ch(l,e,t){let{$$slots:n={},$$scope:a}=e,{class:r=""}=e,{pin:c=!1}=e,{strongMask:i=!1}=e;return l.$$set=s=>{"class"in s&&t(0,r=s.class),"pin"in s&&t(1,c=s.pin),"strongMask"in s&&t(2,i=s.strongMask),"$$scope"in s&&t(3,a=s.$$scope)},[r,c,i,a,n]}class rm extends Ht{constructor(e){super(),Qt(this,e,Ch,Th,yt,{class:0,pin:1,strongMask:2})}}function N9(l){let e;return{c(){e=_("p"),e.innerHTML=`Please enter your OpenAI API key above to use Open AI's ChatGPT API. +`;a+=m});const r=new Blob([a],{type:"text/markdown"}),c=URL.createObjectURL(r),i=document.createElement("a");i.download=`${t.name}.md`,i.href=c,document.body.appendChild(i),i.click(),document.body.removeChild(i)},nh=async l=>{const e=JSON.parse(JSON.stringify(Kn(l)));for(let c=0;c{const t=Tt(il).find(s=>s.id===l),n=JSON.parse(JSON.stringify(t.settings));Object.keys(a0()).forEach(s=>{delete n[s]});const a=JSON.stringify(n),r=new Blob([a],{type:"text/json"}),c=URL.createObjectURL(r),i=document.createElement("a");i.download=`${n.profileName}.json`,i.href=c,document.body.appendChild(i),i.click(),document.body.removeChild(i)};var Hs={};Object.defineProperty(Hs,"__esModule",{value:!0});var z1=Hs.clickOutside=void 0;function rh(l,e){var t=function(n){return l&&!l.contains(n.target)&&!n.defaultPrevented&&e()};return document.addEventListener("click",t,!0),{destroy:function(){document.removeEventListener("click",t,!0)}}}z1=Hs.clickOutside=rh;function b9(l){let e,t,n,a,r,c,i,s,o,I,m,u,p,R,E,W,X,f,Q,F,A,Y,J,k,ae,P,j,B,re,ge;function we(M,Ie){return M[3]?ih:ch}let Ae=we(l),x=Ae(l);return{c(){e=_("div"),t=_("div"),n=he(),a=_("div"),r=_("article"),c=_("div"),i=_("p"),s=ut(l[1]),o=he(),I=_("button"),m=he(),u=_("div"),x.c(),p=he(),R=_("div"),E=_("div"),W=_("div"),X=he(),f=_("div"),Q=_("div"),F=_("button"),A=ut(l[4]),J=he(),k=_("div"),ae=_("button"),P=ut(l[6]),h(t,"class","modal-background"),h(I,"class","delete"),h(I,"aria-label","close"),h(I,"type","button"),h(c,"class","message-header"),h(u,"class","message-body"),h(W,"class","level-right"),h(F,"class",Y="button "+l[5]),h(F,"type","button"),h(Q,"class","level-item"),h(ae,"class",j="button "+l[7]),h(ae,"type","button"),h(k,"class","level-item"),h(f,"class","level-right"),h(E,"class","level is-mobile"),h(R,"class","message-footer"),h(r,"class",B="message "+l[8]),h(a,"class","modal-content nomax"),h(e,"class","modal is-active")},m(M,Ie){D(M,e,Ie),V(e,t),V(e,n),V(e,a),V(a,r),V(r,c),V(c,i),V(i,s),V(c,o),V(c,I),V(r,m),V(r,u),x.m(u,null),V(r,p),V(r,R),V(R,E),V(E,W),V(E,X),V(E,f),V(f,Q),V(Q,F),V(F,A),V(f,J),V(f,k),V(k,ae),V(ae,P),re||(ge=[Qe(t,"click",l[9]),Qe(I,"click",l[9]),Qe(F,"click",l[10]),Qe(ae,"click",l[9]),Qe(e,"modal-esc",l[9])],re=!0)},p(M,Ie){Ie&2&&bl(s,M[1]),Ae===(Ae=we(M))&&x?x.p(M,Ie):(x.d(1),x=Ae(M),x&&(x.c(),x.m(u,null))),Ie&16&&bl(A,M[4]),Ie&32&&Y!==(Y="button "+M[5])&&h(F,"class",Y),Ie&64&&bl(P,M[6]),Ie&128&&j!==(j="button "+M[7])&&h(ae,"class",j),Ie&256&&B!==(B="message "+M[8])&&h(r,"class",B)},d(M){M&&z(e),x.d(),re=!1,Hl(ge)}}}function ch(l){let e;return{c(){e=ut(l[2])},m(t,n){D(t,e,n)},p(t,n){n&4&&bl(e,t[2])},d(t){t&&z(e)}}}function ih(l){let e,t;return{c(){e=new c2(!1),t=vt(),e.a=t},m(n,a){e.m(l[2],n,a),D(n,t,a)},p(n,a){a&4&&e.p(n[2])},d(n){n&&z(t),n&&e.d()}}}function sh(l){let e,t=l[0]&&b9(l);return{c(){t&&t.c(),e=vt()},m(n,a){t&&t.m(n,a),D(n,e,a)},p(n,[a]){n[0]?t?t.p(n,a):(t=b9(n),t.c(),t.m(e.parentNode,e)):t&&(t.d(1),t=null)},i:lt,o:lt,d(n){t&&t.d(n),n&&z(e)}}}function oh(l,e,t){let{isOpen:n}=e,{title:a}=e,{message:r}=e,{asHtml:c=!1}=e,{onConfirm:i}=e,{onCancel:s=null}=e,{confirmButton:o="Yes"}=e,{confirmButtonClass:I="is-info"}=e,{cancelButton:m="No"}=e,{cancelButtonClass:u=""}=e,{class:p=""}=e;const R=()=>{K2(),s&&s()},E=()=>{K2(),i()};return l.$$set=W=>{"isOpen"in W&&t(0,n=W.isOpen),"title"in W&&t(1,a=W.title),"message"in W&&t(2,r=W.message),"asHtml"in W&&t(3,c=W.asHtml),"onConfirm"in W&&t(11,i=W.onConfirm),"onCancel"in W&&t(12,s=W.onCancel),"confirmButton"in W&&t(4,o=W.confirmButton),"confirmButtonClass"in W&&t(5,I=W.confirmButtonClass),"cancelButton"in W&&t(6,m=W.cancelButton),"cancelButtonClass"in W&&t(7,u=W.cancelButtonClass),"class"in W&&t(8,p=W.class)},[n,a,r,c,o,I,m,u,p,R,E,i,s]}class Ka extends Ht{constructor(e){super(),Qt(this,e,oh,sh,yt,{isOpen:0,title:1,message:2,asHtml:3,onConfirm:11,onCancel:12,confirmButton:4,confirmButtonClass:5,cancelButton:6,cancelButtonClass:7,class:8})}}function Ih(l){let e,t,n,a;return t=new Rt({props:{icon:Q7}}),{c(){e=_("span"),fe(t.$$.fragment),n=ut(" Hide Summarized Messages"),h(e,"class","menu-icon")},m(r,c){D(r,e,c),Fe(t,e,null),D(r,n,c),a=!0},p:lt,i(r){a||(H(t.$$.fragment,r),a=!0)},o(r){L(t.$$.fragment,r),a=!1},d(r){r&&z(e),Ye(t),r&&z(n)}}}function dh(l){let e,t,n,a;return t=new Rt({props:{icon:L7}}),{c(){e=_("span"),fe(t.$$.fragment),n=ut(" Show Summarized Messages"),h(e,"class","menu-icon")},m(r,c){D(r,e,c),Fe(t,e,null),D(r,n,c),a=!0},p:lt,i(r){a||(H(t.$$.fragment,r),a=!0)},o(r){L(t.$$.fragment,r),a=!1},d(r){r&&z(e),Ye(t),r&&z(n)}}}function mh(l){let e,t,n,a,r,c,i,s,o,I,m,u,p,R,E,W,X,f,Q,F,A,Y,J,k,ae,P,j,B,re,ge,we,Ae,x,M,Ie,Xe,Ge,Ze,oe,_e,se,pe,Ee,Te,ue,bt,He,Ue,gt,ht,ye,tt,Et,Je,Ce,it,Zt,et,_t,kt,zt,Dt,ze,xe,Wt,Xt,Jt,ol,gl,Il,ct,Dl,Ml,Ct,De,Wl,cn,rl,Ll,sn,Tl,Cl,jl,ql,$l,xt,ll,at,Pt,nl,kl,Yn,Ln,on,Bl,ln,xn,wn,_l,en,pt,te,Oe,Ke,Bt,al,Fl,El,Jl,Nn,Zl,In,dn,fl,ka,qt;r=new Rt({props:{icon:Fs}}),m=new Rt({props:{icon:T7}}),f=new Rt({props:{icon:Xs}}),J=new Rt({props:{icon:th}}),B=new Rt({props:{icon:k7}}),Ie=new Rt({props:{icon:sG}}),_e=new Rt({props:{icon:oG}}),ue=new Rt({props:{icon:$G}}),tt=new Rt({props:{icon:w0}}),Zt=new Rt({props:{icon:V0}}),Dt=new Rt({props:{icon:mG}}),gl=new Rt({props:{icon:V0}}),Wl=new Rt({props:{icon:V0}}),Tl=new Rt({props:{icon:w0}}),at=new Rt({props:{icon:sr}}),Ln=new Rt({props:{icon:Pp}});const s2=[dh,Ih],Tn=[];function o2(Me,Rl){return Me[6].hideSummarized?0:1}return _l=o2(l),en=Tn[_l]=s2[_l](l),al=new Rt({props:{icon:H7}}),{c(){e=_("div"),t=_("div"),n=_("button"),a=_("span"),fe(r.$$.fragment),c=he(),i=_("div"),s=_("div"),o=_("a"),I=_("span"),fe(m.$$.fragment),u=ut(" Chat Profile Settings"),p=he(),R=_("hr"),E=he(),W=_("a"),X=_("span"),fe(f.$$.fragment),Q=ut(" New Chat from Default"),F=he(),A=_("a"),Y=_("span"),fe(J.$$.fragment),k=ut(" New Chat from Current"),ae=he(),P=_("a"),j=_("span"),fe(B.$$.fragment),re=ut(" Clone Chat"),ge=he(),we=_("hr"),Ae=he(),x=_("a"),M=_("span"),fe(Ie.$$.fragment),Xe=ut(" Restart Chat Session"),Ge=he(),Ze=_("a"),oe=_("span"),fe(_e.$$.fragment),se=ut(" Clear Chat Messages"),pe=he(),Ee=_("a"),Te=_("span"),fe(ue.$$.fragment),bt=ut(" Clear Chat Usage"),He=he(),Ue=_("hr"),gt=he(),ht=_("a"),ye=_("span"),fe(tt.$$.fragment),Et=ut(" Backup Chat JSON"),Je=he(),Ce=_("a"),it=_("span"),fe(Zt.$$.fragment),et=ut(" Restore Chat JSON"),_t=he(),kt=_("a"),zt=_("span"),fe(Dt.$$.fragment),ze=ut(" Export Chat Markdown"),xe=he(),Wt=_("hr"),Xt=he(),Jt=_("a"),ol=_("span"),fe(gl.$$.fragment),Il=ut(" Restore Profile JSON"),ct=he(),Dl=_("hr"),Ml=he(),Ct=_("a"),De=_("span"),fe(Wl.$$.fragment),cn=ut(" Dump All Data"),rl=he(),Ll=_("a"),sn=_("span"),fe(Tl.$$.fragment),Cl=ut(" Load All Data"),jl=he(),ql=_("hr"),$l=he(),xt=_("a"),ll=_("span"),fe(at.$$.fragment),Pt=ut(" Delete Chat"),nl=he(),kl=_("a"),Yn=_("span"),fe(Ln.$$.fragment),on=ut(" Delete ALL Chats"),Bl=he(),ln=_("hr"),xn=he(),wn=_("a"),en.c(),pt=he(),te=_("hr"),Oe=he(),Ke=_("a"),Bt=_("span"),fe(al.$$.fragment),Fl=ut(" API Setting"),Nn=he(),Zl=_("input"),In=he(),dn=_("input"),h(a,"class","icon "),h(n,"class","button is-ghost default-text"),h(n,"aria-haspopup","true"),h(n,"aria-controls","dropdown-menu3"),h(t,"class","dropdown-trigger"),h(I,"class","menu-icon"),h(o,"href","#"),h(o,"class","dropdown-item"),ve(o,"is-disabled",!l[0]),h(R,"class","dropdown-divider"),h(X,"class","menu-icon"),h(W,"href","#"),h(W,"class","dropdown-item"),ve(W,"is-disabled",!fn()),h(Y,"class","menu-icon"),h(A,"href","#"),h(A,"class","dropdown-item"),ve(A,"is-disabled",!l[0]),h(j,"class","menu-icon"),h(P,"href","#"),h(P,"class","dropdown-item"),ve(P,"is-disabled",!l[0]),h(we,"class","dropdown-divider"),h(M,"class","menu-icon"),h(x,"href","#"),h(x,"class","dropdown-item"),ve(x,"is-disabled",!l[0]),h(oe,"class","menu-icon"),h(Ze,"href","#"),h(Ze,"class","dropdown-item"),ve(Ze,"is-disabled",!l[0]),h(Te,"class","menu-icon"),h(Ee,"href","#"),h(Ee,"class","dropdown-item"),ve(Ee,"is-disabled",!l[0]),h(Ue,"class","dropdown-divider"),h(ye,"class","menu-icon"),h(ht,"href","#"),h(ht,"class","dropdown-item"),ve(ht,"is-disabled",!l[0]),h(it,"class","menu-icon"),h(Ce,"href","#"),h(Ce,"class","dropdown-item"),ve(Ce,"is-disabled",!fn()),h(zt,"class","menu-icon"),h(kt,"href","#"),h(kt,"class","dropdown-item"),ve(kt,"is-disabled",!l[0]),h(Wt,"class","dropdown-divider"),h(ol,"class","menu-icon"),h(Jt,"href","#"),h(Jt,"class","dropdown-item"),ve(Jt,"is-disabled",!fn()),h(Dl,"class","dropdown-divider"),h(De,"class","menu-icon"),h(Ct,"href","#"),h(Ct,"class","dropdown-item"),h(sn,"class","menu-icon"),h(Ll,"href","#"),h(Ll,"class","dropdown-item"),h(ql,"class","dropdown-divider"),h(ll,"class","menu-icon"),h(xt,"href","#"),h(xt,"class","dropdown-item"),ve(xt,"is-disabled",!l[0]),h(Yn,"class","menu-icon"),h(kl,"href","#"),h(kl,"class","dropdown-item"),ve(kl,"is-disabled",l[2]&&!l[2][0]),h(ln,"class","dropdown-divider"),h(wn,"href","#"),h(wn,"class","dropdown-item"),h(te,"class","dropdown-divider"),h(Bt,"class","menu-icon"),h(Ke,"href","#/"),h(Ke,"class","dropdown-item"),h(s,"class","dropdown-content"),h(i,"class","dropdown-menu"),h(i,"id","dropdown-menu3"),h(i,"role","menu"),h(e,"class",El="dropdown "+l[1]),ve(e,"is-active",l[3]),On(Zl,"display","none"),h(Zl,"type","file"),h(Zl,"accept",".json"),On(dn,"display","none"),h(dn,"type","file"),h(dn,"accept",".json")},m(Me,Rl){D(Me,e,Rl),V(e,t),V(t,n),V(n,a),Fe(r,a,null),V(e,c),V(e,i),V(i,s),V(s,o),V(o,I),Fe(m,I,null),V(o,u),V(s,p),V(s,R),V(s,E),V(s,W),V(W,X),Fe(f,X,null),V(W,Q),V(s,F),V(s,A),V(A,Y),Fe(J,Y,null),V(A,k),V(s,ae),V(s,P),V(P,j),Fe(B,j,null),V(P,re),V(s,ge),V(s,we),V(s,Ae),V(s,x),V(x,M),Fe(Ie,M,null),V(x,Xe),V(s,Ge),V(s,Ze),V(Ze,oe),Fe(_e,oe,null),V(Ze,se),V(s,pe),V(s,Ee),V(Ee,Te),Fe(ue,Te,null),V(Ee,bt),V(s,He),V(s,Ue),V(s,gt),V(s,ht),V(ht,ye),Fe(tt,ye,null),V(ht,Et),V(s,Je),V(s,Ce),V(Ce,it),Fe(Zt,it,null),V(Ce,et),V(s,_t),V(s,kt),V(kt,zt),Fe(Dt,zt,null),V(kt,ze),V(s,xe),V(s,Wt),V(s,Xt),V(s,Jt),V(Jt,ol),Fe(gl,ol,null),V(Jt,Il),V(s,ct),V(s,Dl),V(s,Ml),V(s,Ct),V(Ct,De),Fe(Wl,De,null),V(Ct,cn),V(s,rl),V(s,Ll),V(Ll,sn),Fe(Tl,sn,null),V(Ll,Cl),V(s,jl),V(s,ql),V(s,$l),V(s,xt),V(xt,ll),Fe(at,ll,null),V(xt,Pt),V(s,nl),V(s,kl),V(kl,Yn),Fe(Ln,Yn,null),V(kl,on),V(s,Bl),V(s,ln),V(s,xn),V(s,wn),Tn[_l].m(wn,null),V(s,pt),V(s,te),V(s,Oe),V(s,Ke),V(Ke,Bt),Fe(al,Bt,null),V(Ke,Fl),D(Me,Nn,Rl),D(Me,Zl,Rl),l[36](Zl),D(Me,In,Rl),D(Me,dn,Rl),l[38](dn),fl=!0,ka||(qt=[Qe(n,"click",g2(Vt(l[17]))),Qe(o,"click",Vt(l[18])),Qe(W,"click",Vt(l[19])),Qe(A,"click",Vt(l[20])),Qe(P,"click",Vt(l[21])),Qe(x,"click",Vt(l[22])),Qe(Ze,"click",Vt(l[23])),Qe(Ee,"click",Vt(l[24])),Qe(ht,"click",Vt(l[25])),Qe(Ce,"click",Vt(l[26])),Qe(kt,"click",Vt(l[27])),Qe(Jt,"click",Vt(l[28])),Qe(Ct,"click",Vt(l[29])),Qe(Ll,"click",Vt(l[30])),Qe(xt,"click",Vt(l[31])),Qe(kl,"click",Vt(l[32])),Qe(wn,"click",Vt(l[33])),Qe(Ke,"click",l[11]),Oi(Jl=z1.call(null,e,l[34])),Qe(Zl,"change",l[35]),Qe(dn,"change",l[37])],ka=!0)},p(Me,Rl){(!fl||Rl[0]&1)&&ve(o,"is-disabled",!Me[0]),(!fl||Rl[0]&1)&&ve(A,"is-disabled",!Me[0]),(!fl||Rl[0]&1)&&ve(P,"is-disabled",!Me[0]),(!fl||Rl[0]&1)&&ve(x,"is-disabled",!Me[0]),(!fl||Rl[0]&1)&&ve(Ze,"is-disabled",!Me[0]),(!fl||Rl[0]&1)&&ve(Ee,"is-disabled",!Me[0]),(!fl||Rl[0]&1)&&ve(ht,"is-disabled",!Me[0]),(!fl||Rl[0]&1)&&ve(kt,"is-disabled",!Me[0]),(!fl||Rl[0]&1)&&ve(xt,"is-disabled",!Me[0]),(!fl||Rl[0]&4)&&ve(kl,"is-disabled",Me[2]&&!Me[2][0]);let ta=_l;_l=o2(Me),_l===ta?Tn[_l].p(Me,Rl):(ot(),L(Tn[ta],1,1,()=>{Tn[ta]=null}),It(),en=Tn[_l],en?en.p(Me,Rl):(en=Tn[_l]=s2[_l](Me),en.c()),H(en,1),en.m(wn,null)),(!fl||Rl[0]&2&&El!==(El="dropdown "+Me[1]))&&h(e,"class",El),Jl&&$a(Jl.update)&&Rl[0]&8&&Jl.update.call(null,Me[34]),(!fl||Rl[0]&10)&&ve(e,"is-active",Me[3])},i(Me){fl||(H(r.$$.fragment,Me),H(m.$$.fragment,Me),H(f.$$.fragment,Me),H(J.$$.fragment,Me),H(B.$$.fragment,Me),H(Ie.$$.fragment,Me),H(_e.$$.fragment,Me),H(ue.$$.fragment,Me),H(tt.$$.fragment,Me),H(Zt.$$.fragment,Me),H(Dt.$$.fragment,Me),H(gl.$$.fragment,Me),H(Wl.$$.fragment,Me),H(Tl.$$.fragment,Me),H(at.$$.fragment,Me),H(Ln.$$.fragment,Me),H(en),H(al.$$.fragment,Me),fl=!0)},o(Me){L(r.$$.fragment,Me),L(m.$$.fragment,Me),L(f.$$.fragment,Me),L(J.$$.fragment,Me),L(B.$$.fragment,Me),L(Ie.$$.fragment,Me),L(_e.$$.fragment,Me),L(ue.$$.fragment,Me),L(tt.$$.fragment,Me),L(Zt.$$.fragment,Me),L(Dt.$$.fragment,Me),L(gl.$$.fragment,Me),L(Wl.$$.fragment,Me),L(Tl.$$.fragment,Me),L(at.$$.fragment,Me),L(Ln.$$.fragment,Me),L(en),L(al.$$.fragment,Me),fl=!1},d(Me){Me&&z(e),Ye(r),Ye(m),Ye(f),Ye(J),Ye(B),Ye(Ie),Ye(_e),Ye(ue),Ye(tt),Ye(Zt),Ye(Dt),Ye(gl),Ye(Wl),Ye(Tl),Ye(at),Ye(Ln),Tn[_l].d(),Ye(al),Me&&z(Nn),Me&&z(Zl),l[36](null),Me&&z(In),Me&&z(dn),l[38](null),ka=!1,Hl(qt)}}}function bh(){try{let l={};for(let i=0;it(6,a=ue)),tl(l,Dn,ue=>t(40,r=ue)),tl(l,pa,ue=>t(41,c=ue)),tl(l,il,ue=>t(2,i=ue)),tl(l,M1,ue=>t(7,s=ue));let{chatId:o}=e;const I=(ue=!0)=>{t(3,u=ue)};let{style:m="is-right"}=e,u=!1,p,R;const E=ue=>{f();const bt=ue.target.files[0];ue.target.value=null;const He=new FileReader;He.readAsText(bt),He.onload=Ue=>{const gt=(Ue.target||{}).result;AG(gt)}},W=()=>{f(),ma(Ka,{title:"Delete Chat",message:"Are you sure you want to delete this chat?",class:"is-warning",confirmButtonClass:"is-warning",confirmButton:"Delete Chat",onConfirm:()=>{const ue=Kn(o),bt=n.indexOf(ue),He=n[bt-1],gt=n[bt+1]||He;gt?ia(`/chat/${gt.id}`).then(()=>{z2(o)}):ia("/").then(()=>{z2(o)})}})},X=()=>{n.length&&(f(),ma(Ka,{title:"Delete ALL Chat",message:"Are you sure you want to delete ALL of your chats?",class:"is-danger",confirmButtonClass:"is-danger",confirmButton:"Delete ALL",onConfirm:()=>{ia("/").then(()=>{z2(o)}),fG()}}))},f=()=>{wl(pa,c=!1,c),t(3,u=!1)},Q=()=>{f(),q2(o),wl(Dn,r++,r)},F=()=>{f(),wa("hideSummarized",!a.hideSummarized)},A=()=>{ma(Ka,{title:"Clear Chat Usage",message:"Are you sure you want to clear your token usage stats for the current chat?",class:"is-warning",confirmButtonClass:"is-warning",confirmButton:"Clear Usage",onConfirm:()=>{const ue=Kn(o);ue.usage={},vn()}})},Y=ue=>{const bt=ue.target.files[0];ue.target.value=null;const He=new FileReader;He.onload=Ue=>{const gt=(Ue.target||{}).result;try{const ht=JSON.parse(gt);ht.profileName=U1(ht.profileName||""),ht.profile=null,w1(ht),ma(Ka,{title:"Profile Restored",class:"is-info",message:"Profile restored as:
"+Ku(ht.profileName)+"

Start new chat with this profile?",asHtml:!0,onConfirm:()=>{$i(o,ht)},onCancel:()=>{}})}catch(ht){hn("Unable to import profile:",ht)}},He.onerror=Ue=>{hn("Unable to import profile:",new Error("Unknown error"))},He.readAsText(bt)},J=()=>{t(3,u=!u)},k=()=>{o&&f(),wl(M1,s=!0,s)},ae=()=>{fn()&&f(),fn()&&$i()},P=()=>{o&&f(),o&&ju(o)},j=()=>{o&&f(),HG(o)},B=()=>{o&&Q()},re=()=>{o&&f(),tm(o)},ge=()=>{o&&f(),A()},we=()=>{f(),nh(o)},Ae=()=>{o&&f(),p.click()},x=()=>{o&&f(),lh(o)},M=()=>{o&&f(),R.click()},Ie=()=>{f(),bh()},Xe=()=>{o&&f(),ph(),uh()},Ge=()=>{o&&f(),W()},Ze=()=>{X()},oe=()=>{o&&F()},_e=()=>{t(3,u=!1)},se=ue=>E(ue);function pe(ue){_n[ue?"unshift":"push"](()=>{p=ue,t(4,p)})}const Ee=ue=>Y(ue);function Te(ue){_n[ue?"unshift":"push"](()=>{R=ue,t(5,R)})}return l.$$set=ue=>{"chatId"in ue&&t(0,o=ue.chatId),"style"in ue&&t(1,m=ue.style)},l.$$.update=()=>{l.$$.dirty[0]&4&&(n=i.sort((ue,bt)=>bt.id-ue.id))},[o,m,i,u,p,R,a,s,E,W,X,f,Q,F,A,Y,I,J,k,ae,P,j,B,re,ge,we,Ae,x,M,Ie,Xe,Ge,Ze,oe,_e,se,pe,Ee,Te]}class am extends Ht{constructor(e){super(),Qt(this,e,Gh,mh,yt,{chatId:0,show:16,style:1},null,[-1,-1])}get show(){return this.$$.ctx[16]}}function hh(l){let e,t,n,a,r,c;return n=new Rt({props:{icon:qp}}),{c(){e=_("button"),t=_("span"),fe(n.$$.fragment),h(t,"class","icon"),h(e,"class","button")},m(i,s){D(i,e,s),V(e,t),Fe(n,t,null),a=!0,r||(c=Qe(e,"click",g2(l[4])),r=!0)},p:lt,i(i){a||(H(n.$$.fragment,i),a=!0)},o(i){L(n.$$.fragment,i),a=!1},d(i){i&&z(e),Ye(n),r=!1,c()}}}function Zh(l){let e,t,n,a,r,c;return n=new Rt({props:{icon:IG}}),{c(){e=_("button"),t=_("span"),fe(n.$$.fragment),h(t,"class","icon"),h(e,"class","button")},m(i,s){D(i,e,s),V(e,t),Fe(n,t,null),a=!0,r||(c=Qe(e,"click",g2(l[3])),r=!0)},p:lt,i(i){a||(H(n.$$.fragment,i),a=!0)},o(i){L(n.$$.fragment,i),a=!1},d(i){i&&z(e),Ye(n),r=!1,c()}}}function Rh(l){let e,t,n,a,r,c,i,s,o,I,m,u,p,R,E,W;const X=[Zh,hh],f=[];function Q(Y,J){return Y[1]?0:1}a=Q(l),r=f[a]=X[a](l);function F(Y){l[5](Y)}let A={};return l[0]!==void 0&&(A.chatId=l[0]),R=new am({props:A}),_n.push(()=>_2(R,"chatId",F)),{c(){e=_("nav"),t=_("div"),n=_("div"),r.c(),c=he(),i=_("a"),s=_("img"),I=he(),m=_("p"),m.textContent="ChatGPT-web",u=he(),p=_("div"),fe(R.$$.fragment),h(n,"class","navbar-item"),e2(s.src,o=nm)||h(s,"src",o),h(s,"alt","ChatGPT-web"),h(s,"width","24"),h(s,"height","24"),h(m,"class","ml-2 is-size-6 has-text-weight-bold"),h(i,"class","navbar-item"),h(i,"href","#/"),h(p,"class","chat-option-menu navbar-item is-pulled-right"),h(t,"class","navbar-brand"),h(e,"class","navbar is-fixed-top"),h(e,"aria-label","main navigation")},m(Y,J){D(Y,e,J),V(e,t),V(t,n),f[a].m(n,null),V(t,c),V(t,i),V(i,s),V(i,I),V(i,m),V(t,u),V(t,p),Fe(R,p,null),W=!0},p(Y,[J]){let k=a;a=Q(Y),a===k?f[a].p(Y,J):(ot(),L(f[k],1,1,()=>{f[k]=null}),It(),r=f[a],r?r.p(Y,J):(r=f[a]=X[a](Y),r.c()),H(r,1),r.m(n,null));const ae={};!E&&J&1&&(E=!0,ae.chatId=Y[0],y2(()=>E=!1)),R.$set(ae)},i(Y){W||(H(r),H(R.$$.fragment,Y),W=!0)},o(Y){L(r),L(R.$$.fragment,Y),W=!1},d(Y){Y&&z(e),f[a].d(),Ye(R)}}}function Nh(l,e,t){let n,a,r;tl(l,T1,o=>t(2,a=o)),tl(l,pa,o=>t(1,r=o));const c=()=>{wl(pa,r=!1,r)},i=()=>{wl(pa,r=!0,r)};function s(o){n=o,t(0,n),t(2,a)}return l.$$.update=()=>{l.$$.dirty&4&&t(0,n=a&&a.chatId?parseInt(a.chatId):void 0)},[n,r,a,c,i,s]}class gh extends Ht{constructor(e){super(),Qt(this,e,Nh,Rh,yt,{})}}function Wh(l){let e,t,n,a,r,c,i=(l[0].name||`Chat ${l[0].id}`)+"",s,o,I,m,u;const p=[vh,Vh],R=[];function E(W,X){return W[3]?0:1}return t=E(l),n=R[t]=p[t](l),c=new Rt({props:{class:"mr-2 chat-icon",size:"xs",icon:qG}}),{c(){e=_("a"),n.c(),a=he(),r=_("span"),fe(c.$$.fragment),s=ut(i),h(r,"class","chat-item-name"),h(e,"href",o=`#/chat/${l[0].id}`),h(e,"class","chat-menu-item"),ve(e,"is-waiting",l[3]),ve(e,"is-disabled",!fn()),ve(e,"is-active",l[1]===l[0].id)},m(W,X){D(W,e,X),R[t].m(e,null),V(e,a),V(e,r),Fe(c,r,null),V(r,s),I=!0,m||(u=Qe(e,"click",l[15]),m=!0)},p(W,X){let f=t;t=E(W),t===f?R[t].p(W,X):(ot(),L(R[f],1,1,()=>{R[f]=null}),It(),n=R[t],n?n.p(W,X):(n=R[t]=p[t](W),n.c()),H(n,1),n.m(e,a)),(!I||X&1)&&i!==(i=(W[0].name||`Chat ${W[0].id}`)+"")&&bl(s,i),(!I||X&1&&o!==(o=`#/chat/${W[0].id}`))&&h(e,"href",o),(!I||X&8)&&ve(e,"is-waiting",W[3]),(!I||X&3)&&ve(e,"is-active",W[1]===W[0].id)},i(W){I||(H(n),H(c.$$.fragment,W),I=!0)},o(W){L(n),L(c.$$.fragment,W),I=!1},d(W){W&&z(e),R[t].d(),Ye(c),m=!1,u()}}}function Eh(l){let e,t,n,a;return{c(){e=_("div"),h(e,"id",t="chat-menu-item-"+l[0].id),h(e,"class","chat-name-editor"),h(e,"contenteditable",""),l[0].name===void 0&&Y0(()=>l[11].call(e))},m(r,c){D(r,e,c),l[0].name!==void 0&&(e.innerText=l[0].name),n||(a=[Qe(e,"keydown",l[5]),Qe(e,"input",l[11]),Qe(e,"blur",l[6])],n=!0)},p(r,c){c&1&&t!==(t="chat-menu-item-"+r[0].id)&&h(e,"id",t),c&1&&r[0].name!==e.innerText&&(e.innerText=r[0].name)},i:lt,o:lt,d(r){r&&z(e),n=!1,Hl(a)}}}function Vh(l){let e,t,n,a,r,c,i,s;return t=new Rt({props:{icon:jp}}),r=new Rt({props:{icon:sr}}),{c(){e=_("a"),fe(t.$$.fragment),n=he(),a=_("a"),fe(r.$$.fragment),h(e,"class","is-pulled-right is-hidden px-1 py-0 has-text-weight-bold edit-button"),h(e,"href","$"),h(a,"class","is-pulled-right is-hidden px-1 py-0 has-text-weight-bold delete-button"),h(a,"href","$")},m(o,I){D(o,e,I),Fe(t,e,null),D(o,n,I),D(o,a,I),Fe(r,a,null),c=!0,i||(s=[Qe(e,"click",Vt(l[13])),Qe(a,"click",Vt(l[14]))],i=!0)},p:lt,i(o){c||(H(t.$$.fragment,o),H(r.$$.fragment,o),c=!0)},o(o){L(t.$$.fragment,o),L(r.$$.fragment,o),c=!1},d(o){o&&z(e),Ye(t),o&&z(n),o&&z(a),Ye(r),i=!1,Hl(s)}}}function vh(l){let e,t,n,a,r;return t=new Rt({props:{icon:ir}}),{c(){e=_("a"),fe(t.$$.fragment),h(e,"class","is-pulled-right is-hidden px-1 py-0 has-text-weight-bold delete-button"),h(e,"href","$")},m(c,i){D(c,e,i),Fe(t,e,null),n=!0,a||(r=Qe(e,"click",Vt(l[12])),a=!0)},p:lt,i(c){n||(H(t.$$.fragment,c),n=!0)},o(c){L(t.$$.fragment,c),n=!1},d(c){c&&z(e),Ye(t),a=!1,r()}}}function yh(l){let e,t,n,a;const r=[Eh,Wh],c=[];function i(s,o){return s[2]?0:1}return t=i(l),n=c[t]=r[t](l),{c(){e=_("li"),n.c()},m(s,o){D(s,e,o),c[t].m(e,null),a=!0},p(s,[o]){let I=t;t=i(s),t===I?c[t].p(s,o):(ot(),L(c[I],1,1,()=>{c[I]=null}),It(),n=c[t],n?n.p(s,o):(n=c[t]=r[t](s),n.c()),H(n,1),n.m(e,null))},i(s){a||(H(n),a=!0)},o(s){L(n),a=!1},d(s){s&&z(e),c[t].d()}}}function _h(l,e,t){let n;tl(l,pa,F=>t(4,n=F));let{chat:a}=e,{activeChatId:r}=e,{prevChat:c}=e,{nextChat:i}=e,s=!1,o,I=0;sa(async()=>{a.name||t(0,a.name=`Chat ${a.id}`,a)});const m=F=>{F.key==="Escape"&&(F.stopPropagation(),F.preventDefault(),t(0,a.name=o,a),t(2,s=!1)),(F.key==="Tab"||F.key==="Enter")&&(F.stopPropagation(),F.preventDefault(),u())},u=()=>{if(t(2,s=!1),!a.name){t(0,a.name=o,a);return}vn()},p=()=>{if(!I){t(3,I=setTimeout(()=>{t(3,I=0)},1e3));return}if(clearTimeout(I),t(3,I=0),r===a.id){const F=i||c;F?ia(`/chat/${F.id}`).then(()=>{z2(a.id)}):ia("/").then(()=>{z2(a.id)})}else z2(a.id)},R=()=>{o=a.name,t(2,s=!0),setTimeout(()=>{const F=document.getElementById(`chat-menu-item-${a.id}`);F&&F.focus()},0)};function E(){a.name=this.innerText,t(0,a)}const W=()=>p(),X=()=>R(),f=()=>p(),Q=()=>{wl(pa,n=!1,n)};return l.$$set=F=>{"chat"in F&&t(0,a=F.chat),"activeChatId"in F&&t(1,r=F.activeChatId),"prevChat"in F&&t(9,c=F.prevChat),"nextChat"in F&&t(10,i=F.nextChat)},[a,r,s,I,n,m,u,p,R,c,i,E,W,X,f,Q]}class Xh extends Ht{constructor(e){super(),Qt(this,e,_h,yh,yt,{chat:0,activeChatId:1,prevChat:9,nextChat:10})}}function u9(l,e,t){const n=l.slice();return n[18]=e[t],n}function p9(l,e,t){const n=l.slice();return n[21]=e[t],n[23]=t,n}function Fh(l){let e=l[0],t,n,a=Z9(l);return{c(){a.c(),t=vt()},m(r,c){a.m(r,c),D(r,t,c),n=!0},p(r,c){c&1&&yt(e,e=r[0])?(ot(),L(a,1,1,lt),It(),a=Z9(r),a.c(),H(a,1),a.m(t.parentNode,t)):a.p(r,c)},i(r){n||(H(a),n=!0)},o(r){L(a),n=!1},d(r){r&&z(t),a.d(r)}}}function Yh(l){let e;return{c(){e=_("li"),e.innerHTML='No chats yet...'},m(t,n){D(t,e,n)},p:lt,i:lt,o:lt,d(t){t&&z(e)}}}function G9(l){let e,t;return e=new Xh({props:{activeChatId:l[5],chat:l[21],prevChat:l[4][l[23]-1],nextChat:l[4][l[23]+1]}}),{c(){fe(e.$$.fragment)},m(n,a){Fe(e,n,a),t=!0},p(n,a){const r={};a&32&&(r.activeChatId=n[5]),a&16&&(r.chat=n[21]),a&16&&(r.prevChat=n[4][n[23]-1]),a&16&&(r.nextChat=n[4][n[23]+1]),e.$set(r)},i(n){t||(H(e.$$.fragment,n),t=!0)},o(n){L(e.$$.fragment,n),t=!1},d(n){Ye(e,n)}}}function h9(l){let e=l[21].id,t,n,a=G9(l);return{c(){a.c(),t=vt()},m(r,c){a.m(r,c),D(r,t,c),n=!0},p(r,c){c&16&&yt(e,e=r[21].id)?(ot(),L(a,1,1,lt),It(),a=G9(r),a.c(),H(a,1),a.m(t.parentNode,t)):a.p(r,c)},i(r){n||(H(a),n=!0)},o(r){L(a),n=!1},d(r){r&&z(t),a.d(r)}}}function Z9(l){let e,t,n=l[4],a=[];for(let c=0;cL(a[c],1,1,()=>{a[c]=null});return{c(){for(let c=0;c_2(m,"chatId",He));const gt=[Yh,Fh],ht=[];function ye(et,_t){return et[4].length===0?0:1}E=ye(l),W=ht[E]=gt[E](l),k=new Rt({props:{icon:l[1].icon}});let tt=Object.values(j2),Et=[];for(let et=0;etL(Et[et],1,1,()=>{Et[et]=null});x=new Rt({props:{icon:V0}}),Ze=new Rt({props:{icon:w0}});const Ce=[Ah,wh],it=[];function Zt(et,_t){return et[2]?1:0}return se=Zt(l),pe=it[se]=Ce[se](l),{c(){e=_("aside"),t=_("div"),t.textContent="2025-06-24 14:23:51",n=he(),a=_("div"),r=_("div"),c=_("a"),i=_("img"),o=he(),I=_("div"),fe(m.$$.fragment),p=he(),R=_("ul"),W.c(),X=he(),f=_("div"),Q=_("div"),F=_("div"),A=_("div"),Y=_("button"),J=_("span"),fe(k.$$.fragment),ae=he(),P=_("div"),j=_("div");for(let et=0;etu=!1)),m.$set(kt);let zt=E;E=ye(et),E===zt?ht[E].p(et,_t):(ot(),L(ht[zt],1,1,()=>{ht[zt]=null}),It(),W=ht[E],W?W.p(et,_t):(W=ht[E]=gt[E](et),W.c()),H(W,1),W.m(R,null));const Dt={};if(_t&2&&(Dt.icon=et[1].icon),k.$set(Dt),_t&10){tt=Object.values(j2);let xe;for(xe=0;xe{it[ze]=null}),It(),pe=it[se],pe?pe.p(et,_t):(pe=it[se]=Ce[se](et),pe.c()),H(pe,1),pe.m(_e,null)),Ee&&$a(Ee.update)&&_t&64&&Ee.update.call(null,et[16]),(!Te||_t&64)&&ve(e,"pinned",et[6])},i(et){if(!Te){H(m.$$.fragment,et),H(W),H(k.$$.fragment,et);for(let _t=0;_tt(0,r=A)),tl(l,il,A=>t(7,c=A)),tl(l,T1,A=>t(8,i=A)),tl(l,pa,A=>t(6,s=A));let o=Pr(),I=fn();const m=(...A)=>{t(1,o=Pr()),t(4,n=c.sort(o.sortFn)),t(2,I=fn())};let u=!1;sa(()=>{});function p(A){a=A,t(5,a),t(8,i)}const R=()=>{t(3,u=!u)},E=A=>{t(3,u=!1),UG(A.value)},W=()=>{t(3,u=!1)},X=()=>{Qh()},f=()=>{Sh()},Q=()=>{wl(pa,s=!1,s),$i()},F=()=>{wl(pa,s=!1,s)};return l.$$.update=()=>{l.$$.dirty&128&&t(4,n=c.sort(Pr().sortFn)),l.$$.dirty&256&&t(5,a=i&&i.chatId?parseInt(i.chatId):void 0),l.$$.dirty&1&&m(r)},[r,o,I,u,n,a,s,c,i,p,R,E,W,X,f,Q,F]}class Lh extends Ht{constructor(e){super(),Qt(this,e,Hh,fh,yt,{})}}function Th(l){let e,t,n,a,r,c,i;const s=l[4].default,o=ul(s,l,l[3],null);return{c(){e=_("div"),t=he(),n=_("div"),a=he(),r=_("div"),o&&o.c(),h(e,"class","lower-mask section-footer-mask"),ve(e,"pin-footer",l[1]),h(n,"class","lower-mask2"),ve(n,"strong-mask",l[2]),h(r,"class",c="section-footer "+l[0]),ve(r,"pin-footer",l[1])},m(I,m){D(I,e,m),D(I,t,m),D(I,n,m),D(I,a,m),D(I,r,m),o&&o.m(r,null),i=!0},p(I,[m]){(!i||m&2)&&ve(e,"pin-footer",I[1]),(!i||m&4)&&ve(n,"strong-mask",I[2]),o&&o.p&&(!i||m&8)&&Gl(o,s,I,I[3],i?pl(s,I[3],m,null):hl(I[3]),null),(!i||m&1&&c!==(c="section-footer "+I[0]))&&h(r,"class",c),(!i||m&3)&&ve(r,"pin-footer",I[1])},i(I){i||(H(o,I),i=!0)},o(I){L(o,I),i=!1},d(I){I&&z(e),I&&z(t),I&&z(n),I&&z(a),I&&z(r),o&&o.d(I)}}}function Ch(l,e,t){let{$$slots:n={},$$scope:a}=e,{class:r=""}=e,{pin:c=!1}=e,{strongMask:i=!1}=e;return l.$$set=s=>{"class"in s&&t(0,r=s.class),"pin"in s&&t(1,c=s.pin),"strongMask"in s&&t(2,i=s.strongMask),"$$scope"in s&&t(3,a=s.$$scope)},[r,c,i,a,n]}class rm extends Ht{constructor(e){super(),Qt(this,e,Ch,Th,yt,{class:0,pin:1,strongMask:2})}}function N9(l){let e;return{c(){e=_("p"),e.innerHTML=`Please enter your OpenAI API key above to use Open AI's ChatGPT API. At least one API must be enabled to use ChatGPT-web.`,ve(e,"is-danger",!l[2]),ve(e,"is-warning",!l[3])},m(t,n){D(t,e,n)},p(t,n){n&4&&ve(e,"is-danger",!t[2]),n&8&&ve(e,"is-warning",!t[3])},d(t){t&&z(e)}}}function g9(l){let e,t,n,a,r,c,i,s,o,I,m,u,p,R,E,W,X,f,Q,F=!l[1]&&W9();return{c(){e=_("p"),e.textContent="Set Petals API Endpoint:",t=he(),n=_("form"),a=_("p"),r=_("input"),i=he(),s=_("p"),s.innerHTML='',o=he(),F&&F.c(),I=he(),m=_("p"),m.innerHTML='Petals lets you run large language models at home by connecting to a public swarm, BitTorrent-style, without hefty GPU requirements.',u=he(),p=_("p"),p.innerHTML='You are encouraged to set up a Petals server to share your GPU resources with the public swarm. Minimum requirements to contribute Llama 2 completions are a GTX 1080 8GB, but the larger/faster the better.',R=he(),E=_("p"),E.innerHTML='If you're receiving errors while using Petals, check swarm health and consider adding your GPU to the swarm to help.',W=he(),X=_("p"),X.innerHTML="Because Petals uses a public swarm, do not send sensitive information when using Petals.",h(r,"aria-label","PetalsAPI Endpoint"),h(r,"type","text"),h(r,"class","input"),h(r,"placeholder",Yp()+y7()),r.value=c=l[4].pedalsEndpoint||"",h(a,"class","control is-expanded"),h(s,"class","control"),h(n,"class","field has-addons has-addons-right"),h(m,"class","my-4"),h(p,"class","mb-4"),h(E,"class","mb-4"),h(X,"class","help is-warning")},m(A,Y){D(A,e,Y),D(A,t,Y),D(A,n,Y),V(n,a),V(a,r),V(n,i),V(n,s),D(A,o,Y),F&&F.m(A,Y),D(A,I,Y),D(A,m,Y),D(A,u,Y),D(A,p,Y),D(A,R,Y),D(A,E,Y),D(A,W,Y),D(A,X,Y),f||(Q=Qe(n,"submit",Vt(l[9])),f=!0)},p(A,Y){Y&16&&c!==(c=A[4].pedalsEndpoint||"")&&r.value!==c&&(r.value=c),A[1]?F&&(F.d(1),F=null):F||(F=W9(),F.c(),F.m(I.parentNode,I))},d(A){A&&z(e),A&&z(t),A&&z(n),A&&z(o),F&&F.d(A),A&&z(I),A&&z(m),A&&z(u),A&&z(p),A&&z(R),A&&z(E),A&&z(W),A&&z(X),f=!1,Q()}}}function W9(l){let e;return{c(){e=_("p"),e.innerHTML='Please only use the default public API for testing. It's best to configure a private endpoint and enter it above for connection to the Petals swarm.',h(e,"class","help is-warning")},m(t,n){D(t,e,n)},d(t){t&&z(e)}}}function E9(l){let e;return{c(){e=_("article"),e.innerHTML=`
Select an existing chat on the sidebar, or create a new chat
`,h(e,"class","message is-info")},m(t,n){D(t,e,n)},d(t){t&&z(e)}}}function kh(l){let e,t,n,a,r,c,i,s,o,I,m,u,p,R,E,W,X,f,Q,F,A,Y,J,k,ae,P,j,B,re,ge,we,Ae,x,M,Ie,Xe,Ge=!l[3]&&N9(l),Ze=l[0]&&g9(l),oe=l[3]&&E9();return x=new rm({props:{pin:!0}}),{c(){e=_("section"),t=_("article"),t.innerHTML=`

ChatGPT-web is a simple one-page web interface to the OpenAI ChatGPT API. To use it, you need to register for @@ -533,6 +533,6 @@ ${e} `}strong(e){return`${e}`}em(e){return`${e}`}codespan(e){return`${e}`}br(){return this.options.xhtml?"
":"
"}del(e){return`${e}`}link(e,t,n){if(e=Nd(this.options.sanitize,this.options.baseUrl,e),e===null)return n;let a='",a}image(e,t,n){if(e=Nd(this.options.sanitize,this.options.baseUrl,e),e===null)return n;let a=`${n}":">",a}text(e){return e}}class yb{strong(e){return e}em(e){return e}codespan(e){return e}del(e){return e}html(e){return e}text(e){return e}link(e,t,n){return""+n}image(e,t,n){return""+n}br(){return""}}class oo{constructor(){this.seen={}}serialize(e){return e.toLowerCase().trim().replace(/<[!\/a-z].*?>/ig,"").replace(/[\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,./:;<=>?@[\]^`{|}~]/g,"").replace(/\s/g,"-")}getNextSafeSlug(e,t){let n=e,a=0;if(this.seen.hasOwnProperty(n)){a=this.seen[e];do a++,n=e+"-"+a;while(this.seen.hasOwnProperty(n))}return t||(this.seen[e]=a,this.seen[n]=0),n}slug(e,t={}){const n=this.serialize(e);return this.getNextSafeSlug(n,t.dryrun)}}class r2{constructor(e){this.options=e||H2,this.options.renderer=this.options.renderer||new so,this.renderer=this.options.renderer,this.renderer.options=this.options,this.textRenderer=new yb,this.slugger=new oo}static parse(e,t){return new r2(t).parse(e)}static parseInline(e,t){return new r2(t).parseInline(e)}parse(e,t=!0){let n="",a,r,c,i,s,o,I,m,u,p,R,E,W,X,f,Q,F,A,Y;const J=e.length;for(a=0;a0&&f.tokens[0].type==="paragraph"?(f.tokens[0].text=A+" "+f.tokens[0].text,f.tokens[0].tokens&&f.tokens[0].tokens.length>0&&f.tokens[0].tokens[0].type==="text"&&(f.tokens[0].tokens[0].text=A+" "+f.tokens[0].tokens[0].text)):f.tokens.unshift({type:"text",text:A}):X+=A),X+=this.parse(f.tokens,W),u+=this.renderer.listitem(X,F,Q);n+=this.renderer.list(u,R,E);continue}case"html":{n+=this.renderer.html(p.text);continue}case"paragraph":{n+=this.renderer.paragraph(this.parseInline(p.tokens));continue}case"text":{for(u=p.tokens?this.parseInline(p.tokens):p.text;a+1{if(n.message+=` Please report this to https://github.com/markedjs/marked.`,l){const a="

An error occurred:

"+pn(n.message+"",!0)+"
";if(e)return Promise.resolve(a);if(t){t(null,a);return}return a}if(e)return Promise.reject(n);if(t){t(n);return}throw n}}function _b(l,e){return(t,n,a)=>{typeof n=="function"&&(a=n,n=null);const r={...n};n={...St.defaults,...r};const c=Ny(n.silent,n.async,a);if(typeof t>"u"||t===null)return c(new Error("marked(): input parameter is undefined or null"));if(typeof t!="string")return c(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(t)+", string expected"));if(hy(n),n.hooks&&(n.hooks.options=n),a){const i=n.highlight;let s;try{n.hooks&&(t=n.hooks.preprocess(t)),s=l(t,n)}catch(m){return c(m)}const o=function(m){let u;if(!m)try{n.walkTokens&&St.walkTokens(s,n.walkTokens),u=e(s,n),n.hooks&&(u=n.hooks.postprocess(u))}catch(p){m=p}return n.highlight=i,m?c(m):a(null,u)};if(!i||i.length<3||(delete n.highlight,!s.length))return o();let I=0;St.walkTokens(s,function(m){m.type==="code"&&(I++,setTimeout(()=>{i(m.text,m.lang,function(u,p){if(u)return o(u);p!=null&&p!==m.text&&(m.text=p,m.escaped=!0),I--,I===0&&o()})},0))}),I===0&&o();return}if(n.async)return Promise.resolve(n.hooks?n.hooks.preprocess(t):t).then(i=>l(i,n)).then(i=>n.walkTokens?Promise.all(St.walkTokens(i,n.walkTokens)).then(()=>i):i).then(i=>e(i,n)).then(i=>n.hooks?n.hooks.postprocess(i):i).catch(c);try{n.hooks&&(t=n.hooks.preprocess(t));const i=l(t,n);n.walkTokens&&St.walkTokens(i,n.walkTokens);let s=e(i,n);return n.hooks&&(s=n.hooks.postprocess(s)),s}catch(i){return c(i)}}}function St(l,e,t){return _b(La.lex,r2.parse)(l,e,t)}St.options=St.setOptions=function(l){return St.defaults={...St.defaults,...l},ay(St.defaults),St};St.getDefaults=Wb;St.defaults=H2;St.use=function(...l){const e=St.defaults.extensions||{renderers:{},childTokens:{}};l.forEach(t=>{const n={...t};if(n.async=St.defaults.async||n.async||!1,t.extensions&&(t.extensions.forEach(a=>{if(!a.name)throw new Error("extension name required");if(a.renderer){const r=e.renderers[a.name];r?e.renderers[a.name]=function(...c){let i=a.renderer.apply(this,c);return i===!1&&(i=r.apply(this,c)),i}:e.renderers[a.name]=a.renderer}if(a.tokenizer){if(!a.level||a.level!=="block"&&a.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");e[a.level]?e[a.level].unshift(a.tokenizer):e[a.level]=[a.tokenizer],a.start&&(a.level==="block"?e.startBlock?e.startBlock.push(a.start):e.startBlock=[a.start]:a.level==="inline"&&(e.startInline?e.startInline.push(a.start):e.startInline=[a.start]))}a.childTokens&&(e.childTokens[a.name]=a.childTokens)}),n.extensions=e),t.renderer){const a=St.defaults.renderer||new so;for(const r in t.renderer){const c=a[r];a[r]=(...i)=>{let s=t.renderer[r].apply(a,i);return s===!1&&(s=c.apply(a,i)),s}}n.renderer=a}if(t.tokenizer){const a=St.defaults.tokenizer||new io;for(const r in t.tokenizer){const c=a[r];a[r]=(...i)=>{let s=t.tokenizer[r].apply(a,i);return s===!1&&(s=c.apply(a,i)),s}}n.tokenizer=a}if(t.hooks){const a=St.defaults.hooks||new tr;for(const r in t.hooks){const c=a[r];tr.passThroughHooks.has(r)?a[r]=i=>{if(St.defaults.async)return Promise.resolve(t.hooks[r].call(a,i)).then(o=>c.call(a,o));const s=t.hooks[r].call(a,i);return c.call(a,s)}:a[r]=(...i)=>{let s=t.hooks[r].apply(a,i);return s===!1&&(s=c.apply(a,i)),s}}n.hooks=a}if(t.walkTokens){const a=St.defaults.walkTokens;n.walkTokens=function(r){let c=[];return c.push(t.walkTokens.call(this,r)),a&&(c=c.concat(a.call(this,r))),c}}St.setOptions(n)})};St.walkTokens=function(l,e){let t=[];for(const n of l)switch(t=t.concat(e.call(St,n)),n.type){case"table":{for(const a of n.header)t=t.concat(St.walkTokens(a.tokens,e));for(const a of n.rows)for(const r of a)t=t.concat(St.walkTokens(r.tokens,e));break}case"list":{t=t.concat(St.walkTokens(n.items,e));break}default:St.defaults.extensions&&St.defaults.extensions.childTokens&&St.defaults.extensions.childTokens[n.type]?St.defaults.extensions.childTokens[n.type].forEach(function(a){t=t.concat(St.walkTokens(n[a],e))}):n.tokens&&(t=t.concat(St.walkTokens(n.tokens,e)))}return t};St.parseInline=_b(La.lexInline,r2.parseInline);St.Parser=r2;St.parser=r2.parse;St.Renderer=so;St.TextRenderer=yb;St.Lexer=La;St.lexer=La.lex;St.Tokenizer=io;St.Slugger=oo;St.Hooks=tr;St.parse=St;St.options;St.setOptions;St.use;St.walkTokens;St.parseInline;r2.parse;La.lex;const Xb={};function gy(l){let e;return{c(){e=ut(l[1])},m(t,n){D(t,e,n)},p(t,n){n&2&&bl(e,t[1])},i:lt,o:lt,d(t){t&&z(e)}}}function Wy(l){let e,t;const n=l[5].default,a=ul(n,l,l[4],null);return{c(){e=_("h6"),a&&a.c(),h(e,"id",l[2])},m(r,c){D(r,e,c),a&&a.m(e,null),t=!0},p(r,c){a&&a.p&&(!t||c&16)&&Gl(a,n,r,r[4],t?pl(n,r[4],c,null):hl(r[4]),null),(!t||c&4)&&h(e,"id",r[2])},i(r){t||(H(a,r),t=!0)},o(r){L(a,r),t=!1},d(r){r&&z(e),a&&a.d(r)}}}function Ey(l){let e,t;const n=l[5].default,a=ul(n,l,l[4],null);return{c(){e=_("h5"),a&&a.c(),h(e,"id",l[2])},m(r,c){D(r,e,c),a&&a.m(e,null),t=!0},p(r,c){a&&a.p&&(!t||c&16)&&Gl(a,n,r,r[4],t?pl(n,r[4],c,null):hl(r[4]),null),(!t||c&4)&&h(e,"id",r[2])},i(r){t||(H(a,r),t=!0)},o(r){L(a,r),t=!1},d(r){r&&z(e),a&&a.d(r)}}}function Vy(l){let e,t;const n=l[5].default,a=ul(n,l,l[4],null);return{c(){e=_("h4"),a&&a.c(),h(e,"id",l[2])},m(r,c){D(r,e,c),a&&a.m(e,null),t=!0},p(r,c){a&&a.p&&(!t||c&16)&&Gl(a,n,r,r[4],t?pl(n,r[4],c,null):hl(r[4]),null),(!t||c&4)&&h(e,"id",r[2])},i(r){t||(H(a,r),t=!0)},o(r){L(a,r),t=!1},d(r){r&&z(e),a&&a.d(r)}}}function vy(l){let e,t;const n=l[5].default,a=ul(n,l,l[4],null);return{c(){e=_("h3"),a&&a.c(),h(e,"id",l[2])},m(r,c){D(r,e,c),a&&a.m(e,null),t=!0},p(r,c){a&&a.p&&(!t||c&16)&&Gl(a,n,r,r[4],t?pl(n,r[4],c,null):hl(r[4]),null),(!t||c&4)&&h(e,"id",r[2])},i(r){t||(H(a,r),t=!0)},o(r){L(a,r),t=!1},d(r){r&&z(e),a&&a.d(r)}}}function yy(l){let e,t;const n=l[5].default,a=ul(n,l,l[4],null);return{c(){e=_("h2"),a&&a.c(),h(e,"id",l[2])},m(r,c){D(r,e,c),a&&a.m(e,null),t=!0},p(r,c){a&&a.p&&(!t||c&16)&&Gl(a,n,r,r[4],t?pl(n,r[4],c,null):hl(r[4]),null),(!t||c&4)&&h(e,"id",r[2])},i(r){t||(H(a,r),t=!0)},o(r){L(a,r),t=!1},d(r){r&&z(e),a&&a.d(r)}}}function _y(l){let e,t;const n=l[5].default,a=ul(n,l,l[4],null);return{c(){e=_("h1"),a&&a.c(),h(e,"id",l[2])},m(r,c){D(r,e,c),a&&a.m(e,null),t=!0},p(r,c){a&&a.p&&(!t||c&16)&&Gl(a,n,r,r[4],t?pl(n,r[4],c,null):hl(r[4]),null),(!t||c&4)&&h(e,"id",r[2])},i(r){t||(H(a,r),t=!0)},o(r){L(a,r),t=!1},d(r){r&&z(e),a&&a.d(r)}}}function Xy(l){let e,t,n,a;const r=[_y,yy,vy,Vy,Ey,Wy,gy],c=[];function i(s,o){return s[0]===1?0:s[0]===2?1:s[0]===3?2:s[0]===4?3:s[0]===5?4:s[0]===6?5:6}return e=i(l),t=c[e]=r[e](l),{c(){t.c(),n=vt()},m(s,o){c[e].m(s,o),D(s,n,o),a=!0},p(s,[o]){let I=e;e=i(s),e===I?c[e].p(s,o):(ot(),L(c[I],1,1,()=>{c[I]=null}),It(),t=c[e],t?t.p(s,o):(t=c[e]=r[e](s),t.c()),H(t,1),t.m(n.parentNode,n))},i(s){a||(H(t),a=!0)},o(s){L(t),a=!1},d(s){c[e].d(s),s&&z(n)}}}function Fy(l,e,t){let n,{$$slots:a={},$$scope:r}=e,{depth:c}=e,{raw:i}=e,{text:s}=e;const{slug:o,getOptions:I}=lu(Xb),m=I();return l.$$set=u=>{"depth"in u&&t(0,c=u.depth),"raw"in u&&t(1,i=u.raw),"text"in u&&t(3,s=u.text),"$$scope"in u&&t(4,r=u.$$scope)},l.$$.update=()=>{l.$$.dirty&8&&t(2,n=m.headerIds?m.headerPrefix+o(s):void 0)},[c,i,n,s,r,a]}class Yy extends Ht{constructor(e){super(),Qt(this,e,Fy,Xy,yt,{depth:0,raw:1,text:3})}}function wy(l){let e,t;const n=l[1].default,a=ul(n,l,l[0],null);return{c(){e=_("p"),a&&a.c()},m(r,c){D(r,e,c),a&&a.m(e,null),t=!0},p(r,[c]){a&&a.p&&(!t||c&1)&&Gl(a,n,r,r[0],t?pl(n,r[0],c,null):hl(r[0]),null)},i(r){t||(H(a,r),t=!0)},o(r){L(a,r),t=!1},d(r){r&&z(e),a&&a.d(r)}}}function Ay(l,e,t){let{$$slots:n={},$$scope:a}=e;return l.$$set=r=>{"$$scope"in r&&t(0,a=r.$$scope)},[a,n]}class fy extends Ht{constructor(e){super(),Qt(this,e,Ay,wy,yt,{})}}function Sy(l){let e;const t=l[3].default,n=ul(t,l,l[2],null);return{c(){n&&n.c()},m(a,r){n&&n.m(a,r),e=!0},p(a,[r]){n&&n.p&&(!e||r&4)&&Gl(n,t,a,a[2],e?pl(t,a[2],r,null):hl(a[2]),null)},i(a){e||(H(n,a),e=!0)},o(a){L(n,a),e=!1},d(a){n&&n.d(a)}}}function Qy(l,e,t){let{$$slots:n={},$$scope:a}=e,{text:r}=e,{raw:c}=e;return l.$$set=i=>{"text"in i&&t(0,r=i.text),"raw"in i&&t(1,c=i.raw),"$$scope"in i&&t(2,a=i.$$scope)},[r,c,a,n]}class Hy extends Ht{constructor(e){super(),Qt(this,e,Qy,Sy,yt,{text:0,raw:1})}}function Ly(l){let e,t;return{c(){e=_("img"),e2(e.src,t=l[0])||h(e,"src",t),h(e,"title",l[1]),h(e,"alt",l[2])},m(n,a){D(n,e,a)},p(n,[a]){a&1&&!e2(e.src,t=n[0])&&h(e,"src",t),a&2&&h(e,"title",n[1]),a&4&&h(e,"alt",n[2])},i:lt,o:lt,d(n){n&&z(e)}}}function Ty(l,e,t){let{href:n=""}=e,{title:a=void 0}=e,{text:r=""}=e;return l.$$set=c=>{"href"in c&&t(0,n=c.href),"title"in c&&t(1,a=c.title),"text"in c&&t(2,r=c.text)},[n,a,r]}class Cy extends Ht{constructor(e){super(),Qt(this,e,Ty,Ly,yt,{href:0,title:1,text:2})}}function ky(l){let e,t;const n=l[3].default,a=ul(n,l,l[2],null);return{c(){e=_("a"),a&&a.c(),h(e,"href",l[0]),h(e,"title",l[1])},m(r,c){D(r,e,c),a&&a.m(e,null),t=!0},p(r,[c]){a&&a.p&&(!t||c&4)&&Gl(a,n,r,r[2],t?pl(n,r[2],c,null):hl(r[2]),null),(!t||c&1)&&h(e,"href",r[0]),(!t||c&2)&&h(e,"title",r[1])},i(r){t||(H(a,r),t=!0)},o(r){L(a,r),t=!1},d(r){r&&z(e),a&&a.d(r)}}}function Jy(l,e,t){let{$$slots:n={},$$scope:a}=e,{href:r=""}=e,{title:c=void 0}=e;return l.$$set=i=>{"href"in i&&t(0,r=i.href),"title"in i&&t(1,c=i.title),"$$scope"in i&&t(2,a=i.$$scope)},[r,c,a,n]}class Uy extends Ht{constructor(e){super(),Qt(this,e,Jy,ky,yt,{href:0,title:1})}}function xy(l){let e,t;const n=l[1].default,a=ul(n,l,l[0],null);return{c(){e=_("em"),a&&a.c()},m(r,c){D(r,e,c),a&&a.m(e,null),t=!0},p(r,[c]){a&&a.p&&(!t||c&1)&&Gl(a,n,r,r[0],t?pl(n,r[0],c,null):hl(r[0]),null)},i(r){t||(H(a,r),t=!0)},o(r){L(a,r),t=!1},d(r){r&&z(e),a&&a.d(r)}}}function My(l,e,t){let{$$slots:n={},$$scope:a}=e;return l.$$set=r=>{"$$scope"in r&&t(0,a=r.$$scope)},[a,n]}class By extends Ht{constructor(e){super(),Qt(this,e,My,xy,yt,{})}}function Oy(l){let e,t;const n=l[1].default,a=ul(n,l,l[0],null);return{c(){e=_("del"),a&&a.c()},m(r,c){D(r,e,c),a&&a.m(e,null),t=!0},p(r,[c]){a&&a.p&&(!t||c&1)&&Gl(a,n,r,r[0],t?pl(n,r[0],c,null):hl(r[0]),null)},i(r){t||(H(a,r),t=!0)},o(r){L(a,r),t=!1},d(r){r&&z(e),a&&a.d(r)}}}function zy(l,e,t){let{$$slots:n={},$$scope:a}=e;return l.$$set=r=>{"$$scope"in r&&t(0,a=r.$$scope)},[a,n]}class Dy extends Ht{constructor(e){super(),Qt(this,e,zy,Oy,yt,{})}}function Py(l){let e,t=l[0].replace(/`/g,"")+"",n;return{c(){e=_("code"),n=ut(t)},m(a,r){D(a,e,r),V(e,n)},p(a,[r]){r&1&&t!==(t=a[0].replace(/`/g,"")+"")&&bl(n,t)},i:lt,o:lt,d(a){a&&z(e)}}}function Ky(l,e,t){let{raw:n}=e;return l.$$set=a=>{"raw"in a&&t(0,n=a.raw)},[n]}class jy extends Ht{constructor(e){super(),Qt(this,e,Ky,Py,yt,{raw:0})}}function qy(l){let e,t;const n=l[1].default,a=ul(n,l,l[0],null);return{c(){e=_("strong"),a&&a.c()},m(r,c){D(r,e,c),a&&a.m(e,null),t=!0},p(r,[c]){a&&a.p&&(!t||c&1)&&Gl(a,n,r,r[0],t?pl(n,r[0],c,null):hl(r[0]),null)},i(r){t||(H(a,r),t=!0)},o(r){L(a,r),t=!1},d(r){r&&z(e),a&&a.d(r)}}}function $y(l,e,t){let{$$slots:n={},$$scope:a}=e;return l.$$set=r=>{"$$scope"in r&&t(0,a=r.$$scope)},[a,n]}class e_ extends Ht{constructor(e){super(),Qt(this,e,$y,qy,yt,{})}}function t_(l){let e,t;const n=l[1].default,a=ul(n,l,l[0],null);return{c(){e=_("table"),a&&a.c()},m(r,c){D(r,e,c),a&&a.m(e,null),t=!0},p(r,[c]){a&&a.p&&(!t||c&1)&&Gl(a,n,r,r[0],t?pl(n,r[0],c,null):hl(r[0]),null)},i(r){t||(H(a,r),t=!0)},o(r){L(a,r),t=!1},d(r){r&&z(e),a&&a.d(r)}}}function l_(l,e,t){let{$$slots:n={},$$scope:a}=e;return l.$$set=r=>{"$$scope"in r&&t(0,a=r.$$scope)},[a,n]}class n_ extends Ht{constructor(e){super(),Qt(this,e,l_,t_,yt,{})}}function a_(l){let e,t;const n=l[1].default,a=ul(n,l,l[0],null);return{c(){e=_("thead"),a&&a.c()},m(r,c){D(r,e,c),a&&a.m(e,null),t=!0},p(r,[c]){a&&a.p&&(!t||c&1)&&Gl(a,n,r,r[0],t?pl(n,r[0],c,null):hl(r[0]),null)},i(r){t||(H(a,r),t=!0)},o(r){L(a,r),t=!1},d(r){r&&z(e),a&&a.d(r)}}}function r_(l,e,t){let{$$slots:n={},$$scope:a}=e;return l.$$set=r=>{"$$scope"in r&&t(0,a=r.$$scope)},[a,n]}class c_ extends Ht{constructor(e){super(),Qt(this,e,r_,a_,yt,{})}}function i_(l){let e,t;const n=l[1].default,a=ul(n,l,l[0],null);return{c(){e=_("tbody"),a&&a.c()},m(r,c){D(r,e,c),a&&a.m(e,null),t=!0},p(r,[c]){a&&a.p&&(!t||c&1)&&Gl(a,n,r,r[0],t?pl(n,r[0],c,null):hl(r[0]),null)},i(r){t||(H(a,r),t=!0)},o(r){L(a,r),t=!1},d(r){r&&z(e),a&&a.d(r)}}}function s_(l,e,t){let{$$slots:n={},$$scope:a}=e;return l.$$set=r=>{"$$scope"in r&&t(0,a=r.$$scope)},[a,n]}class o_ extends Ht{constructor(e){super(),Qt(this,e,s_,i_,yt,{})}}function I_(l){let e,t;const n=l[1].default,a=ul(n,l,l[0],null);return{c(){e=_("tr"),a&&a.c()},m(r,c){D(r,e,c),a&&a.m(e,null),t=!0},p(r,[c]){a&&a.p&&(!t||c&1)&&Gl(a,n,r,r[0],t?pl(n,r[0],c,null):hl(r[0]),null)},i(r){t||(H(a,r),t=!0)},o(r){L(a,r),t=!1},d(r){r&&z(e),a&&a.d(r)}}}function d_(l,e,t){let{$$slots:n={},$$scope:a}=e;return l.$$set=r=>{"$$scope"in r&&t(0,a=r.$$scope)},[a,n]}class m_ extends Ht{constructor(e){super(),Qt(this,e,d_,I_,yt,{})}}function b_(l){let e,t;const n=l[3].default,a=ul(n,l,l[2],null);return{c(){e=_("td"),a&&a.c(),h(e,"align",l[1])},m(r,c){D(r,e,c),a&&a.m(e,null),t=!0},p(r,c){a&&a.p&&(!t||c&4)&&Gl(a,n,r,r[2],t?pl(n,r[2],c,null):hl(r[2]),null),(!t||c&2)&&h(e,"align",r[1])},i(r){t||(H(a,r),t=!0)},o(r){L(a,r),t=!1},d(r){r&&z(e),a&&a.d(r)}}}function u_(l){let e,t;const n=l[3].default,a=ul(n,l,l[2],null);return{c(){e=_("th"),a&&a.c(),h(e,"align",l[1])},m(r,c){D(r,e,c),a&&a.m(e,null),t=!0},p(r,c){a&&a.p&&(!t||c&4)&&Gl(a,n,r,r[2],t?pl(n,r[2],c,null):hl(r[2]),null),(!t||c&2)&&h(e,"align",r[1])},i(r){t||(H(a,r),t=!0)},o(r){L(a,r),t=!1},d(r){r&&z(e),a&&a.d(r)}}}function p_(l){let e,t,n,a;const r=[u_,b_],c=[];function i(s,o){return s[0]?0:1}return e=i(l),t=c[e]=r[e](l),{c(){t.c(),n=vt()},m(s,o){c[e].m(s,o),D(s,n,o),a=!0},p(s,[o]){let I=e;e=i(s),e===I?c[e].p(s,o):(ot(),L(c[I],1,1,()=>{c[I]=null}),It(),t=c[e],t?t.p(s,o):(t=c[e]=r[e](s),t.c()),H(t,1),t.m(n.parentNode,n))},i(s){a||(H(t),a=!0)},o(s){L(t),a=!1},d(s){c[e].d(s),s&&z(n)}}}function G_(l,e,t){let{$$slots:n={},$$scope:a}=e,{header:r}=e,{align:c}=e;return l.$$set=i=>{"header"in i&&t(0,r=i.header),"align"in i&&t(1,c=i.align),"$$scope"in i&&t(2,a=i.$$scope)},[r,c,a,n]}class h_ extends Ht{constructor(e){super(),Qt(this,e,G_,p_,yt,{header:0,align:1})}}function Z_(l){let e,t;const n=l[3].default,a=ul(n,l,l[2],null);return{c(){e=_("ul"),a&&a.c()},m(r,c){D(r,e,c),a&&a.m(e,null),t=!0},p(r,c){a&&a.p&&(!t||c&4)&&Gl(a,n,r,r[2],t?pl(n,r[2],c,null):hl(r[2]),null)},i(r){t||(H(a,r),t=!0)},o(r){L(a,r),t=!1},d(r){r&&z(e),a&&a.d(r)}}}function R_(l){let e,t;const n=l[3].default,a=ul(n,l,l[2],null);return{c(){e=_("ol"),a&&a.c(),h(e,"start",l[1])},m(r,c){D(r,e,c),a&&a.m(e,null),t=!0},p(r,c){a&&a.p&&(!t||c&4)&&Gl(a,n,r,r[2],t?pl(n,r[2],c,null):hl(r[2]),null),(!t||c&2)&&h(e,"start",r[1])},i(r){t||(H(a,r),t=!0)},o(r){L(a,r),t=!1},d(r){r&&z(e),a&&a.d(r)}}}function N_(l){let e,t,n,a;const r=[R_,Z_],c=[];function i(s,o){return s[0]?0:1}return e=i(l),t=c[e]=r[e](l),{c(){t.c(),n=vt()},m(s,o){c[e].m(s,o),D(s,n,o),a=!0},p(s,[o]){let I=e;e=i(s),e===I?c[e].p(s,o):(ot(),L(c[I],1,1,()=>{c[I]=null}),It(),t=c[e],t?t.p(s,o):(t=c[e]=r[e](s),t.c()),H(t,1),t.m(n.parentNode,n))},i(s){a||(H(t),a=!0)},o(s){L(t),a=!1},d(s){c[e].d(s),s&&z(n)}}}function g_(l,e,t){let{$$slots:n={},$$scope:a}=e,{ordered:r}=e,{start:c}=e;return l.$$set=i=>{"ordered"in i&&t(0,r=i.ordered),"start"in i&&t(1,c=i.start),"$$scope"in i&&t(2,a=i.$$scope)},[r,c,a,n]}class W_ extends Ht{constructor(e){super(),Qt(this,e,g_,N_,yt,{ordered:0,start:1})}}function E_(l){let e,t;const n=l[1].default,a=ul(n,l,l[0],null);return{c(){e=_("li"),a&&a.c()},m(r,c){D(r,e,c),a&&a.m(e,null),t=!0},p(r,[c]){a&&a.p&&(!t||c&1)&&Gl(a,n,r,r[0],t?pl(n,r[0],c,null):hl(r[0]),null)},i(r){t||(H(a,r),t=!0)},o(r){L(a,r),t=!1},d(r){r&&z(e),a&&a.d(r)}}}function V_(l,e,t){let{$$slots:n={},$$scope:a}=e;return l.$$set=r=>{"$$scope"in r&&t(0,a=r.$$scope)},[a,n]}class v_ extends Ht{constructor(e){super(),Qt(this,e,V_,E_,yt,{})}}function y_(l){let e;return{c(){e=_("hr")},m(t,n){D(t,e,n)},p:lt,i:lt,o:lt,d(t){t&&z(e)}}}class __ extends Ht{constructor(e){super(),Qt(this,e,null,y_,yt,{})}}function X_(l){let e,t;return{c(){e=new c2(!1),t=vt(),e.a=t},m(n,a){e.m(l[0],n,a),D(n,t,a)},p(n,[a]){a&1&&e.p(n[0])},i:lt,o:lt,d(n){n&&z(t),n&&e.d()}}}function F_(l,e,t){let{text:n}=e;return l.$$set=a=>{"text"in a&&t(0,n=a.text)},[n]}class Y_ extends Ht{constructor(e){super(),Qt(this,e,F_,X_,yt,{text:0})}}function w_(l){let e,t;const n=l[1].default,a=ul(n,l,l[0],null);return{c(){e=_("blockquote"),a&&a.c()},m(r,c){D(r,e,c),a&&a.m(e,null),t=!0},p(r,[c]){a&&a.p&&(!t||c&1)&&Gl(a,n,r,r[0],t?pl(n,r[0],c,null):hl(r[0]),null)},i(r){t||(H(a,r),t=!0)},o(r){L(a,r),t=!1},d(r){r&&z(e),a&&a.d(r)}}}function A_(l,e,t){let{$$slots:n={},$$scope:a}=e;return l.$$set=r=>{"$$scope"in r&&t(0,a=r.$$scope)},[a,n]}class f_ extends Ht{constructor(e){super(),Qt(this,e,A_,w_,yt,{})}}function S_(l){let e,t,n;return{c(){e=_("pre"),t=_("code"),n=ut(l[1]),h(e,"class",l[0])},m(a,r){D(a,e,r),V(e,t),V(t,n)},p(a,[r]){r&2&&bl(n,a[1]),r&1&&h(e,"class",a[0])},i:lt,o:lt,d(a){a&&z(e)}}}function Q_(l,e,t){let{lang:n}=e,{text:a}=e;return l.$$set=r=>{"lang"in r&&t(0,n=r.lang),"text"in r&&t(1,a=r.text)},[n,a]}class H_ extends Ht{constructor(e){super(),Qt(this,e,Q_,S_,yt,{lang:0,text:1})}}function L_(l){let e,t;const n=l[1].default,a=ul(n,l,l[0],null);return{c(){e=_("br"),a&&a.c()},m(r,c){D(r,e,c),a&&a.m(r,c),t=!0},p(r,[c]){a&&a.p&&(!t||c&1)&&Gl(a,n,r,r[0],t?pl(n,r[0],c,null):hl(r[0]),null)},i(r){t||(H(a,r),t=!0)},o(r){L(a,r),t=!1},d(r){r&&z(e),a&&a.d(r)}}}function T_(l,e,t){let{$$slots:n={},$$scope:a}=e;return l.$$set=r=>{"$$scope"in r&&t(0,a=r.$$scope)},[a,n]}class C_ extends Ht{constructor(e){super(),Qt(this,e,T_,L_,yt,{})}}const k_={heading:Yy,paragraph:fy,text:Hy,image:Cy,link:Uy,em:By,strong:e_,codespan:jy,del:Dy,table:n_,tablehead:c_,tablebody:o_,tablerow:m_,tablecell:h_,list:W_,orderedlistitem:null,unorderedlistitem:null,listitem:v_,hr:__,html:Y_,blockquote:f_,code:H_,br:C_},J_={baseUrl:null,breaks:!1,gfm:!0,headerIds:!0,headerPrefix:"",highlight:null,langPrefix:"language-",mangle:!0,pedantic:!1,renderer:null,sanitize:!1,sanitizer:null,silent:!1,smartLists:!1,smartypants:!1,tokenizer:null,xhtml:!1};function U_(l){let e,t;return e=new Q2({props:{tokens:l[0],renderers:l[1]}}),{c(){fe(e.$$.fragment)},m(n,a){Fe(e,n,a),t=!0},p(n,[a]){const r={};a&1&&(r.tokens=n[0]),a&2&&(r.renderers=n[1]),e.$set(r)},i(n){t||(H(e.$$.fragment,n),t=!0)},o(n){L(e.$$.fragment,n),t=!1},d(n){Ye(e,n)}}}function x_(l,e,t){let n,a,r,c,{source:i=[]}=e,{renderers:s={}}=e,{options:o={}}=e,{isInline:I=!1}=e;const m=w2();let u,p,R;return tu(Xb,{slug:E=>a?a.slug(E):"",getOptions:()=>r}),sa(()=>{t(7,R=!0)}),l.$$set=E=>{"source"in E&&t(2,i=E.source),"renderers"in E&&t(3,s=E.renderers),"options"in E&&t(4,o=E.options),"isInline"in E&&t(5,I=E.isInline)},l.$$.update=()=>{l.$$.dirty&4&&t(8,n=Array.isArray(i)),l.$$.dirty&4&&(a=i?new oo:void 0),l.$$.dirty&16&&t(9,r={...J_,...o}),l.$$.dirty&869&&(n?t(0,u=i):(t(6,p=new La(r)),t(0,u=I?p.inlineTokens(i):p.lex(i)),m("parsed",{tokens:u}))),l.$$.dirty&8&&t(1,c={...k_,...s}),l.$$.dirty&385&&R&&!n&&m("parsed",{tokens:u})},[u,c,i,s,o,I,p,R,n,r]}class Fb extends Ht{constructor(e){super(),Qt(this,e,x_,U_,yt,{source:2,renderers:3,options:4,isInline:5})}}function M_(l){let e,t,n=l[4],a,r,c,i,s=l[0].summary&&!l[0].summary.length&&vd(),o=_d(l),I=l[3]&&Xd(l);return{c(){e=_("div"),s&&s.c(),t=he(),o.c(),a=he(),I&&I.c(),h(e,"class","message-display")},m(m,u){D(m,e,u),s&&s.m(e,null),V(e,t),o.m(e,null),V(e,a),I&&I.m(e,null),r=!0,c||(i=[Qe(e,"touchend",l[20],{passive:!0}),Qe(e,"dblclick",Vt(l[31]))],c=!0)},p(m,u){m[0].summary&&!m[0].summary.length?s||(s=vd(),s.c(),s.m(e,t)):s&&(s.d(1),s=null),u[0]&16&&yt(n,n=m[4])?(ot(),L(o,1,1,lt),It(),o=_d(m),o.c(),H(o,1),o.m(e,a)):o.p(m,u),m[3]?I?I.p(m,u):(I=Xd(m),I.c(),I.m(e,null)):I&&(I.d(1),I=null)},i(m){r||(H(o),r=!0)},o(m){L(o),r=!1},d(m){m&&z(e),s&&s.d(),o.d(m),I&&I.d(),c=!1,Hl(i)}}}function B_(l){let e,t,n,a,r,c,i,s=l[3]&&Fd(l);return{c(){e=_("form"),t=_("div"),a=he(),s&&s.c(),r=vt(),h(t,"id",n="edit-"+l[0].uuid),h(t,"class","message-editor"),h(t,"contenteditable",""),l[0].content===void 0&&Y0(()=>l[30].call(t)),h(e,"class","message-edit")},m(o,I){D(o,e,I),V(e,t),l[0].content!==void 0&&(t.innerText=l[0].content),D(o,a,I),s&&s.m(o,I),D(o,r,I),c||(i=[Qe(t,"input",l[30]),Qe(t,"input",l[16]),Qe(t,"blur",l[18]),Qe(e,"submit",Vt(l[16])),Qe(e,"keydown",l[19])],c=!0)},p(o,I){I[0]&1&&n!==(n="edit-"+o[0].uuid)&&h(t,"id",n),I[0]&1&&o[0].content!==t.innerText&&(t.innerText=o[0].content),o[3]?s?s.p(o,I):(s=Fd(o),s.c(),s.m(r.parentNode,r)):s&&(s.d(1),s=null)},i:lt,o:lt,d(o){o&&z(e),o&&z(a),s&&s.d(o),o&&z(r),c=!1,Hl(i)}}}function vd(l){let e;return{c(){e=_("p"),e.innerHTML="Summarizing..."},m(t,n){D(t,e,n)},d(t){t&&z(e)}}}function yd(l){let e,t,n,a,r,c,i,s;return r=new Fb({props:{source:l[0].reason}}),{c(){e=_("details"),t=_("summary"),t.textContent="Reasoning..",n=he(),a=_("div"),fe(r.$$.fragment),c=he(),i=_("br"),On(a,"background-color","#333"),On(a,"padding","10px")},m(o,I){D(o,e,I),V(e,t),V(e,n),V(e,a),Fe(r,a,null),D(o,c,I),D(o,i,I),s=!0},p(o,I){const m={};I[0]&1&&(m.source=o[0].reason),r.$set(m)},i(o){s||(H(r.$$.fragment,o),s=!0)},o(o){L(r.$$.fragment,o),s=!1},d(o){o&&z(e),Ye(r),o&&z(c),o&&z(i)}}}function _d(l){let e,t,n,a=l[0].reason&&yd(l);return t=new Fb({props:{source:l[22](l[26](l[5])),options:l[13],renderers:l[14]}}),{c(){a&&a.c(),e=he(),fe(t.$$.fragment)},m(r,c){a&&a.m(r,c),D(r,e,c),Fe(t,r,c),n=!0},p(r,c){r[0].reason?a?(a.p(r,c),c[0]&1&&H(a,1)):(a=yd(r),a.c(),H(a,1),a.m(e.parentNode,e)):a&&(ot(),L(a,1,1,()=>{a=null}),It());const i={};c[0]&32&&(i.source=r[22](r[26](r[5]))),t.$set(i)},i(r){n||(H(a),H(t.$$.fragment,r),n=!0)},o(r){L(a),L(t.$$.fragment,r),n=!1},d(r){a&&a.d(r),r&&z(e),Ye(t,r)}}}function Xd(l){let e,t;return{c(){e=_("img"),e2(e.src,t=l[3])||h(e,"src",t),h(e,"alt","")},m(n,a){D(n,e,a)},p(n,a){a[0]&8&&!e2(e.src,t=n[3])&&h(e,"src",t)},d(n){n&&z(e)}}}function Fd(l){let e,t;return{c(){e=_("img"),e2(e.src,t=l[3])||h(e,"src",t),h(e,"alt","")},m(n,a){D(n,e,a)},p(n,a){a[0]&8&&!e2(e.src,t=n[3])&&h(e,"src",t)},d(n){n&&z(e)}}}function O_(l){let e,t,n=(Nl(l[0].model||"").label||l[0].model||l[2])+"",a,r,c,i=l[0].usage.total_tokens+"",s,o,I,m,u=k1(l[0].usage,l[0].model||l[2]).toFixed(6)+"",p;return{c(){e=_("p"),t=_("em"),a=ut(n),r=ut(" using "),c=_("span"),s=ut(i),o=ut(` - tokens ~= `),I=_("span"),m=ut("$"),p=ut(u),h(c,"class","has-text-weight-bold"),h(I,"class","has-text-weight-bold"),h(e,"class","is-size-7 message-note")},m(R,E){D(R,e,E),V(e,t),V(t,a),V(e,r),V(e,c),V(c,s),V(e,o),V(e,I),V(I,m),V(I,p)},p(R,E){E[0]&5&&n!==(n=(Nl(R[0].model||"").label||R[0].model||R[2])+"")&&bl(a,n),E[0]&1&&i!==(i=R[0].usage.total_tokens+"")&&bl(s,i),E[0]&5&&u!==(u=k1(R[0].usage,R[0].model||R[2]).toFixed(6)+"")&&bl(p,u)},d(R){R&&z(e)}}}function z_(l){let e;return{c(){e=_("p"),e.textContent="System Prompt",h(e,"class","is-size-7 message-note")},m(t,n){D(t,e,n)},p:lt,d(t){t&&z(e)}}}function Yd(l){let e,t,n,a,r,c;return n=new Rt({props:{icon:Fs}}),{c(){e=_("a"),t=_("span"),fe(n.$$.fragment),h(t,"class","icon"),h(e,"href","#"),h(e,"title","Continue "),h(e,"class","msg-incomplete button is-small")},m(i,s){D(i,e,s),V(e,t),Fe(n,t,null),a=!0,r||(c=Qe(e,"click",Vt(l[32])),r=!0)},p:lt,i(i){a||(H(n.$$.fragment,i),a=!0)},o(i){L(n.$$.fragment,i),a=!1},d(i){i&&z(e),Ye(n),r=!1,c()}}}function wd(l){let e,t,n,a,r,c;return n=new Rt({props:{icon:iG}}),{c(){e=_("a"),t=_("span"),fe(n.$$.fragment),h(t,"class","icon"),h(e,"href","#"),h(e,"title","Jump to summary"),h(e,"class","msg-summary button is-small")},m(i,s){D(i,e,s),V(e,t),Fe(n,t,null),a=!0,r||(c=Qe(e,"click",Vt(l[33])),r=!0)},p:lt,i(i){a||(H(n.$$.fragment,i),a=!0)},o(i){L(n.$$.fragment,i),a=!1},d(i){i&&z(e),Ye(n),r=!1,c()}}}function Ad(l){let e,t,n,a,r,c;return n=new Rt({props:{icon:Kp}}),{c(){e=_("a"),t=_("span"),fe(n.$$.fragment),h(t,"class","icon"),h(e,"href","#"),h(e,"title","Jump to summarized"),h(e,"class","msg-summarized button is-small")},m(i,s){D(i,e,s),V(e,t),Fe(n,t,null),a=!0,r||(c=Qe(e,"click",Vt(l[34])),r=!0)},p:lt,i(i){a||(H(n.$$.fragment,i),a=!0)},o(i){L(n.$$.fragment,i),a=!1},d(i){i&&z(e),Ye(n),r=!1,c()}}}function D_(l){let e,t,n,a,r,c;return n=new Rt({props:{icon:S7}}),{c(){e=_("a"),t=_("span"),fe(n.$$.fragment),h(t,"class","icon"),h(e,"href","#"),h(e,"title","Edit"),h(e,"class","msg-image button is-small")},m(i,s){D(i,e,s),V(e,t),Fe(n,t,null),a=!0,r||(c=Qe(e,"click",Vt(l[35])),r=!0)},p:lt,i(i){a||(H(n.$$.fragment,i),a=!0)},o(i){L(n.$$.fragment,i),a=!1},d(i){i&&z(e),Ye(n),r=!1,c()}}}function fd(l){let e,t,n,a,r,c;const i=[K_,P_],s=[];function o(I,m){return I[6]?0:1}return t=o(l),n=s[t]=i[t](l),{c(){e=_("a"),n.c(),h(e,"href","#"),h(e,"title","Delete this message"),h(e,"class","msg-delete button is-small")},m(I,m){D(I,e,m),s[t].m(e,null),a=!0,r||(c=Qe(e,"click",Vt(l[36])),r=!0)},p(I,m){let u=t;t=o(I),t===u?s[t].p(I,m):(ot(),L(s[u],1,1,()=>{s[u]=null}),It(),n=s[t],n?n.p(I,m):(n=s[t]=i[t](I),n.c()),H(n,1),n.m(e,null))},i(I){a||(H(n),a=!0)},o(I){L(n),a=!1},d(I){I&&z(e),s[t].d(),r=!1,c()}}}function P_(l){let e,t,n;return t=new Rt({props:{icon:sr}}),{c(){e=_("span"),fe(t.$$.fragment),h(e,"class","icon")},m(a,r){D(a,e,r),Fe(t,e,null),n=!0},p:lt,i(a){n||(H(t.$$.fragment,a),n=!0)},o(a){L(t.$$.fragment,a),n=!1},d(a){a&&z(e),Ye(t)}}}function K_(l){let e,t,n;return t=new Rt({props:{icon:ir}}),{c(){e=_("span"),fe(t.$$.fragment),h(e,"class","icon")},m(a,r){D(a,e,r),Fe(t,e,null),n=!0},p:lt,i(a){n||(H(t.$$.fragment,a),n=!0)},o(a){L(t.$$.fragment,a),n=!1},d(a){a&&z(e),Ye(t)}}}function Sd(l){let e,t,n,a,r,c;const i=[q_,j_],s=[];function o(I,m){return I[7]?0:1}return t=o(l),n=s[t]=i[t](l),{c(){e=_("a"),n.c(),h(e,"href","#"),h(e,"title","Truncate from here and send"),h(e,"class","msg-truncate button is-small")},m(I,m){D(I,e,m),s[t].m(e,null),a=!0,r||(c=Qe(e,"click",Vt(l[37])),r=!0)},p(I,m){let u=t;t=o(I),t===u?s[t].p(I,m):(ot(),L(s[u],1,1,()=>{s[u]=null}),It(),n=s[t],n?n.p(I,m):(n=s[t]=i[t](I),n.c()),H(n,1),n.m(e,null))},i(I){a||(H(n),a=!0)},o(I){L(n),a=!1},d(I){I&&z(e),s[t].d(),r=!1,c()}}}function j_(l){let e,t,n;return t=new Rt({props:{icon:J7}}),{c(){e=_("span"),fe(t.$$.fragment),h(e,"class","icon")},m(a,r){D(a,e,r),Fe(t,e,null),n=!0},p:lt,i(a){n||(H(t.$$.fragment,a),n=!0)},o(a){L(t.$$.fragment,a),n=!1},d(a){a&&z(e),Ye(t)}}}function q_(l){let e,t,n;return t=new Rt({props:{icon:ir}}),{c(){e=_("span"),fe(t.$$.fragment),h(e,"class","icon")},m(a,r){D(a,e,r),Fe(t,e,null),n=!0},p:lt,i(a){n||(H(t.$$.fragment,a),n=!0)},o(a){L(t.$$.fragment,a),n=!1},d(a){a&&z(e),Ye(t)}}}function Qd(l){let e,t,n,a,r,c,i;const s=[eX,$_],o=[];function I(m,u){return m[0].suppress?0:1}return t=I(l),n=o[t]=s[t](l),{c(){e=_("a"),n.c(),h(e,"href","#"),h(e,"title",a=(l[0].suppress?"Uns":"S")+"uppress message from submission"),h(e,"class","msg-supress button is-small")},m(m,u){D(m,e,u),o[t].m(e,null),r=!0,c||(i=Qe(e,"click",Vt(l[38])),c=!0)},p(m,u){let p=t;t=I(m),t===p?o[t].p(m,u):(ot(),L(o[p],1,1,()=>{o[p]=null}),It(),n=o[t],n?n.p(m,u):(n=o[t]=s[t](m),n.c()),H(n,1),n.m(e,null)),(!r||u[0]&1&&a!==(a=(m[0].suppress?"Uns":"S")+"uppress message from submission"))&&h(e,"title",a)},i(m){r||(H(n),r=!0)},o(m){L(n),r=!1},d(m){m&&z(e),o[t].d(),c=!1,i()}}}function $_(l){let e,t,n;return t=new Rt({props:{icon:Q7}}),{c(){e=_("span"),fe(t.$$.fragment),h(e,"class","icon")},m(a,r){D(a,e,r),Fe(t,e,null),n=!0},p:lt,i(a){n||(H(t.$$.fragment,a),n=!0)},o(a){L(t.$$.fragment,a),n=!1},d(a){a&&z(e),Ye(t)}}}function eX(l){let e,t,n;return t=new Rt({props:{icon:L7}}),{c(){e=_("span"),fe(t.$$.fragment),h(e,"class","icon")},m(a,r){D(a,e,r),Fe(t,e,null),n=!0},p:lt,i(a){n||(H(t.$$.fragment,a),n=!0)},o(a){L(t.$$.fragment,a),n=!1},d(a){a&&z(e),Ye(t)}}}function tX(l){let e,t,n,a,r,c;return n=new Rt({props:{icon:tG}}),{c(){e=_("a"),t=_("span"),fe(n.$$.fragment),h(t,"class","icon"),h(e,"href","#"),h(e,"title","Copy to Clipboard"),h(e,"class","msg-image button is-small")},m(i,s){D(i,e,s),V(e,t),Fe(n,t,null),a=!0,r||(c=Qe(e,"click",Vt(l[39])),r=!0)},p:lt,i(i){a||(H(n.$$.fragment,i),a=!0)},o(i){L(n.$$.fragment,i),a=!1},d(i){i&&z(e),Ye(n),r=!1,c()}}}function Hd(l){let e,t,n,a,r,c;return n=new Rt({props:{icon:w0}}),{c(){e=_("a"),t=_("span"),fe(n.$$.fragment),h(t,"class","icon"),h(e,"href","#"),h(e,"title","Download Image"),h(e,"class","msg-image button is-small")},m(i,s){D(i,e,s),V(e,t),Fe(n,t,null),a=!0,r||(c=Qe(e,"click",Vt(l[41])),r=!0)},p:lt,i(i){a||(H(n.$$.fragment,i),a=!0)},o(i){L(n.$$.fragment,i),a=!1},d(i){i&&z(e),Ye(n),r=!1,c()}}}function lX(l){let e,t,n,a,r,c,i,s,o,I,m,u,p,R,E,W,X,f,Q,F,A,Y,J,k,ae,P;const j=[B_,M_],B=[];function re(pe,Ee){return pe[1]?0:1}n=re(l),a=B[n]=j[n](l);function ge(pe,Ee){if(pe[9])return z_;if(pe[0].usage)return O_}let we=ge(l),Ae=we&&we(l),x=(l[0].finish_reason==="length"||l[0].finish_reason==="abort")&&Yd(l),M=l[0].summarized&&wd(l),Ie=l[0].summary&&Ad(l),Xe=!l[12]&&D_(l),Ge=!l[0].summarized&&fd(l),Ze=!l[12]&&!l[0].summarized&&!l[8]&&Sd(l),oe=!l[12]&&!l[0].summarized&&!l[9]&&!l[8]&&Qd(l),_e=!l[12]&&tX(l);A=new Rt({props:{icon:cG}});let se=l[3]&&Hd(l);return{c(){e=_("article"),t=_("div"),a.c(),r=he(),Ae&&Ae.c(),c=he(),i=_("div"),s=he(),o=_("div"),I=_("div"),x&&x.c(),m=he(),M&&M.c(),u=he(),Ie&&Ie.c(),p=he(),Xe&&Xe.c(),R=he(),Ge&&Ge.c(),E=he(),Ze&&Ze.c(),W=he(),oe&&oe.c(),X=he(),_e&&_e.c(),f=he(),Q=_("a"),F=_("span"),fe(A.$$.fragment),Y=he(),se&&se.c(),h(t,"class","message-body content"),h(i,"class","tool-drawer-mask"),h(F,"class","icon"),h(Q,"href","#"),h(Q,"title","Render LaTeX in message"),h(Q,"class","button is-small"),h(I,"class","button-pack"),h(o,"class","tool-drawer"),h(e,"id",J="message-"+l[0].uuid),h(e,"class","message chat-message"),ve(e,"is-info",l[10]),ve(e,"is-success",l[11]||l[12]),ve(e,"is-warning",l[9]),ve(e,"is-danger",l[8]),ve(e,"user-message",l[10]||l[9]),ve(e,"assistant-message",l[8]||l[11]||l[12]),ve(e,"summarized",l[0].summarized),ve(e,"suppress",l[0].suppress),ve(e,"editing",l[1]),ve(e,"streaming",l[0].streaming),ve(e,"incomplete",l[0].finish_reason==="length")},m(pe,Ee){D(pe,e,Ee),V(e,t),B[n].m(t,null),V(t,r),Ae&&Ae.m(t,null),V(e,c),V(e,i),V(e,s),V(e,o),V(o,I),x&&x.m(I,null),V(I,m),M&&M.m(I,null),V(I,u),Ie&&Ie.m(I,null),V(I,p),Xe&&Xe.m(I,null),V(I,R),Ge&&Ge.m(I,null),V(I,E),Ze&&Ze.m(I,null),V(I,W),oe&&oe.m(I,null),V(I,X),_e&&_e.m(I,null),V(I,f),V(I,Q),V(Q,F),Fe(A,F,null),V(I,Y),se&&se.m(I,null),k=!0,ae||(P=Qe(Q,"click",Vt(l[40])),ae=!0)},p(pe,Ee){let Te=n;n=re(pe),n===Te?B[n].p(pe,Ee):(ot(),L(B[Te],1,1,()=>{B[Te]=null}),It(),a=B[n],a?a.p(pe,Ee):(a=B[n]=j[n](pe),a.c()),H(a,1),a.m(t,r)),we===(we=ge(pe))&&Ae?Ae.p(pe,Ee):(Ae&&Ae.d(1),Ae=we&&we(pe),Ae&&(Ae.c(),Ae.m(t,null))),pe[0].finish_reason==="length"||pe[0].finish_reason==="abort"?x?(x.p(pe,Ee),Ee[0]&1&&H(x,1)):(x=Yd(pe),x.c(),H(x,1),x.m(I,m)):x&&(ot(),L(x,1,1,()=>{x=null}),It()),pe[0].summarized?M?(M.p(pe,Ee),Ee[0]&1&&H(M,1)):(M=wd(pe),M.c(),H(M,1),M.m(I,u)):M&&(ot(),L(M,1,1,()=>{M=null}),It()),pe[0].summary?Ie?(Ie.p(pe,Ee),Ee[0]&1&&H(Ie,1)):(Ie=Ad(pe),Ie.c(),H(Ie,1),Ie.m(I,p)):Ie&&(ot(),L(Ie,1,1,()=>{Ie=null}),It()),pe[12]||Xe.p(pe,Ee),pe[0].summarized?Ge&&(ot(),L(Ge,1,1,()=>{Ge=null}),It()):Ge?(Ge.p(pe,Ee),Ee[0]&1&&H(Ge,1)):(Ge=fd(pe),Ge.c(),H(Ge,1),Ge.m(I,E)),!pe[12]&&!pe[0].summarized&&!pe[8]?Ze?(Ze.p(pe,Ee),Ee[0]&1&&H(Ze,1)):(Ze=Sd(pe),Ze.c(),H(Ze,1),Ze.m(I,W)):Ze&&(ot(),L(Ze,1,1,()=>{Ze=null}),It()),!pe[12]&&!pe[0].summarized&&!pe[9]&&!pe[8]?oe?(oe.p(pe,Ee),Ee[0]&1&&H(oe,1)):(oe=Qd(pe),oe.c(),H(oe,1),oe.m(I,X)):oe&&(ot(),L(oe,1,1,()=>{oe=null}),It()),pe[12]||_e.p(pe,Ee),pe[3]?se?(se.p(pe,Ee),Ee[0]&8&&H(se,1)):(se=Hd(pe),se.c(),H(se,1),se.m(I,null)):se&&(ot(),L(se,1,1,()=>{se=null}),It()),(!k||Ee[0]&1&&J!==(J="message-"+pe[0].uuid))&&h(e,"id",J),(!k||Ee[0]&1)&&ve(e,"summarized",pe[0].summarized),(!k||Ee[0]&1)&&ve(e,"suppress",pe[0].suppress),(!k||Ee[0]&2)&&ve(e,"editing",pe[1]),(!k||Ee[0]&1)&&ve(e,"streaming",pe[0].streaming),(!k||Ee[0]&1)&&ve(e,"incomplete",pe[0].finish_reason==="length")},i(pe){k||(H(a),H(x),H(M),H(Ie),H(Xe),H(Ge),H(Ze),H(oe),H(_e),H(A.$$.fragment,pe),H(se),k=!0)},o(pe){L(a),L(x),L(M),L(Ie),L(Xe),L(Ge),L(Ze),L(oe),L(_e),L(A.$$.fragment,pe),L(se),k=!1},d(pe){pe&&z(e),B[n].d(),Ae&&Ae.d(),x&&x.d(),M&&M.d(),Ie&&Ie.d(),Xe&&Xe.d(),Ge&&Ge.d(),Ze&&Ze.d(),oe&&oe.d(),_e&&_e.d(),Ye(A),se&&se.d(),ae=!1,P()}}}function nX(l,e,t){let n,a,r;tl(l,B1,Je=>t(46,a=Je)),tl(l,O1,Je=>t(47,r=Je));let{message:c}=e,{chatId:i}=e,{chat:s}=e;const o=c.role==="error",I=c.role==="system",m=c.role==="user",u=c.role==="assistant",p=c.role==="image",R={gfm:!0,breaks:!0,mangle:!1},E={code:Xv,codespan:fv},W=()=>{const Je=c.content;if(I&&n.hideSystemPrompt){const Ce=Je.match(/::NOTE::[\s\S]+?::NOTE::/g);return Ce?Ce.map(it=>it.replace(/::NOTE::([\s\S]+?)::NOTE::/,"$1")).join(""):"(hidden)"}return Je},X=w2();let f=!1,Q,F,A,Y=0,J=c.content;sa(()=>{t(2,F=n.model),c!=null&&c.image&&h7(c.image.id).then(Je=>{t(3,A="data:image/png;base64, "+Je.b64image)}),t(5,J=W())}),Ta(()=>{c.streaming&&c.content.slice(-5).includes("```")&&t(4,Y++,Y),t(5,J=W())});const k=()=>{c.summarized||c.streaming||f||(t(1,f=!0),Q=c.content,setTimeout(()=>{const Je=document.getElementById("edit-"+c.uuid);Je&&Je.focus()},0))};let ae;const P=()=>{clearTimeout(ae),ae=setTimeout(()=>{j()},250)},j=()=>{c.content!==Q&&(X("change",c),S0(i))},B=()=>{t(1,f=!1),d9(i,c.uuid),wl(O1,r=c.uuid,r)},re=()=>{j(),t(1,f=!1)},ge=Je=>{if(Je.key==="Escape"){if(!f)return;Je.stopPropagation(),Je.preventDefault(),t(0,c.content=Q,c),t(1,f=!1)}if(Je.ctrlKey&&Je.key==="Enter"){if(!f)return;Je.stopPropagation(),Je.preventDefault(),re(),Ge(),setTimeout(Ge,10)}};let we=0;const Ae=()=>{const Ce=new Date().getTime()-we;Ce<400&&Ce>0&&k(),we=new Date().getTime()};let x=0;const M=()=>{if(clearTimeout(Xe),t(7,Xe=0),!x){t(6,x=setTimeout(()=>{t(6,x=0)},1e3));return}if(clearTimeout(x),t(6,x=0),c.summarized){hn("Sorry, you can't delete a summarized message");return}if(c.summary)ma(Ka,{title:"Delete Summary",message:"

Are you sure you want to delete this summary?

Your session may be too long to submit again after you do.

",asHtml:!0,class:"is-warning",confirmButtonClass:"is-warning",confirmButton:"Delete Summary",onConfirm:()=>{try{em(i,c.uuid)}catch(Je){hn("Unable to delete summary:",Je)}}});else try{dr(i,c.uuid)}catch(Je){hn("Unable to delete:",Je)}},Ie=Je=>{if(u){const Ce=/([\s\S]*?)<\/think>/,it=Je.match(Ce);it&&(t(0,c.reason=it[1],c),Je=Je.replace(Ce,""))}else t(0,c.reason="",c);return Je};let Xe=0;const Ge=()=>{if(clearTimeout(x),t(6,x=0),!Xe){t(7,Xe=setTimeout(()=>{t(7,Xe=0)},1e3));return}if(clearTimeout(Xe),t(7,Xe=0),c.summarized){hn("Sorry, you can't truncate a summarized message");return}try{d9(i,c.uuid),wl(B1,a=!0,a)}catch(Je){hn("Unable to delete:",Je)}},Ze=Je=>{if(c.summarized){hn("Sorry, you can't suppress a summarized message");return}t(0,c.suppress=Je,c),S0(i)},oe=()=>{var it;const Je=((c==null?void 0:c.content)||`${s.name}-image-${(it=c==null?void 0:c.image)==null?void 0:it.id}`).replace(/([^a-z0-9- ]|\.)+/gi,"_").trim().slice(0,80),Ce=document.createElement("a");Ce.download=`${Je}.png`,Ce.href=A,document.body.appendChild(Ce),Ce.click(),document.body.removeChild(Ce)},_e=Je=>{let Ce="",it=0;for(;it{t(5,J=_e(c.content))};function pe(){c.content=this.innerText,t(0,c)}const Ee=()=>{m&&k()},Te=()=>{B()},ue=()=>{C1(c.summarized)},bt=()=>{C1(c.summary)},He=()=>{k()},Ue=()=>{M()},gt=()=>{Ge()},ht=()=>{Ze(!c.suppress)},ye=()=>{navigator.clipboard.writeText(c.content)},tt=()=>{se()},Et=()=>{oe()};return l.$$set=Je=>{"message"in Je&&t(0,c=Je.message),"chatId"in Je&&t(28,i=Je.chatId),"chat"in Je&&t(29,s=Je.chat)},l.$$.update=()=>{l.$$.dirty[0]&536870912&&(n=s.settings)},[c,f,F,A,Y,J,x,Xe,o,I,m,u,p,R,E,k,P,B,re,ge,Ae,M,Ie,Ge,Ze,oe,_e,se,i,s,pe,Ee,Te,ue,bt,He,Ue,gt,ht,ye,tt,Et]}class aX extends Ht{constructor(e){super(),Qt(this,e,nX,lX,yt,{message:0,chatId:28,chat:29},null,[-1,-1])}}function Ld(l,e,t){const n=l.slice();return n[6]=e[t],n[7]=e,n[8]=t,n}function Td(l){let e=l[6].uuid,t,n,a=Cd(l);return{c(){a.c(),t=vt()},m(r,c){a.m(r,c),D(r,t,c),n=!0},p(r,c){c&1&&yt(e,e=r[6].uuid)?(ot(),L(a,1,1,lt),It(),a=Cd(r),a.c(),H(a,1),a.m(t.parentNode,t)):a.p(r,c)},i(r){n||(H(a),n=!0)},o(r){L(a),n=!1},d(r){r&&z(t),a.d(r)}}}function Cd(l){let e,t,n;function a(c){l[5](c,l[6],l[7],l[8])}let r={chatId:l[1],chat:l[2]};return l[6]!==void 0&&(r.message=l[6]),e=new aX({props:r}),_n.push(()=>_2(e,"message",a)),{c(){fe(e.$$.fragment)},m(c,i){Fe(e,c,i),n=!0},p(c,i){l=c;const s={};i&2&&(s.chatId=l[1]),i&4&&(s.chat=l[2]),!t&&i&1&&(t=!0,s.message=l[6],y2(()=>t=!1)),e.$set(s)},i(c){n||(H(e.$$.fragment,c),n=!0)},o(c){L(e.$$.fragment,c),n=!1},d(c){Ye(e,c)}}}function kd(l){let e,t,n=!(l[6].summarized&&l[4].hideSummarized)&&!(l[8]===0&&l[6].role==="system"&&!l[3].useSystemPrompt)&&Td(l);return{c(){n&&n.c(),e=vt()},m(a,r){n&&n.m(a,r),D(a,e,r),t=!0},p(a,r){!(a[6].summarized&&a[4].hideSummarized)&&!(a[8]===0&&a[6].role==="system"&&!a[3].useSystemPrompt)?n?(n.p(a,r),r&25&&H(n,1)):(n=Td(a),n.c(),H(n,1),n.m(e.parentNode,e)):n&&(ot(),L(n,1,1,()=>{n=null}),It())},i(a){t||(H(n),t=!0)},o(a){L(n),t=!1},d(a){n&&n.d(a),a&&z(e)}}}function rX(l){let e,t,n=l[0],a=[];for(let c=0;cL(a[c],1,1,()=>{a[c]=null});return{c(){for(let c=0;ct(4,a=o));let{messages:r}=e,{chatId:c}=e,{chat:i}=e;function s(o,I,m,u){m[u]=o,t(0,r)}return l.$$set=o=>{"messages"in o&&t(0,r=o.messages),"chatId"in o&&t(1,c=o.chatId),"chat"in o&&t(2,i=o.chat)},l.$$.update=()=>{l.$$.dirty&4&&t(3,n=i.settings)},[r,c,i,n,a,s]}class iX extends Ht{constructor(e){super(),Qt(this,e,cX,rX,yt,{messages:0,chatId:1,chat:2})}}function Jd(l,e,t){const n=l.slice();return n[25]=e[t],n}function Ud(l,e,t){const n=l.slice();return n[28]=e[t],n}function xd(l){let e,t,n,a,r,c,i,s,o=l[6]&&Md(l);function I(W,X){return W[0].type==="boolean"?IX:W[0].type==="textarea"?oX:sX}let m=I(l),u=m(l);const p=[bX,mX,dX],R=[];function E(W,X){return W[0].type==="number"?0:W[0].type==="select"||W[0].type==="select-number"?1:W[0].type==="text"?2:-1}return~(c=E(l))&&(i=R[c]=p[c](l)),{c(){o&&o.c(),e=he(),t=_("div"),u.c(),n=he(),a=_("div"),r=_("div"),i&&i.c(),h(r,"class","field"),ve(r,"has-addons",l[4].length),h(a,"class","field-body"),h(t,"class","field is-horizontal")},m(W,X){o&&o.m(W,X),D(W,e,X),D(W,t,X),u.m(t,null),V(t,n),V(t,a),V(a,r),~c&&R[c].m(r,null),s=!0},p(W,X){W[6]?o?o.p(W,X):(o=Md(W),o.c(),o.m(e.parentNode,e)):o&&(o.d(1),o=null),m===(m=I(W))&&u?u.p(W,X):(u.d(1),u=m(W),u&&(u.c(),u.m(t,n)));let f=c;c=E(W),c===f?~c&&R[c].p(W,X):(i&&(ot(),L(R[f],1,1,()=>{R[f]=null}),It()),~c?(i=R[c],i?i.p(W,X):(i=R[c]=p[c](W),i.c()),H(i,1),i.m(r,null)):i=null),(!s||X&16)&&ve(r,"has-addons",W[4].length)},i(W){s||(H(i),s=!0)},o(W){L(i),s=!1},d(W){o&&o.d(W),W&&z(e),W&&z(t),u.d(),~c&&R[c].d()}}}function Md(l){let e,t;return{c(){e=_("p"),h(e,"class",t="notification "+l[7])},m(n,a){D(n,e,a),e.innerHTML=l[6]},p(n,a){a&64&&(e.innerHTML=n[6]),a&128&&t!==(t="notification "+n[7])&&h(e,"class",t)},d(n){n&&z(e)}}}function sX(l){let e,t,n=l[0].name+"",a,r,c;return{c(){e=_("div"),t=_("label"),a=ut(n),h(t,"class","label"),h(t,"for",r="settings-"+l[0].key),h(t,"title",c=l[0].title),h(e,"class","field-label is-normal")},m(i,s){D(i,e,s),V(e,t),V(t,a)},p(i,s){s&1&&n!==(n=i[0].name+"")&&bl(a,n),s&1&&r!==(r="settings-"+i[0].key)&&h(t,"for",r),s&1&&c!==(c=i[0].title)&&h(t,"title",c)},d(i){i&&z(e)}}}function oX(l){let e,t,n=l[0].name+"",a,r,c,i,s,o,I,m,u;return{c(){e=_("div"),t=_("label"),a=ut(n),i=he(),s=_("textarea"),h(t,"class","label"),h(t,"for",r="settings-"+l[0].key),h(t,"title",c=l[0].title),h(s,"class","input is-info is-focused chat-input auto-size"),h(s,"placeholder",o=l[8]||""),h(s,"rows","1"),s.value=I=l[1][l[0].key],h(e,"class","field is-normal"),On(e,"width","100%")},m(p,R){D(p,e,R),V(e,t),V(t,a),V(e,i),V(e,s),m||(u=[Qe(s,"input",l[15]),Qe(s,"change",l[16])],m=!0)},p(p,R){R&1&&n!==(n=p[0].name+"")&&bl(a,n),R&1&&r!==(r="settings-"+p[0].key)&&h(t,"for",r),R&1&&c!==(c=p[0].title)&&h(t,"title",c),R&256&&o!==(o=p[8]||"")&&h(s,"placeholder",o),R&3&&I!==(I=p[1][p[0].key])&&(s.value=I)},d(p){p&&z(e),m=!1,Hl(u)}}}function IX(l){let e,t,n,a,r,c,i,s=l[0].name+"",o,I,m,u,p;return{c(){e=_("div"),t=_("label"),n=_("input"),i=he(),o=ut(s),h(n,"type","checkbox"),h(n,"title",a=l[0].title),h(n,"class","checkbox"),h(n,"id",r="settings-"+l[0].key),n.checked=c=!!l[1][l[0].key],h(t,"class","label"),h(t,"for",I="settings-"+l[0].key),h(t,"title",m=l[0].title),h(e,"class","field is-normal")},m(R,E){D(R,e,E),V(e,t),V(t,n),V(t,i),V(t,o),u||(p=Qe(n,"click",l[14]),u=!0)},p(R,E){E&1&&a!==(a=R[0].title)&&h(n,"title",a),E&1&&r!==(r="settings-"+R[0].key)&&h(n,"id",r),E&3&&c!==(c=!!R[1][R[0].key])&&(n.checked=c),E&1&&s!==(s=R[0].name+"")&&bl(o,s),E&1&&I!==(I="settings-"+R[0].key)&&h(t,"for",I),E&1&&m!==(m=R[0].title)&&h(t,"title",m)},d(R){R&&z(e),u=!1,p()}}}function dX(l){let e,t,n,a,r,c,i;return{c(){e=_("div"),t=_("input"),h(t,"type","text"),h(t,"title",n=l[0].title),h(t,"class","input"),t.value=a=l[1][l[0].key],h(t,"placeholder",r=String(l[8]||l[2][l[0].key])),h(e,"class","field")},m(s,o){D(s,e,o),V(e,t),c||(i=Qe(t,"change",l[20]),c=!0)},p(s,o){o&1&&n!==(n=s[0].title)&&h(t,"title",n),o&3&&a!==(a=s[1][s[0].key])&&t.value!==a&&(t.value=a),o&261&&r!==(r=String(s[8]||s[2][s[0].key]))&&h(t,"placeholder",r)},i:lt,o:lt,d(s){s&&z(e),c=!1,i()}}}function mX(l){let e,t=l[3],n,a,r,c=Od(l),i=l[4],s=[];for(let I=0;IL(s[I],1,1,()=>{s[I]=null});return{c(){e=_("div"),c.c(),n=he();for(let I=0;I{I=null}),It()),l[25].icon?m?(m.p(l,R),R&16&&H(m,1)):(m=Dd(l),m.c(),H(m,1),m.m(t,null)):m&&(ot(),L(m,1,1,()=>{m=null}),It()),(!i||R&16&&a!==(a=l[25].text))&&h(t,"title",a),(!i||R&16&&r!==(r="button "+(l[25].class||"")))&&h(t,"class",r)},i(p){i||(H(I),H(m),i=!0)},o(p){L(I),L(m),i=!1},d(p){p&&z(e),I&&I.d(),m&&m.d(),s=!1,o()}}}function uX(l){let e,t,n=l[5]&&xd(l);return{c(){n&&n.c(),e=vt()},m(a,r){n&&n.m(a,r),D(a,e,r),t=!0},p(a,[r]){a[5]?n?(n.p(a,r),r&32&&H(n,1)):(n=xd(a),n.c(),H(n,1),n.m(e.parentNode,e)):n&&(ot(),L(n,1,1,()=>{n=null}),It())},i(a){t||(H(n),t=!0)},o(a){L(n),t=!1},d(a){n&&n.d(a),a&&z(e)}}}function pX(l,e,t){let{setting:n}=e,{chatSettings:a}=e,{chat:r}=e,{chatDefaults:c}=e,{originalProfile:i}=e,{rkey:s=0}=e,o;const I=r.id;let m=!1,u=h2(I,n.header),p=h2(I,n.headerClass),R=h2(I,n.placeholder);const E=()=>{t(4,o=(n.fieldControls||[]).map(B=>B.getAction(I,n,a[n.key])))};E(),sa(()=>{t(5,m=typeof n.hide!="function"||!n.hide(I,n)),E()}),Ta(()=>{t(5,m=typeof n.hide!="function"||!n.hide(I,n)),t(6,u=h2(I,n.header)),t(7,p=h2(I,n.headerClass)),t(8,R=h2(I,n.placeholder)),E()});const W=w2(),X=()=>{W("refresh")},f={profile:[{title:"Unsaved Profile Changes",message:`Unsaved changes to the current profile will be lost. + tokens ~= `),I=_("span"),m=ut("$"),p=ut(u),h(c,"class","has-text-weight-bold"),h(I,"class","has-text-weight-bold"),h(e,"class","is-size-7 message-note")},m(R,E){D(R,e,E),V(e,t),V(t,a),V(e,r),V(e,c),V(c,s),V(e,o),V(e,I),V(I,m),V(I,p)},p(R,E){E[0]&5&&n!==(n=(Nl(R[0].model||"").label||R[0].model||R[2])+"")&&bl(a,n),E[0]&1&&i!==(i=R[0].usage.total_tokens+"")&&bl(s,i),E[0]&5&&u!==(u=k1(R[0].usage,R[0].model||R[2]).toFixed(6)+"")&&bl(p,u)},d(R){R&&z(e)}}}function z_(l){let e;return{c(){e=_("p"),e.textContent="System Prompt",h(e,"class","is-size-7 message-note")},m(t,n){D(t,e,n)},p:lt,d(t){t&&z(e)}}}function Yd(l){let e,t,n,a,r,c;return n=new Rt({props:{icon:Fs}}),{c(){e=_("a"),t=_("span"),fe(n.$$.fragment),h(t,"class","icon"),h(e,"href","#"),h(e,"title","Continue "),h(e,"class","msg-incomplete button is-small")},m(i,s){D(i,e,s),V(e,t),Fe(n,t,null),a=!0,r||(c=Qe(e,"click",Vt(l[32])),r=!0)},p:lt,i(i){a||(H(n.$$.fragment,i),a=!0)},o(i){L(n.$$.fragment,i),a=!1},d(i){i&&z(e),Ye(n),r=!1,c()}}}function wd(l){let e,t,n,a,r,c;return n=new Rt({props:{icon:iG}}),{c(){e=_("a"),t=_("span"),fe(n.$$.fragment),h(t,"class","icon"),h(e,"href","#"),h(e,"title","Jump to summary"),h(e,"class","msg-summary button is-small")},m(i,s){D(i,e,s),V(e,t),Fe(n,t,null),a=!0,r||(c=Qe(e,"click",Vt(l[33])),r=!0)},p:lt,i(i){a||(H(n.$$.fragment,i),a=!0)},o(i){L(n.$$.fragment,i),a=!1},d(i){i&&z(e),Ye(n),r=!1,c()}}}function Ad(l){let e,t,n,a,r,c;return n=new Rt({props:{icon:Kp}}),{c(){e=_("a"),t=_("span"),fe(n.$$.fragment),h(t,"class","icon"),h(e,"href","#"),h(e,"title","Jump to summarized"),h(e,"class","msg-summarized button is-small")},m(i,s){D(i,e,s),V(e,t),Fe(n,t,null),a=!0,r||(c=Qe(e,"click",Vt(l[34])),r=!0)},p:lt,i(i){a||(H(n.$$.fragment,i),a=!0)},o(i){L(n.$$.fragment,i),a=!1},d(i){i&&z(e),Ye(n),r=!1,c()}}}function D_(l){let e,t,n,a,r,c;return n=new Rt({props:{icon:S7}}),{c(){e=_("a"),t=_("span"),fe(n.$$.fragment),h(t,"class","icon"),h(e,"href","#"),h(e,"title","Edit"),h(e,"class","msg-image button is-small")},m(i,s){D(i,e,s),V(e,t),Fe(n,t,null),a=!0,r||(c=Qe(e,"click",Vt(l[35])),r=!0)},p:lt,i(i){a||(H(n.$$.fragment,i),a=!0)},o(i){L(n.$$.fragment,i),a=!1},d(i){i&&z(e),Ye(n),r=!1,c()}}}function fd(l){let e,t,n,a,r,c;const i=[K_,P_],s=[];function o(I,m){return I[6]?0:1}return t=o(l),n=s[t]=i[t](l),{c(){e=_("a"),n.c(),h(e,"href","#"),h(e,"title","Delete this message"),h(e,"class","msg-delete button is-small")},m(I,m){D(I,e,m),s[t].m(e,null),a=!0,r||(c=Qe(e,"click",Vt(l[36])),r=!0)},p(I,m){let u=t;t=o(I),t===u?s[t].p(I,m):(ot(),L(s[u],1,1,()=>{s[u]=null}),It(),n=s[t],n?n.p(I,m):(n=s[t]=i[t](I),n.c()),H(n,1),n.m(e,null))},i(I){a||(H(n),a=!0)},o(I){L(n),a=!1},d(I){I&&z(e),s[t].d(),r=!1,c()}}}function P_(l){let e,t,n;return t=new Rt({props:{icon:sr}}),{c(){e=_("span"),fe(t.$$.fragment),h(e,"class","icon")},m(a,r){D(a,e,r),Fe(t,e,null),n=!0},p:lt,i(a){n||(H(t.$$.fragment,a),n=!0)},o(a){L(t.$$.fragment,a),n=!1},d(a){a&&z(e),Ye(t)}}}function K_(l){let e,t,n;return t=new Rt({props:{icon:ir}}),{c(){e=_("span"),fe(t.$$.fragment),h(e,"class","icon")},m(a,r){D(a,e,r),Fe(t,e,null),n=!0},p:lt,i(a){n||(H(t.$$.fragment,a),n=!0)},o(a){L(t.$$.fragment,a),n=!1},d(a){a&&z(e),Ye(t)}}}function Sd(l){let e,t,n,a,r,c;const i=[q_,j_],s=[];function o(I,m){return I[7]?0:1}return t=o(l),n=s[t]=i[t](l),{c(){e=_("a"),n.c(),h(e,"href","#"),h(e,"title","Truncate from here and send"),h(e,"class","msg-truncate button is-small")},m(I,m){D(I,e,m),s[t].m(e,null),a=!0,r||(c=Qe(e,"click",Vt(l[37])),r=!0)},p(I,m){let u=t;t=o(I),t===u?s[t].p(I,m):(ot(),L(s[u],1,1,()=>{s[u]=null}),It(),n=s[t],n?n.p(I,m):(n=s[t]=i[t](I),n.c()),H(n,1),n.m(e,null))},i(I){a||(H(n),a=!0)},o(I){L(n),a=!1},d(I){I&&z(e),s[t].d(),r=!1,c()}}}function j_(l){let e,t,n;return t=new Rt({props:{icon:J7}}),{c(){e=_("span"),fe(t.$$.fragment),h(e,"class","icon")},m(a,r){D(a,e,r),Fe(t,e,null),n=!0},p:lt,i(a){n||(H(t.$$.fragment,a),n=!0)},o(a){L(t.$$.fragment,a),n=!1},d(a){a&&z(e),Ye(t)}}}function q_(l){let e,t,n;return t=new Rt({props:{icon:ir}}),{c(){e=_("span"),fe(t.$$.fragment),h(e,"class","icon")},m(a,r){D(a,e,r),Fe(t,e,null),n=!0},p:lt,i(a){n||(H(t.$$.fragment,a),n=!0)},o(a){L(t.$$.fragment,a),n=!1},d(a){a&&z(e),Ye(t)}}}function Qd(l){let e,t,n,a,r,c,i;const s=[eX,$_],o=[];function I(m,u){return m[0].suppress?0:1}return t=I(l),n=o[t]=s[t](l),{c(){e=_("a"),n.c(),h(e,"href","#"),h(e,"title",a=(l[0].suppress?"Uns":"S")+"uppress message from submission"),h(e,"class","msg-supress button is-small")},m(m,u){D(m,e,u),o[t].m(e,null),r=!0,c||(i=Qe(e,"click",Vt(l[38])),c=!0)},p(m,u){let p=t;t=I(m),t===p?o[t].p(m,u):(ot(),L(o[p],1,1,()=>{o[p]=null}),It(),n=o[t],n?n.p(m,u):(n=o[t]=s[t](m),n.c()),H(n,1),n.m(e,null)),(!r||u[0]&1&&a!==(a=(m[0].suppress?"Uns":"S")+"uppress message from submission"))&&h(e,"title",a)},i(m){r||(H(n),r=!0)},o(m){L(n),r=!1},d(m){m&&z(e),o[t].d(),c=!1,i()}}}function $_(l){let e,t,n;return t=new Rt({props:{icon:Q7}}),{c(){e=_("span"),fe(t.$$.fragment),h(e,"class","icon")},m(a,r){D(a,e,r),Fe(t,e,null),n=!0},p:lt,i(a){n||(H(t.$$.fragment,a),n=!0)},o(a){L(t.$$.fragment,a),n=!1},d(a){a&&z(e),Ye(t)}}}function eX(l){let e,t,n;return t=new Rt({props:{icon:L7}}),{c(){e=_("span"),fe(t.$$.fragment),h(e,"class","icon")},m(a,r){D(a,e,r),Fe(t,e,null),n=!0},p:lt,i(a){n||(H(t.$$.fragment,a),n=!0)},o(a){L(t.$$.fragment,a),n=!1},d(a){a&&z(e),Ye(t)}}}function tX(l){let e,t,n,a,r,c;return n=new Rt({props:{icon:tG}}),{c(){e=_("a"),t=_("span"),fe(n.$$.fragment),h(t,"class","icon"),h(e,"href","#"),h(e,"title","Copy to Clipboard"),h(e,"class","msg-image button is-small")},m(i,s){D(i,e,s),V(e,t),Fe(n,t,null),a=!0,r||(c=Qe(e,"click",Vt(l[39])),r=!0)},p:lt,i(i){a||(H(n.$$.fragment,i),a=!0)},o(i){L(n.$$.fragment,i),a=!1},d(i){i&&z(e),Ye(n),r=!1,c()}}}function Hd(l){let e,t,n,a,r,c;return n=new Rt({props:{icon:w0}}),{c(){e=_("a"),t=_("span"),fe(n.$$.fragment),h(t,"class","icon"),h(e,"href","#"),h(e,"title","Download Image"),h(e,"class","msg-image button is-small")},m(i,s){D(i,e,s),V(e,t),Fe(n,t,null),a=!0,r||(c=Qe(e,"click",Vt(l[41])),r=!0)},p:lt,i(i){a||(H(n.$$.fragment,i),a=!0)},o(i){L(n.$$.fragment,i),a=!1},d(i){i&&z(e),Ye(n),r=!1,c()}}}function lX(l){let e,t,n,a,r,c,i,s,o,I,m,u,p,R,E,W,X,f,Q,F,A,Y,J,k,ae,P;const j=[B_,M_],B=[];function re(pe,Ee){return pe[1]?0:1}n=re(l),a=B[n]=j[n](l);function ge(pe,Ee){if(pe[9])return z_;if(pe[0].usage)return O_}let we=ge(l),Ae=we&&we(l),x=(l[0].finish_reason==="length"||l[0].finish_reason==="abort")&&Yd(l),M=l[0].summarized&&wd(l),Ie=l[0].summary&&Ad(l),Xe=!l[12]&&D_(l),Ge=!l[0].summarized&&fd(l),Ze=!l[12]&&!l[0].summarized&&!l[8]&&Sd(l),oe=!l[12]&&!l[0].summarized&&!l[9]&&!l[8]&&Qd(l),_e=!l[12]&&tX(l);A=new Rt({props:{icon:cG}});let se=l[3]&&Hd(l);return{c(){e=_("article"),t=_("div"),a.c(),r=he(),Ae&&Ae.c(),c=he(),i=_("div"),s=he(),o=_("div"),I=_("div"),x&&x.c(),m=he(),M&&M.c(),u=he(),Ie&&Ie.c(),p=he(),Xe&&Xe.c(),R=he(),Ge&&Ge.c(),E=he(),Ze&&Ze.c(),W=he(),oe&&oe.c(),X=he(),_e&&_e.c(),f=he(),Q=_("a"),F=_("span"),fe(A.$$.fragment),Y=he(),se&&se.c(),h(t,"class","message-body content"),h(i,"class","tool-drawer-mask"),h(F,"class","icon"),h(Q,"href","#"),h(Q,"title","Render LaTeX in message"),h(Q,"class","button is-small"),h(I,"class","button-pack"),h(o,"class","tool-drawer"),h(e,"id",J="message-"+l[0].uuid),h(e,"class","message chat-message"),ve(e,"is-info",l[10]),ve(e,"is-success",l[11]||l[12]),ve(e,"is-warning",l[9]),ve(e,"is-danger",l[8]),ve(e,"user-message",l[10]||l[9]),ve(e,"assistant-message",l[8]||l[11]||l[12]),ve(e,"summarized",l[0].summarized),ve(e,"suppress",l[0].suppress),ve(e,"editing",l[1]),ve(e,"streaming",l[0].streaming),ve(e,"incomplete",l[0].finish_reason==="length")},m(pe,Ee){D(pe,e,Ee),V(e,t),B[n].m(t,null),V(t,r),Ae&&Ae.m(t,null),V(e,c),V(e,i),V(e,s),V(e,o),V(o,I),x&&x.m(I,null),V(I,m),M&&M.m(I,null),V(I,u),Ie&&Ie.m(I,null),V(I,p),Xe&&Xe.m(I,null),V(I,R),Ge&&Ge.m(I,null),V(I,E),Ze&&Ze.m(I,null),V(I,W),oe&&oe.m(I,null),V(I,X),_e&&_e.m(I,null),V(I,f),V(I,Q),V(Q,F),Fe(A,F,null),V(I,Y),se&&se.m(I,null),k=!0,ae||(P=Qe(Q,"click",Vt(l[40])),ae=!0)},p(pe,Ee){let Te=n;n=re(pe),n===Te?B[n].p(pe,Ee):(ot(),L(B[Te],1,1,()=>{B[Te]=null}),It(),a=B[n],a?a.p(pe,Ee):(a=B[n]=j[n](pe),a.c()),H(a,1),a.m(t,r)),we===(we=ge(pe))&&Ae?Ae.p(pe,Ee):(Ae&&Ae.d(1),Ae=we&&we(pe),Ae&&(Ae.c(),Ae.m(t,null))),pe[0].finish_reason==="length"||pe[0].finish_reason==="abort"?x?(x.p(pe,Ee),Ee[0]&1&&H(x,1)):(x=Yd(pe),x.c(),H(x,1),x.m(I,m)):x&&(ot(),L(x,1,1,()=>{x=null}),It()),pe[0].summarized?M?(M.p(pe,Ee),Ee[0]&1&&H(M,1)):(M=wd(pe),M.c(),H(M,1),M.m(I,u)):M&&(ot(),L(M,1,1,()=>{M=null}),It()),pe[0].summary?Ie?(Ie.p(pe,Ee),Ee[0]&1&&H(Ie,1)):(Ie=Ad(pe),Ie.c(),H(Ie,1),Ie.m(I,p)):Ie&&(ot(),L(Ie,1,1,()=>{Ie=null}),It()),pe[12]||Xe.p(pe,Ee),pe[0].summarized?Ge&&(ot(),L(Ge,1,1,()=>{Ge=null}),It()):Ge?(Ge.p(pe,Ee),Ee[0]&1&&H(Ge,1)):(Ge=fd(pe),Ge.c(),H(Ge,1),Ge.m(I,E)),!pe[12]&&!pe[0].summarized&&!pe[8]?Ze?(Ze.p(pe,Ee),Ee[0]&1&&H(Ze,1)):(Ze=Sd(pe),Ze.c(),H(Ze,1),Ze.m(I,W)):Ze&&(ot(),L(Ze,1,1,()=>{Ze=null}),It()),!pe[12]&&!pe[0].summarized&&!pe[9]&&!pe[8]?oe?(oe.p(pe,Ee),Ee[0]&1&&H(oe,1)):(oe=Qd(pe),oe.c(),H(oe,1),oe.m(I,X)):oe&&(ot(),L(oe,1,1,()=>{oe=null}),It()),pe[12]||_e.p(pe,Ee),pe[3]?se?(se.p(pe,Ee),Ee[0]&8&&H(se,1)):(se=Hd(pe),se.c(),H(se,1),se.m(I,null)):se&&(ot(),L(se,1,1,()=>{se=null}),It()),(!k||Ee[0]&1&&J!==(J="message-"+pe[0].uuid))&&h(e,"id",J),(!k||Ee[0]&1)&&ve(e,"summarized",pe[0].summarized),(!k||Ee[0]&1)&&ve(e,"suppress",pe[0].suppress),(!k||Ee[0]&2)&&ve(e,"editing",pe[1]),(!k||Ee[0]&1)&&ve(e,"streaming",pe[0].streaming),(!k||Ee[0]&1)&&ve(e,"incomplete",pe[0].finish_reason==="length")},i(pe){k||(H(a),H(x),H(M),H(Ie),H(Xe),H(Ge),H(Ze),H(oe),H(_e),H(A.$$.fragment,pe),H(se),k=!0)},o(pe){L(a),L(x),L(M),L(Ie),L(Xe),L(Ge),L(Ze),L(oe),L(_e),L(A.$$.fragment,pe),L(se),k=!1},d(pe){pe&&z(e),B[n].d(),Ae&&Ae.d(),x&&x.d(),M&&M.d(),Ie&&Ie.d(),Xe&&Xe.d(),Ge&&Ge.d(),Ze&&Ze.d(),oe&&oe.d(),_e&&_e.d(),Ye(A),se&&se.d(),ae=!1,P()}}}function nX(l,e,t){let n,a,r;tl(l,B1,Je=>t(46,a=Je)),tl(l,O1,Je=>t(47,r=Je));let{message:c}=e,{chatId:i}=e,{chat:s}=e;const o=c.role==="error",I=c.role==="system",m=c.role==="user",u=c.role==="assistant",p=c.role==="image",R={gfm:!0,breaks:!0,mangle:!1},E={code:Xv,codespan:fv},W=()=>{const Je=c.content;if(I&&n.hideSystemPrompt){const Ce=Je.match(/::NOTE::[\s\S]+?::NOTE::/g);return Ce?Ce.map(it=>it.replace(/::NOTE::([\s\S]+?)::NOTE::/,"$1")).join(""):"(hidden)"}return Je},X=w2();let f=!1,Q,F,A,Y=0,J=c.content;sa(()=>{t(2,F=n.model),c!=null&&c.image&&h7(c.image.id).then(Je=>{t(3,A="data:image/png;base64, "+Je.b64image)}),t(5,J=W())}),Ta(()=>{c.streaming&&c.content.slice(-5).includes("```")&&t(4,Y++,Y),t(5,J=W())});const k=()=>{c.summarized||c.streaming||f||(t(1,f=!0),Q=c.content,setTimeout(()=>{const Je=document.getElementById("edit-"+c.uuid);Je&&Je.focus()},0))};let ae;const P=()=>{clearTimeout(ae),ae=setTimeout(()=>{j()},250)},j=()=>{c.content!==Q&&(X("change",c),S0(i))},B=()=>{t(1,f=!1),d9(i,c.uuid),wl(O1,r=c.uuid,r)},re=()=>{j(),t(1,f=!1)},ge=Je=>{if(Je.key==="Escape"){if(!f)return;Je.stopPropagation(),Je.preventDefault(),t(0,c.content=Q,c),t(1,f=!1)}if(Je.ctrlKey&&Je.key==="Enter"){if(!f)return;Je.stopPropagation(),Je.preventDefault(),re(),Ge(),setTimeout(Ge,10)}};let we=0;const Ae=()=>{const Ce=new Date().getTime()-we;Ce<400&&Ce>0&&k(),we=new Date().getTime()};let x=0;const M=()=>{if(clearTimeout(Xe),t(7,Xe=0),!x){t(6,x=setTimeout(()=>{t(6,x=0)},1e3));return}if(clearTimeout(x),t(6,x=0),c.summarized){hn("Sorry, you can't delete a summarized message");return}if(c.summary)ma(Ka,{title:"Delete Summary",message:"

Are you sure you want to delete this summary?

Your session may be too long to submit again after you do.

",asHtml:!0,class:"is-warning",confirmButtonClass:"is-warning",confirmButton:"Delete Summary",onConfirm:()=>{try{em(i,c.uuid)}catch(Je){hn("Unable to delete summary:",Je)}}});else try{dr(i,c.uuid)}catch(Je){hn("Unable to delete:",Je)}},Ie=Je=>{if(u){const Ce=/([\s\S]*?)<\/think>/,it=Je.match(Ce);it&&(t(0,c.reason=it[1],c),Je=Je.replace(Ce,""))}else t(0,c.reason="",c);return Je};let Xe=0;const Ge=()=>{if(clearTimeout(x),t(6,x=0),!Xe){t(7,Xe=setTimeout(()=>{t(7,Xe=0)},1e3));return}if(clearTimeout(Xe),t(7,Xe=0),c.summarized){hn("Sorry, you can't truncate a summarized message");return}try{d9(i,c.uuid),wl(B1,a=!0,a)}catch(Je){hn("Unable to delete:",Je)}},Ze=Je=>{if(c.summarized){hn("Sorry, you can't suppress a summarized message");return}t(0,c.suppress=Je,c),S0(i)},oe=()=>{var it;const Je=((c==null?void 0:c.content)||`${s.name}-image-${(it=c==null?void 0:c.image)==null?void 0:it.id}`).replace(/([^a-z0-9- ]|\.)+/gi,"_").trim().slice(0,80),Ce=document.createElement("a");Ce.download=`${Je}.png`,Ce.href=A,document.body.appendChild(Ce),Ce.click(),document.body.removeChild(Ce)},_e=Je=>{let Ce="",it=0;for(;it{t(5,J=_e(c.content))};function pe(){c.content=this.innerText,t(0,c)}const Ee=()=>{m&&k()},Te=()=>{B()},ue=()=>{C1(c.summarized)},bt=()=>{C1(c.summary)},He=()=>{k()},Ue=()=>{M()},gt=()=>{Ge()},ht=()=>{Ze(!c.suppress)},ye=()=>{navigator.clipboard.writeText(c.content)},tt=()=>{se()},Et=()=>{oe()};return l.$$set=Je=>{"message"in Je&&t(0,c=Je.message),"chatId"in Je&&t(28,i=Je.chatId),"chat"in Je&&t(29,s=Je.chat)},l.$$.update=()=>{l.$$.dirty[0]&536870912&&(n=s.settings)},[c,f,F,A,Y,J,x,Xe,o,I,m,u,p,R,E,k,P,B,re,ge,Ae,M,Ie,Ge,Ze,oe,_e,se,i,s,pe,Ee,Te,ue,bt,He,Ue,gt,ht,ye,tt,Et]}class aX extends Ht{constructor(e){super(),Qt(this,e,nX,lX,yt,{message:0,chatId:28,chat:29},null,[-1,-1])}}function Ld(l,e,t){const n=l.slice();return n[6]=e[t],n[7]=e,n[8]=t,n}function Td(l){let e=l[6].uuid,t,n,a=Cd(l);return{c(){a.c(),t=vt()},m(r,c){a.m(r,c),D(r,t,c),n=!0},p(r,c){c&1&&yt(e,e=r[6].uuid)?(ot(),L(a,1,1,lt),It(),a=Cd(r),a.c(),H(a,1),a.m(t.parentNode,t)):a.p(r,c)},i(r){n||(H(a),n=!0)},o(r){L(a),n=!1},d(r){r&&z(t),a.d(r)}}}function Cd(l){let e,t,n;function a(c){l[5](c,l[6],l[7],l[8])}let r={chatId:l[1],chat:l[2]};return l[6]!==void 0&&(r.message=l[6]),e=new aX({props:r}),_n.push(()=>_2(e,"message",a)),{c(){fe(e.$$.fragment)},m(c,i){Fe(e,c,i),n=!0},p(c,i){l=c;const s={};i&2&&(s.chatId=l[1]),i&4&&(s.chat=l[2]),!t&&i&1&&(t=!0,s.message=l[6],y2(()=>t=!1)),e.$set(s)},i(c){n||(H(e.$$.fragment,c),n=!0)},o(c){L(e.$$.fragment,c),n=!1},d(c){Ye(e,c)}}}function kd(l){let e,t,n=!(l[6].summarized&&l[4].hideSummarized)&&!(l[8]===0&&l[6].role==="system"&&!l[3].useSystemPrompt)&&Td(l);return{c(){n&&n.c(),e=vt()},m(a,r){n&&n.m(a,r),D(a,e,r),t=!0},p(a,r){!(a[6].summarized&&a[4].hideSummarized)&&!(a[8]===0&&a[6].role==="system"&&!a[3].useSystemPrompt)?n?(n.p(a,r),r&25&&H(n,1)):(n=Td(a),n.c(),H(n,1),n.m(e.parentNode,e)):n&&(ot(),L(n,1,1,()=>{n=null}),It())},i(a){t||(H(n),t=!0)},o(a){L(n),t=!1},d(a){n&&n.d(a),a&&z(e)}}}function rX(l){let e,t,n=l[0],a=[];for(let c=0;cL(a[c],1,1,()=>{a[c]=null});return{c(){for(let c=0;ct(4,a=o));let{messages:r}=e,{chatId:c}=e,{chat:i}=e;function s(o,I,m,u){m[u]=o,t(0,r)}return l.$$set=o=>{"messages"in o&&t(0,r=o.messages),"chatId"in o&&t(1,c=o.chatId),"chat"in o&&t(2,i=o.chat)},l.$$.update=()=>{l.$$.dirty&4&&t(3,n=i.settings)},[r,c,i,n,a,s]}class iX extends Ht{constructor(e){super(),Qt(this,e,cX,rX,yt,{messages:0,chatId:1,chat:2})}}function Jd(l,e,t){const n=l.slice();return n[25]=e[t],n}function Ud(l,e,t){const n=l.slice();return n[28]=e[t],n}function xd(l){let e,t,n,a,r,c,i,s,o=l[6]&&Md(l);function I(W,X){return W[0].type==="boolean"?IX:W[0].type==="textarea"?oX:sX}let m=I(l),u=m(l);const p=[bX,mX,dX],R=[];function E(W,X){return W[0].type==="number"?0:W[0].type==="select"||W[0].type==="select-number"?1:W[0].type==="text"?2:-1}return~(c=E(l))&&(i=R[c]=p[c](l)),{c(){o&&o.c(),e=he(),t=_("div"),u.c(),n=he(),a=_("div"),r=_("div"),i&&i.c(),h(r,"class","field"),ve(r,"has-addons",l[4].length),h(a,"class","field-body"),h(t,"class","field is-horizontal")},m(W,X){o&&o.m(W,X),D(W,e,X),D(W,t,X),u.m(t,null),V(t,n),V(t,a),V(a,r),~c&&R[c].m(r,null),s=!0},p(W,X){W[6]?o?o.p(W,X):(o=Md(W),o.c(),o.m(e.parentNode,e)):o&&(o.d(1),o=null),m===(m=I(W))&&u?u.p(W,X):(u.d(1),u=m(W),u&&(u.c(),u.m(t,n)));let f=c;c=E(W),c===f?~c&&R[c].p(W,X):(i&&(ot(),L(R[f],1,1,()=>{R[f]=null}),It()),~c?(i=R[c],i?i.p(W,X):(i=R[c]=p[c](W),i.c()),H(i,1),i.m(r,null)):i=null),(!s||X&16)&&ve(r,"has-addons",W[4].length)},i(W){s||(H(i),s=!0)},o(W){L(i),s=!1},d(W){o&&o.d(W),W&&z(e),W&&z(t),u.d(),~c&&R[c].d()}}}function Md(l){let e,t;return{c(){e=_("p"),h(e,"class",t="notification "+l[7])},m(n,a){D(n,e,a),e.innerHTML=l[6]},p(n,a){a&64&&(e.innerHTML=n[6]),a&128&&t!==(t="notification "+n[7])&&h(e,"class",t)},d(n){n&&z(e)}}}function sX(l){let e,t,n=l[0].name+"",a,r,c;return{c(){e=_("div"),t=_("label"),a=ut(n),h(t,"class","label"),h(t,"for",r="settings-"+l[0].key),h(t,"title",c=l[0].title),h(e,"class","field-label is-normal")},m(i,s){D(i,e,s),V(e,t),V(t,a)},p(i,s){s&1&&n!==(n=i[0].name+"")&&bl(a,n),s&1&&r!==(r="settings-"+i[0].key)&&h(t,"for",r),s&1&&c!==(c=i[0].title)&&h(t,"title",c)},d(i){i&&z(e)}}}function oX(l){let e,t,n=l[0].name+"",a,r,c,i,s,o,I,m,u;return{c(){e=_("div"),t=_("label"),a=ut(n),i=he(),s=_("textarea"),h(t,"class","label"),h(t,"for",r="settings-"+l[0].key),h(t,"title",c=l[0].title),h(s,"class","input is-info is-focused chat-input auto-size"),h(s,"placeholder",o=l[8]||""),h(s,"rows","1"),s.value=I=l[1][l[0].key],h(e,"class","field is-normal"),On(e,"width","100%")},m(p,R){D(p,e,R),V(e,t),V(t,a),V(e,i),V(e,s),m||(u=[Qe(s,"input",l[15]),Qe(s,"change",l[16])],m=!0)},p(p,R){R&1&&n!==(n=p[0].name+"")&&bl(a,n),R&1&&r!==(r="settings-"+p[0].key)&&h(t,"for",r),R&1&&c!==(c=p[0].title)&&h(t,"title",c),R&256&&o!==(o=p[8]||"")&&h(s,"placeholder",o),R&3&&I!==(I=p[1][p[0].key])&&(s.value=I)},d(p){p&&z(e),m=!1,Hl(u)}}}function IX(l){let e,t,n,a,r,c,i,s=l[0].name+"",o,I,m,u,p;return{c(){e=_("div"),t=_("label"),n=_("input"),i=he(),o=ut(s),h(n,"type","checkbox"),h(n,"title",a=l[0].title),h(n,"class","checkbox"),h(n,"id",r="settings-"+l[0].key),n.checked=c=!!l[1][l[0].key],h(t,"class","label"),h(t,"for",I="settings-"+l[0].key),h(t,"title",m=l[0].title),h(e,"class","field is-normal")},m(R,E){D(R,e,E),V(e,t),V(t,n),V(t,i),V(t,o),u||(p=Qe(n,"click",l[14]),u=!0)},p(R,E){E&1&&a!==(a=R[0].title)&&h(n,"title",a),E&1&&r!==(r="settings-"+R[0].key)&&h(n,"id",r),E&3&&c!==(c=!!R[1][R[0].key])&&(n.checked=c),E&1&&s!==(s=R[0].name+"")&&bl(o,s),E&1&&I!==(I="settings-"+R[0].key)&&h(t,"for",I),E&1&&m!==(m=R[0].title)&&h(t,"title",m)},d(R){R&&z(e),u=!1,p()}}}function dX(l){let e,t,n,a,r,c,i;return{c(){e=_("div"),t=_("input"),h(t,"type","text"),h(t,"title",n=l[0].title),h(t,"class","input"),t.value=a=l[1][l[0].key],h(t,"placeholder",r=String(l[8]||l[2][l[0].key])),h(e,"class","field")},m(s,o){D(s,e,o),V(e,t),c||(i=Qe(t,"change",l[20]),c=!0)},p(s,o){o&1&&n!==(n=s[0].title)&&h(t,"title",n),o&3&&a!==(a=s[1][s[0].key])&&t.value!==a&&(t.value=a),o&261&&r!==(r=String(s[8]||s[2][s[0].key]))&&h(t,"placeholder",r)},i:lt,o:lt,d(s){s&&z(e),c=!1,i()}}}function mX(l){let e,t=l[3],n,a,r,c=Od(l),i=l[4],s=[];for(let I=0;IL(s[I],1,1,()=>{s[I]=null});return{c(){e=_("div"),c.c(),n=he();for(let I=0;I{I=null}),It()),l[25].icon?m?(m.p(l,R),R&16&&H(m,1)):(m=Dd(l),m.c(),H(m,1),m.m(t,null)):m&&(ot(),L(m,1,1,()=>{m=null}),It()),(!i||R&16&&a!==(a=l[25].text))&&h(t,"title",a),(!i||R&16&&r!==(r="button "+(l[25].class||"")))&&h(t,"class",r)},i(p){i||(H(I),H(m),i=!0)},o(p){L(I),L(m),i=!1},d(p){p&&z(e),I&&I.d(),m&&m.d(),s=!1,o()}}}function uX(l){let e,t,n=l[5]&&xd(l);return{c(){n&&n.c(),e=vt()},m(a,r){n&&n.m(a,r),D(a,e,r),t=!0},p(a,[r]){a[5]?n?(n.p(a,r),r&32&&H(n,1)):(n=xd(a),n.c(),H(n,1),n.m(e.parentNode,e)):n&&(ot(),L(n,1,1,()=>{n=null}),It())},i(a){t||(H(n),t=!0)},o(a){L(n),t=!1},d(a){n&&n.d(a),a&&z(e)}}}function pX(l,e,t){let{setting:n}=e,{chatSettings:a}=e,{chat:r}=e,{chatDefaults:c}=e,{originalProfile:i}=e,{rkey:s=0}=e,o;const I=r.id;let m=!1,u=h2(I,n.header),p=h2(I,n.headerClass),R=h2(I,n.placeholder);const E=()=>{t(4,o=(n.fieldControls||[]).map(B=>B.getAction(I,n,a[n.key])))};E(),sa(()=>{t(5,m=typeof n.hide!="function"||!n.hide(I,n)),E()}),Ta(()=>{t(5,m=typeof n.hide!="function"||!n.hide(I,n)),t(6,u=h2(I,n.header)),t(7,p=h2(I,n.headerClass)),t(8,R=h2(I,n.placeholder)),E()});const W=w2(),X=()=>{W("refresh")},f={profile:[{title:"Unsaved Profile Changes",message:`Unsaved changes to the current profile will be lost. Continue?`,checkPrompt:(B,re,ge)=>!!a.isDirty&&re!==ge,passed:!1}]},Q=B=>{const re=f[B];re&&re.forEach(ge=>{ge.passed=!1})},F=(B,re)=>{if(B.target===null)return;const ge=a[re.key],we=B.target,Ae=()=>{try{typeof re.beforeChange=="function"&&re.beforeChange(I,re,we.checked||we.value)&&X()}catch(Xe){hn("Unable to change:",Xe)}switch(re.type){case"boolean":W0(I,re,we.checked),X();break;default:W0(I,re,we.value)}const Ie=H0(re.type,we.checked||we.value);if(ge!==Ie){try{typeof re.afterChange=="function"&&re.afterChange(I,re,a[re.key])&&X()}catch(Xe){W0(I,re,ge),hn("Unable to change:",Xe)}W("change",re)}},x=f[re.key]||[],M=H0(re.type,we.checked||we.value);for(let Ie=0,Xe=x.length;Ie{Ge.passed=!0,Ge.onYes&&Ge.onYes(re,M,ge)?Q(re.key):F(B,re)},onCancel:()=>{!Ge.onNo||!Ge.onNo(re,M,ge)?(Q(re.key),W0(I,re,ge),Ge.onNo&&Ge.onNo(re,M,ge),X()):F(B,re)}}):Ge.passed=!0)}x.find(Ie=>!Ie.passed)||(Q(re.key),Ae())},A=B=>F(B,n),Y=B=>qi(B),J=B=>{F(B,n),qi(B)},k=B=>F(B,n),ae=B=>F(B,n),P=B=>{B.action&&B.action(I,n,a[n.key]),X()},j=B=>{F(B,n)};return l.$$set=B=>{"setting"in B&&t(0,n=B.setting),"chatSettings"in B&&t(1,a=B.chatSettings),"chat"in B&&t(12,r=B.chat),"chatDefaults"in B&&t(2,c=B.chatDefaults),"originalProfile"in B&&t(13,i=B.originalProfile),"rkey"in B&&t(3,s=B.rkey)},[n,a,c,s,o,m,u,p,R,I,X,F,r,i,A,Y,J,k,ae,P,j]}class GX extends Ht{constructor(e){super(),Qt(this,e,pX,uX,yt,{setting:0,chatSettings:1,chat:12,chatDefaults:2,originalProfile:13,rkey:3})}}function Kd(l,e,t){const n=l.slice();return n[44]=e[t],n}function jd(l){let e,t,n;return e=new GX({props:{rkey:l[2],chat:l[1],chatDefaults:l[6],chatSettings:l[8],setting:l[44],originalProfile:l[7]}}),e.$on("refresh",l[12]),e.$on("change",l[20]),{c(){fe(e.$$.fragment),t=he()},m(a,r){Fe(e,a,r),D(a,t,r),n=!0},p(a,r){const c={};r[0]&4&&(c.rkey=a[2]),r[0]&2&&(c.chat=a[1]),r[0]&64&&(c.chatDefaults=a[6]),r[0]&256&&(c.chatSettings=a[8]),r[0]&128&&(c.originalProfile=a[7]),e.$set(c)},i(a){n||(H(e.$$.fragment,a),n=!0)},o(a){L(e.$$.fragment,a),n=!1},d(a){Ye(e,a),a&&z(t)}}}function hX(l){let e,t,n,a,r,c,i,s,o,I,m,u,p,R,E,W,X,f,Q,F,A,Y,J,k,ae,P,j,B,re,ge,we,Ae,x,M,Ie,Xe,Ge,Ze,oe,_e,se,pe,Ee,Te,ue,bt,He,Ue,gt,ht,ye,tt,Et,Je,Ce,it,Zt,et,_t,kt,zt,Dt,ze,xe,Wt,Xt,Jt,ol,gl,Il,ct,Dl,Ml,Ct,De,Wl,cn,rl,Ll,sn,Tl,Cl,jl,ql,$l=l[9],xt=[];for(let at=0;at<$l.length;at+=1)xt[at]=jd(Kd(l,$l,at));const ll=at=>L(xt[at],1,1,()=>{xt[at]=null});return P=new Rt({props:{icon:Fs}}),Ae=new Rt({props:{icon:aG}}),Ge=new Rt({props:{icon:nG}}),pe=new Rt({props:{icon:k7}}),gt=new Rt({props:{icon:C7}}),Je=new Rt({props:{icon:Xs}}),zt=new Rt({props:{icon:w0}}),Xt=new Rt({props:{icon:V0}}),ct=new Rt({props:{icon:eh}}),rl=new Rt({props:{icon:sr}}),{c(){e=_("div"),t=_("div"),n=he(),a=_("div"),r=_("header"),c=_("p"),c.textContent="Chat Settings",i=he(),s=_("button"),o=he(),I=_("section");for(let at=0;at from Current',F=he(),A=_("div"),Y=_("div"),J=_("div"),k=_("button"),ae=_("span"),fe(P.$$.fragment),j=he(),B=_("div"),re=_("div"),ge=_("a"),we=_("span"),fe(Ae.$$.fragment),x=ut(" Save Changes"),M=he(),Ie=_("a"),Xe=_("span"),fe(Ge.$$.fragment),Ze=ut(" Reset Changes"),oe=he(),_e=_("a"),se=_("span"),fe(pe.$$.fragment),Ee=ut(" Clone Profile"),Te=he(),ue=_("hr"),bt=he(),He=_("a"),Ue=_("span"),fe(gt.$$.fragment),ht=ut(" Set as Default Profile"),ye=he(),tt=_("a"),Et=_("span"),fe(Je.$$.fragment),Ce=ut(" Start New Chat from Current"),it=he(),Zt=_("hr"),et=he(),_t=_("a"),kt=_("span"),fe(zt.$$.fragment),Dt=ut(" Backup Profile JSON"),ze=he(),xe=_("a"),Wt=_("span"),fe(Xt.$$.fragment),Jt=ut(" Restore Profile JSON"),ol=he(),gl=_("a"),Il=_("span"),fe(ct.$$.fragment),Dl=ut(" Copy Profile URL to Clipboard"),Ml=he(),Ct=_("hr"),De=he(),Wl=_("a"),cn=_("span"),fe(rl.$$.fragment),Ll=ut(" Delete Profile"),sn=he(),Tl=_("input"),h(t,"class","modal-background"),h(c,"class","modal-card-title"),h(s,"class","delete"),h(s,"aria-label","close"),h(r,"class","modal-card-head"),h(I,"class","modal-card-body"),h(E,"class","button"),h(E,"title","Save changes to this profile."),ve(E,"is-disabled",!l[8].isDirty),h(X,"class","button is-warning"),h(X,"title","Throw away changes to this profile."),ve(X,"is-disabled",!l[8].isDirty),h(Q,"class","button"),h(Q,"title","Start new chat with this profile."),h(R,"class","level-left"),h(ae,"class","icon"),h(k,"class","button"),h(k,"aria-haspopup","true"),h(k,"aria-controls","dropdown-menu3"),h(J,"class","dropdown-trigger"),h(we,"class","menu-icon"),h(ge,"href","#"),h(ge,"class","dropdown-item"),ve(ge,"is-disabled",!l[8].isDirty),h(Xe,"class","menu-icon"),h(Ie,"href","#"),h(Ie,"class","dropdown-item"),ve(Ie,"is-disabled",!l[8].isDirty),h(se,"class","menu-icon"),h(_e,"href","#"),h(_e,"class","dropdown-item"),h(ue,"class","dropdown-divider"),h(Ue,"class","menu-icon"),h(He,"href","#"),h(He,"class","dropdown-item"),ve(He,"is-disabled",l[5]),h(Et,"class","menu-icon"),h(tt,"href","#"),h(tt,"class","dropdown-item"),h(Zt,"class","dropdown-divider"),h(kt,"class","menu-icon"),h(_t,"href","#"),h(_t,"class","dropdown-item"),h(Wt,"class","menu-icon"),h(xe,"href","#"),h(xe,"class","dropdown-item"),h(Il,"class","menu-icon"),h(gl,"href","#"),h(gl,"class","dropdown-item"),h(Ct,"class","dropdown-divider"),h(cn,"class","menu-icon"),h(Wl,"href","#"),h(Wl,"class","dropdown-item"),h(re,"class","dropdown-content"),h(B,"class","dropdown-menu"),h(B,"id","dropdown-menu3"),h(B,"role","menu"),h(Y,"class","dropdown is-right is-up"),ve(Y,"is-active",l[3]),h(A,"class","level-right"),h(p,"class","level is-mobile"),h(u,"class","modal-card-foot"),h(a,"class","modal-card wide"),h(e,"class","modal chat-settings"),ve(e,"is-active",l[2]),On(Tl,"display","none"),h(Tl,"type","file"),h(Tl,"accept",".json")},m(at,Pt){D(at,e,Pt),V(e,t),V(e,n),V(e,a),V(a,r),V(r,c),V(r,i),V(r,s),V(a,o),V(a,I);for(let nl=0;nlt(37,c=He)),tl(l,rn,He=>t(22,i=He)),tl(l,il,He=>t(23,s=He));let{chatId:o}=e;const I=()=>{M()};let m=0,u=!1,p,R=Or(),E=!1;const W=hG(),X=v0("model"),f=v0("imageGenerationModel"),Q=n0(),F=a0();let A,Y,J;sa(async()=>{t(7,A=a&&a.profile),J=a&&JSON.parse(JSON.stringify(a))}),Ta(()=>{A||(t(7,A=a&&a.profile),J=a&&JSON.parse(JSON.stringify(a))),ji()});const k=()=>{t(7,A=""),J={},t(3,u=!1),oe(),wl(Dn,c++,c),t(2,m=0)},ae=()=>{ma(Ka,{title:"Reset Changes",message:"Are you sure you want to reset all changes you've made to this profile?",class:"is-warning",onConfirm:()=>{$7(o),P()}})},P=async()=>{m&&M()},j=()=>{const He="#/chat/new?petals=true&"+Object.entries(a).reduce((gt,[ht,ye])=>{const tt=typeof ye;return x7(ht)&&(tt==="boolean"||tt==="string"||tt==="number")&>.push(encodeURIComponent(ht)+"="+encodeURIComponent(ye)),gt},[]).join("&"),Ue=window.location.protocol+"//"+window.location.host+window.location.pathname+He;return navigator.clipboard.writeText(Ue),Ue},B=()=>{t(3,u=!1);const He=JSON.parse(JSON.stringify(n.settings)),Ue=n.settings.profileName;He.profileName=U1(Ue||""),He.profile=null;try{w1(He),t(1,n.settings.profile=He.profile,n),t(1,n.settings.profileName=He.profileName,n),x1(o,He.profile),P()}catch(gt){hn("Error cloning profile:",gt)}},re=()=>{ma(Ka,{title:"Delete Profile",message:"Are you sure you want to delete this profile?",class:"is-warning",onConfirm:()=>{ge()}})},ge=()=>{t(3,u=!1);try{JG(o,n.settings.profile),t(1,n.settings.profile=r.defaultProfile||"",n),vn(),wa("lastProfile",n.settings.profile),x1(o,n.settings.profile),P()}catch(He){console.error(He),hn("Error deleting profile:",He)}},we=()=>{t(3,u=!1),wa("defaultProfile",n.settings.profile),P()},Ae=He=>{const Ue=He.target.files[0];He.target.value=null;const gt=new FileReader;gt.readAsText(Ue),gt.onload=ht=>{const ye=(ht.target||{}).result;try{const tt=JSON.parse(ye);tt.profileName=U1(tt.profileName||""),tt.profile=null,w1(tt),P()}catch(tt){hn("Unable to import profile:",tt)}}},x=()=>{const He=v0("profile");He.options=D7(),t(6,Q.profile=Or(),Q),t(6,Q.max_tokens=ls(a.model),Q),R=Or(),t(5,E=R===a.profile)},M=async()=>{Ze(),t(2,m++,m),x(),t(2,m++,m),X&&(X.options=await zp(),f.options=await Dp()),t(2,m++,m);const He=Y!==a.profile;Y=a.profile,setTimeout(()=>ji(He))},Ie=()=>{t(3,u=!1);try{w1(n.settings),P()}catch(He){hn("Error saving profile:",He)}},Xe=()=>{const He=J.profile!==a.profile,Ue=f0(a);He&&(t(1,n.settings=J,n),vn()),ia(`/chat/${Ue}`)},Ge=(He,Ue)=>{const gt=Object.keys,ht=typeof He;return He&&Ue&&ht==="object"&&ht===typeof Ue?gt(He).every(tt=>F[tt]||Ge(He[tt],Ue[tt])):He===Ue||(He==null||He===!1)&&(Ue==null||Ue===!1)},Ze=(He=void 0)=>{if(He&&He.detail.key==="profile")return;const Ue=or(a.profile);t(8,a.isDirty=!Ge(Ue,a),a)},oe=()=>{a.useSystemPrompt&&P7(o)},_e=()=>{t(3,u=!u)},se=()=>{t(3,u=!1),ah(o)},pe=()=>{t(3,u=!1),p.click()},Ee=()=>{t(3,u=!1),j()},Te=()=>{t(3,u=!1)},ue=He=>Ae(He);function bt(He){_n[He?"unshift":"push"](()=>{p=He,t(4,p)})}return l.$$set=He=>{"chatId"in He&&t(0,o=He.chatId)},l.$$.update=()=>{l.$$.dirty[0]&8388609&&t(1,n=s.find(He=>He.id===o)),l.$$.dirty[0]&2&&t(8,a=n.settings),l.$$.dirty[0]&4194304&&(r=i)},[o,n,m,u,p,E,Q,A,a,W,k,ae,P,j,B,re,we,Ae,Ie,Xe,Ze,I,i,s,_e,se,pe,Ee,Te,ue,bt]}class RX extends Ht{constructor(e){super(),Qt(this,e,ZX,hX,yt,{chatId:0,show:21},null,[-1,-1])}get show(){return this.$$.ctx[21]}}function qd(l){let e,t,n,a,r,c,i,s,o,I,m,u,p,R,E,W,X,f,Q,F,A,Y,J,k,ae,P,j,B,re,ge,we,Ae,x,M,Ie,Xe,Ge,Ze,oe,_e,se=l[10]&&$d(l),pe=l[9]&&e7(),Ee=l[9]&&t7(l);return{c(){e=_("div"),t=_("div"),n=he(),a=_("div"),r=_("form"),c=_("article"),i=_("div"),s=_("p"),o=ut(l[2]),I=he(),m=_("button"),u=he(),p=_("div"),R=_("div"),E=_("label"),W=ut(l[3]),X=he(),f=_("div"),Q=_("input"),F=he(),se&&se.c(),A=he(),pe&&pe.c(),Y=he(),Ee&&Ee.c(),J=he(),k=_("div"),ae=_("div"),P=_("div"),j=he(),B=_("div"),re=_("div"),ge=_("input"),Ae=he(),x=_("div"),M=_("button"),Ie=ut(l[6]),h(t,"class","modal-background"),h(m,"class","delete"),h(m,"aria-label","close"),h(m,"type","button"),h(i,"class","message-header"),h(E,"class","label"),h(E,"for","text-input"),h(Q,"id",l[12]),h(Q,"name","text-input"),h(Q,"class","input"),h(Q,"type","text"),h(Q,"placeholder",l[8]),ve(Q,"is-danger",l[9]),h(f,"class","control"),ve(f,"has-icons-left",l[10]),ve(f,"has-icons-right",l[9]),h(R,"class","field"),h(p,"class","message-body"),h(P,"class","level-right"),h(ge,"type","submit"),h(ge,"class",we="button "+l[5]),ge.value=l[4],h(re,"class","level-item"),h(M,"class",Xe="button "+l[7]),h(M,"type","button"),h(x,"class","level-item"),h(B,"class","level-right"),h(ae,"class","level is-mobile"),h(k,"class","message-footer"),h(c,"class",Ge="message "+l[11]),h(r,"action","#"),h(a,"class","modal-content nomax"),h(e,"class","modal is-active")},m(Te,ue){D(Te,e,ue),V(e,t),V(e,n),V(e,a),V(a,r),V(r,c),V(c,i),V(i,s),V(s,o),V(i,I),V(i,m),V(c,u),V(c,p),V(p,R),V(R,E),V(E,W),V(R,X),V(R,f),V(f,Q),L1(Q,l[0]),V(f,F),se&&se.m(f,null),V(f,A),pe&&pe.m(f,null),V(R,Y),Ee&&Ee.m(R,null),V(c,J),V(c,k),V(k,ae),V(ae,P),V(ae,j),V(ae,B),V(B,re),V(re,ge),V(B,Ae),V(B,x),V(x,M),V(M,Ie),Ze=!0,oe||(_e=[Qe(t,"click",l[13]),Qe(m,"click",l[13]),Qe(Q,"input",l[17]),Qe(M,"click",l[13]),Qe(r,"submit",Vt(l[18])),Qe(e,"modal-esc",l[13])],oe=!0)},p(Te,ue){(!Ze||ue&4)&&bl(o,Te[2]),(!Ze||ue&8)&&bl(W,Te[3]),(!Ze||ue&256)&&h(Q,"placeholder",Te[8]),ue&1&&Q.value!==Te[0]&&L1(Q,Te[0]),(!Ze||ue&512)&&ve(Q,"is-danger",Te[9]),Te[10]?se?(se.p(Te,ue),ue&1024&&H(se,1)):(se=$d(Te),se.c(),H(se,1),se.m(f,A)):se&&(ot(),L(se,1,1,()=>{se=null}),It()),Te[9]?pe?(pe.p(Te,ue),ue&512&&H(pe,1)):(pe=e7(),pe.c(),H(pe,1),pe.m(f,null)):pe&&(ot(),L(pe,1,1,()=>{pe=null}),It()),(!Ze||ue&1024)&&ve(f,"has-icons-left",Te[10]),(!Ze||ue&512)&&ve(f,"has-icons-right",Te[9]),Te[9]?Ee?Ee.p(Te,ue):(Ee=t7(Te),Ee.c(),Ee.m(R,null)):Ee&&(Ee.d(1),Ee=null),(!Ze||ue&32&&we!==(we="button "+Te[5]))&&h(ge,"class",we),(!Ze||ue&16)&&(ge.value=Te[4]),(!Ze||ue&64)&&bl(Ie,Te[6]),(!Ze||ue&128&&Xe!==(Xe="button "+Te[7]))&&h(M,"class",Xe),(!Ze||ue&2048&&Ge!==(Ge="message "+Te[11]))&&h(c,"class",Ge)},i(Te){Ze||(H(se),H(pe),Ze=!0)},o(Te){L(se),L(pe),Ze=!1},d(Te){Te&&z(e),se&&se.d(),pe&&pe.d(),Ee&&Ee.d(),oe=!1,Hl(_e)}}}function $d(l){let e,t,n;return t=new Rt({props:{icon:l[10]}}),{c(){e=_("span"),fe(t.$$.fragment),h(e,"class","icon is-small is-left")},m(a,r){D(a,e,r),Fe(t,e,null),n=!0},p(a,r){const c={};r&1024&&(c.icon=a[10]),t.$set(c)},i(a){n||(H(t.$$.fragment,a),n=!0)},o(a){L(t.$$.fragment,a),n=!1},d(a){a&&z(e),Ye(t)}}}function e7(l){let e,t,n,a,r;return t=new Rt({props:{icon:uG}}),{c(){e=_("span"),fe(t.$$.fragment),n=he(),a=_("i"),h(a,"class","fas fa-exclamation-triangle"),h(e,"class","icon is-small is-right")},m(c,i){D(c,e,i),Fe(t,e,null),V(e,n),V(e,a),r=!0},p:lt,i(c){r||(H(t.$$.fragment,c),r=!0)},o(c){L(t.$$.fragment,c),r=!1},d(c){c&&z(e),Ye(t)}}}function t7(l){let e,t;return{c(){e=_("p"),t=ut(l[9]),h(e,"class","help is-danger")},m(n,a){D(n,e,a),V(e,t)},p(n,a){a&512&&bl(t,n[9])},d(n){n&&z(e)}}}function NX(l){let e,t,n=l[1]&&qd(l);return{c(){n&&n.c(),e=vt()},m(a,r){n&&n.m(a,r),D(a,e,r),t=!0},p(a,[r]){a[1]?n?(n.p(a,r),r&2&&H(n,1)):(n=qd(a),n.c(),H(n,1),n.m(e.parentNode,e)):n&&(ot(),L(n,1,1,()=>{n=null}),It())},i(a){t||(H(n),t=!0)},o(a){L(n),t=!1},d(a){n&&n.d(a),a&&z(e)}}}function gX(l,e,t){let{isOpen:n}=e,{title:a}=e,{label:r}=e,{value:c}=e,{onSubmit:i}=e,{onClose:s=()=>{}}=e,{saveButton:o="Save"}=e,{saveButtonClass:I="is-info"}=e,{closeButton:m="Cancel"}=e,{closeButtonClass:u=""}=e,{placeholder:p=""}=e,{error:R=""}=e,{icon:E=null}=e,{class:W=""}=e;const X=Zn();sa(async()=>{const Y=document.getElementById(X);Y&&Y.focus()});const f=()=>{(!s||!s())&&K2()},Q=Y=>{i(Y),K2()};function F(){c=this.value,t(0,c)}const A=()=>{Q(c)};return l.$$set=Y=>{"isOpen"in Y&&t(1,n=Y.isOpen),"title"in Y&&t(2,a=Y.title),"label"in Y&&t(3,r=Y.label),"value"in Y&&t(0,c=Y.value),"onSubmit"in Y&&t(15,i=Y.onSubmit),"onClose"in Y&&t(16,s=Y.onClose),"saveButton"in Y&&t(4,o=Y.saveButton),"saveButtonClass"in Y&&t(5,I=Y.saveButtonClass),"closeButton"in Y&&t(6,m=Y.closeButton),"closeButtonClass"in Y&&t(7,u=Y.closeButtonClass),"placeholder"in Y&&t(8,p=Y.placeholder),"error"in Y&&t(9,R=Y.error),"icon"in Y&&t(10,E=Y.icon),"class"in Y&&t(11,W=Y.class)},[c,n,a,r,o,I,m,u,p,R,E,W,X,f,Q,i,s,F,A]}class WX extends Ht{constructor(e){super(),Qt(this,e,gX,NX,yt,{isOpen:1,title:2,label:3,value:0,onSubmit:15,onClose:16,saveButton:4,saveButtonClass:5,closeButton:6,closeButtonClass:7,placeholder:8,error:9,icon:10,class:11})}}function l7(l,e,t){const n=l.slice();return n[36]=e[t][0],n[37]=e[t][1],n}function n7(l){let e,t,n,a,r,c,i,s,o,I,m=(l[0].name||`Chat ${l[0].id}`)+"",u,p,R,E,W,X,f,Q,F,A,Y,J,k,ae,P,j,B,re;function ge(M){l[22](M)}let we={chatId:l[9]};l[6]!==void 0&&(we.show=l[6]),e=new RX({props:we}),_n.push(()=>_2(e,"show",ge)),E=new Rt({props:{icon:S7}}),f=new Rt({props:{icon:f7}}),Y=new iX({props:{messages:l[8],chatId:l[9],chat:l[0]}});let Ae=(l[2].updating===!0||l[1]===0)&&a7(l),x=l[1]!==0&&(l[8].length===0||l[8].length===1&&l[8][0].role==="system")&&r7(l);return P=new rm({props:{class:"prompt-input-container",strongMask:!0,$$slots:{default:[_X]},$$scope:{ctx:l}}}),{c(){fe(e.$$.fragment),n=he(),a=_("div"),r=_("div"),c=_("nav"),i=_("div"),s=_("div"),o=_("p"),I=_("span"),u=ut(m),p=he(),R=_("a"),fe(E.$$.fragment),W=he(),X=_("a"),fe(f.$$.fragment),Q=he(),F=_("div"),F.innerHTML='
',A=he(),fe(Y.$$.fragment),J=he(),Ae&&Ae.c(),k=he(),x&&x.c(),ae=he(),fe(P.$$.fragment),h(R,"href","#"),h(R,"class","greyscale ml-2 is-hidden has-text-weight-bold editbutton"),h(R,"title","Rename chat"),h(X,"href","#"),h(X,"class","greyscale ml-2 is-hidden has-text-weight-bold editbutton"),h(X,"title","Suggest a chat name"),h(o,"class","subtitle is-5"),h(s,"class","level-item"),h(i,"class","level-left"),h(F,"class","level-right"),h(c,"class","level chat-header"),h(r,"class","chat-content"),h(a,"class","chat-page"),On(a,"--running-totals",Object.entries(l[0].usage||{}).length)},m(M,Ie){Fe(e,M,Ie),D(M,n,Ie),D(M,a,Ie),V(a,r),V(r,c),V(c,i),V(i,s),V(s,o),V(o,I),V(I,u),V(o,p),V(o,R),Fe(E,R,null),V(o,W),V(o,X),Fe(f,X,null),V(c,Q),V(c,F),V(r,A),Fe(Y,r,null),V(r,J),Ae&&Ae.m(r,null),V(r,k),x&&x.m(r,null),V(a,ae),Fe(P,a,null),j=!0,B||(re=[Qe(R,"click",Vt(l[14])),Qe(X,"click",Vt(l[13]))],B=!0)},p(M,Ie){const Xe={};!t&&Ie[0]&64&&(t=!0,Xe.show=M[6],y2(()=>t=!1)),e.$set(Xe),(!j||Ie[0]&1)&&m!==(m=(M[0].name||`Chat ${M[0].id}`)+"")&&bl(u,m);const Ge={};Ie[0]&256&&(Ge.messages=M[8]),Ie[0]&1&&(Ge.chat=M[0]),Y.$set(Ge),M[2].updating===!0||M[1]===0?Ae?Ae.p(M,Ie):(Ae=a7(M),Ae.c(),Ae.m(r,k)):Ae&&(Ae.d(1),Ae=null),M[1]!==0&&(M[8].length===0||M[8].length===1&&M[8][0].role==="system")?x?(x.p(M,Ie),Ie[0]&258&&H(x,1)):(x=r7(M),x.c(),H(x,1),x.m(r,null)):x&&(ot(),L(x,1,1,()=>{x=null}),It());const Ze={};Ie[0]&253|Ie[1]&512&&(Ze.$$scope={dirty:Ie,ctx:M}),P.$set(Ze),(!j||Ie[0]&1)&&On(a,"--running-totals",Object.entries(M[0].usage||{}).length)},i(M){j||(H(e.$$.fragment,M),H(E.$$.fragment,M),H(f.$$.fragment,M),H(Y.$$.fragment,M),H(x),H(P.$$.fragment,M),j=!0)},o(M){L(e.$$.fragment,M),L(E.$$.fragment,M),L(f.$$.fragment,M),L(Y.$$.fragment,M),L(x),L(P.$$.fragment,M),j=!1},d(M){Ye(e,M),M&&z(n),M&&z(a),Ye(E),Ye(f),Ye(Y),Ae&&Ae.d(),x&&x.d(),Ye(P),B=!1,Hl(re)}}}function a7(l){let e,t,n,a,r,c=l[2].updatingMessage+"",i;return{c(){e=_("article"),t=_("div"),n=_("span"),a=he(),r=_("span"),i=ut(c),h(n,"class","is-loading"),h(t,"class","message-body content"),h(e,"class","message is-success assistant-message")},m(s,o){D(s,e,o),V(e,t),V(t,n),V(t,a),V(t,r),V(r,i)},p(s,o){o[0]&4&&c!==(c=s[2].updatingMessage+"")&&bl(i,c)},d(s){s&&z(e)}}}function r7(l){let e,t,n;function a(c){l[23](c)}let r={};return l[3]!==void 0&&(r.input=l[3]),e=new vZ({props:r}),_n.push(()=>_2(e,"input",a)),{c(){fe(e.$$.fragment)},m(c,i){Fe(e,c,i),n=!0},p(c,i){const s={};!t&&i[0]&8&&(t=!0,s.input=c[3],y2(()=>t=!1)),e.$set(s)},i(c){n||(H(e.$$.fragment,c),n=!0)},o(c){L(e.$$.fragment,c),n=!1},d(c){Ye(e,c)}}}function EX(l){let e,t,n,a,r;return a=new Rt({props:{icon:J7}}),{c(){e=_("p"),t=_("button"),n=_("span"),fe(a.$$.fragment),h(n,"class","icon"),h(t,"title","Send"),h(t,"class","button is-info"),h(t,"type","submit"),h(e,"class","control send")},m(c,i){D(c,e,i),V(e,t),V(t,n),Fe(a,n,null),r=!0},p:lt,i(c){r||(H(a.$$.fragment,c),r=!0)},o(c){L(a.$$.fragment,c),r=!1},d(c){c&&z(e),Ye(a)}}}function VX(l){let e,t,n,a,r,c,i,s;const o=[yX,vX],I=[];function m(u,p){return u[7]?0:1}return a=m(l),r=I[a]=o[a](l),{c(){e=_("p"),t=_("button"),n=_("span"),r.c(),h(n,"class","icon"),h(t,"title","Cancel Response"),h(t,"class","button is-danger"),h(t,"type","button"),h(e,"class","control send")},m(u,p){D(u,e,p),V(e,t),V(t,n),I[a].m(n,null),c=!0,i||(s=Qe(t,"click",l[11]),i=!0)},p(u,p){let R=a;a=m(u),a===R?I[a].p(u,p):(ot(),L(I[R],1,1,()=>{I[R]=null}),It(),r=I[a],r?r.p(u,p):(r=I[a]=o[a](u),r.c()),H(r,1),r.m(n,null))},i(u){c||(H(r),c=!0)},o(u){L(r),c=!1},d(u){u&&z(e),I[a].d(),i=!1,s()}}}function vX(l){let e,t;return e=new Rt({props:{icon:$p}}),{c(){fe(e.$$.fragment)},m(n,a){Fe(e,n,a),t=!0},p:lt,i(n){t||(H(e.$$.fragment,n),t=!0)},o(n){L(e.$$.fragment,n),t=!1},d(n){Ye(e,n)}}}function yX(l){let e,t;return e=new Rt({props:{icon:ir}}),{c(){fe(e.$$.fragment)},m(n,a){Fe(e,n,a),t=!0},p:lt,i(n){t||(H(e.$$.fragment,n),t=!0)},o(n){L(e.$$.fragment,n),t=!1},d(n){Ye(e,n)}}}function c7(l){let e,t,n=(Nl(l[36]||"").label||l[36])+"",a,r,c,i=l[37].total_tokens+"",s,o,I,m,u=k1(l[37],l[36]).toFixed(6)+"",p,R;return{c(){e=_("p"),t=_("em"),a=ut(n),r=ut(" total "),c=_("span"),s=ut(i),o=ut(` tokens ~= `),I=_("span"),m=ut("$"),p=ut(u),R=he(),h(c,"class","has-text-weight-bold"),h(I,"class","has-text-weight-bold"),h(e,"class","is-size-7 running-totals")},m(E,W){D(E,e,W),V(e,t),V(t,a),V(e,r),V(e,c),V(c,s),V(e,o),V(e,I),V(I,m),V(I,p),V(e,R)},p(E,W){W[0]&1&&n!==(n=(Nl(E[36]||"").label||E[36])+"")&&bl(a,n),W[0]&1&&i!==(i=E[37].total_tokens+"")&&bl(s,i),W[0]&1&&u!==(u=k1(E[37],E[36]).toFixed(6)+"")&&bl(p,u)},d(E){E&&z(e)}}}function _X(l){let e,t,n,a,r,c,i,s,o,I,m,u,p,R,E,W,X,f,Q,F,A,Y,J,k,ae,P,j,B,re,ge,we,Ae;o=new Rt({props:{icon:lG}}),R=new Rt({props:{icon:T7}}),Q=new Rt({props:{icon:f7}}),k=new Rt({props:{icon:eG}});const x=[VX,EX],M=[];function Ie(Ze,oe){return Ze[2].updating?0:1}P=Ie(l),j=M[P]=x[P](l);let Xe=Object.entries(l[0].usage||{}),Ge=[];for(let Ze=0;Ze{M[_e]=null}),It(),j=M[P],j?j.p(l,oe):(j=M[P]=x[P](l),j.c()),H(j,1),j.m(e,null)),oe[0]&1){Xe=Object.entries(l[0].usage||{});let se;for(se=0;se{n=null}),It())},i(a){t||(H(n),t=!0)},o(a){L(n),t=!1},d(a){n&&n.d(a),a&&z(e)}}}function FX(l,e,t){let n,a,r,c,i,s,o,I,m;tl(l,Dn,oe=>t(17,r=oe)),tl(l,F2,oe=>t(8,c=oe)),tl(l,A0,oe=>t(1,i=oe)),tl(l,O1,oe=>t(18,s=oe)),tl(l,B1,oe=>t(19,o=oe)),tl(l,M1,oe=>t(20,I=oe)),tl(l,il,oe=>t(21,m=oe));let{params:u={chatId:""}}=e;const p=parseInt(u.chatId);let R=new qo,E,W=null,X=!1,f=!1,Q,F;const A=(...oe)=>{n&&(clearTimeout(F),setTimeout(()=>{if(n.startSession&&(q2(p),n.startSession&&(t(0,n.startSession=!1,n),vn(),re(!1,!0))),I&&(wl(M1,I=!1,I),Q()),o&&(wl(B1,o=!1,o),re(!1,!0)),s){const _e=Q0(p,s);wl(O1,s="",s),_e&&c.indexOf(_e)===c.length-1&&re(f,!0,_e)}}))},Y=(...oe)=>{F1()};s9(0),j7(p),I7(async()=>{R.controller.abort(),P()}),sa(async()=>{n&&(s9(p),t(2,R=new qo),R.setChat(n),t(0,n.lastAccess=Date.now(),n),vn(),wl(Dn,r++,r),J(),"SpeechRecognition"in window?t(4,W=new window.SpeechRecognition):"webkitSpeechRecognition"in window&&t(4,W=new window.webkitSpeechRecognition),W?(t(4,W.interimResults=!1,W),t(4,W.onstart=()=>{t(5,X=!0)},W),t(4,W.onresult=oe=>{const _e=oe.results.length-1,se=oe.results[_e][0].transcript;t(3,E.value=se,E),W.stop(),t(5,X=!1),re(!0)},W)):console.log("Speech recognition not supported"),n.startSession&&(q2(p),n.startSession&&(t(0,n.startSession=!1,n),vn(),setTimeout(()=>{re(!1,!0)},0))))}),Ta(()=>{ji()});const J=()=>{E.focus(),F1()},k=()=>{if(R.updating)return;let oe;const _e=c[c.length-1],se=Zn();c.length===0?oe={role:"system",content:E.value,uuid:se}:_e&&_e.role==="user"?oe={role:"assistant",content:E.value,uuid:se}:oe={role:"user",content:E.value,uuid:se},Ya(p,oe),t(3,E.value="",E),J()},ae=(oe,_e)=>{if(_e&&"SpeechSynthesisUtterance"in window){const se=new SpeechSynthesisUtterance(oe);window.speechSynthesis.speak(se)}},P=()=>{"SpeechSynthesisUtterance"in window&&window.speechSynthesis.cancel()};let j=0;const B=()=>{if(!j){t(7,j=setTimeout(()=>{t(7,j=0)},1e3));return}clearTimeout(j),t(7,j=0),R.controller.abort()},re=async(oe=!1,_e=!1,se=void 0)=>{if(R.updating)return;if(f=oe,!_e){if(t(0,n.sessionStarted=!0,n),vn(),E.value!==""){const bt={role:"user",content:E.value,uuid:Zn()};Ya(p,bt)}else!se&&c.length&&c[c.length-1].role==="assistant"&&(se=c[c.length-1]);t(3,E.value="",E),E.blur(),t(3,E.style.height="auto",E)}J(),t(2,R.updating=!0,R),t(2,R.updatingMessage="",R);let pe=!0,Ee=!1;const Te=bt=>{bt.target&&bt.isTrusted&&Ee&&(pe=window.innerHeight+window.scrollY+10>=document.body.offsetHeight)};window.addEventListener("scroll",Te);try{const bt=await R.sendRequest(c,{chat:n,autoAddMessages:!0,streaming:a.stream,fillMessage:se,onMessageChange:Ue=>{var gt;pe&&F1(!0),Ee=!!((gt=Ue[0])!=null&>.content)}});await bt.promiseToFinish();const He=bt.getMessages()[0];He&&ae(He.content,oe)}catch(bt){console.error(bt)}window.removeEventListener("scroll",Te),t(2,R.updating=!1,R),t(2,R.updatingMessage="",R);const ue=n.messages.filter(bt=>bt.role==="user").length;n.messages.filter(bt=>bt.role==="assistant").length,ue==3&&n.name.startsWith("Chat ")&&ge(),J()},ge=async()=>{const oe={role:"user",content:"Using appropriate language, please tell me a short 6 word summary of this conversation's topic for use as a book title. Only respond with the summary.",uuid:Zn()},_e=c.slice(0,4);_e.push(oe);const se=n.settings.model;t(2,R.updating=!0,R),t(2,R.updatingMessage="Getting suggestion for chat name...",R);const pe=await R.sendRequest(_e,{chat:n,autoAddMessages:!1,streaming:!1,summaryRequest:!0,maxTokens:30});t(0,n.settings.model=se,n);try{await pe.promiseToFinish()}catch(Ee){console.error("Error generating name suggestion",Ee,Ee.stack)}t(2,R.updating=!1,R),t(2,R.updatingMessage="",R),pe.hasError()?Ya(p,{role:"error",content:`Unable to get suggested name: ${pe.getError()}`,uuid:Zn()}):(pe.getMessages().forEach(Ee=>{const Te=Ee.content.split(/\s+/).slice(0,8).join(" ").replace(/^[^a-z0-9!?]+|[^a-z0-9!?]+$/gi,"").trim();Te&&t(0,n.name=Te,n)}),vn())};function we(){ma(WX,{title:"Enter Name for Chat",label:"Name",value:n.name,class:"is-info",onSubmit:oe=>{t(0,n.name=(oe||"").trim()||n.name,n),vn(),wl(Dn,r++,r)}})}const Ae=()=>{P(),!R.updating&&(X?(W==null||W.stop(),t(5,X=!1)):W==null||W.start())};function x(oe){Q=oe,t(6,Q)}function M(oe){E=oe,t(3,E)}const Ie=oe=>{oe.key==="Enter"&&!oe.shiftKey&&(oe.stopPropagation(),re(),oe.preventDefault())},Xe=oe=>qi(oe);function Ge(oe){_n[oe?"unshift":"push"](()=>{E=oe,t(3,E)})}const Ze=()=>re();return l.$$set=oe=>{"params"in oe&&t(16,u=oe.params)},l.$$.update=()=>{l.$$.dirty[0]&2097152&&t(0,n=m.find(oe=>oe.id===p)),l.$$.dirty[0]&1&&(a=n==null?void 0:n.settings),l.$$.dirty[0]&1966080&&A(r,I,o,s),l.$$.dirty[0]&2&&Y(i)},[n,i,R,E,W,X,Q,j,c,p,k,B,re,ge,we,Ae,u,r,s,o,I,m,x,M,Ie,Xe,Ge,Ze]}class YX extends Ht{constructor(e){super(),Qt(this,e,FX,XX,yt,{params:16},null,[-1,-1])}}function wX(l,e,t){let n;tl(l,p7,c=>t(0,n=c));const a=new URLSearchParams(n),r=a.has("p")?f0(or(a.get("p")||"")):f0();return Object.keys(n0()).forEach(c=>{a.has(c)&&x7(c)&&LG(r,c,a.get(c))}),q2(r),ia(`/chat/${r}`),[]}class AX extends Ht{constructor(e){super(),Qt(this,e,wX,null,yt,{})}}function i7(l){let e,t;return e=new Gu({props:{routes:l[1]}}),e.$on("conditionsFailed",l[3]),{c(){fe(e.$$.fragment)},m(n,a){Fe(e,n,a),t=!0},p:lt,i(n){t||(H(e.$$.fragment,n),t=!0)},o(n){L(e.$$.fragment,n),t=!1},d(n){Ye(e,n)}}}function fX(l){let e,t,n;return{c(){e=_("div"),h(e,"slot","backdrop"),h(e,"class","backdrop svelte-efgxn2")},m(a,r){D(a,e,r),t||(n=Qe(e,"click",K2),t=!0)},p:lt,d(a){a&&z(e),t=!1,n()}}}function SX(l){let e,t,n,a,r,c,i=l[0],s,o,I,m,u;e=new gh({}),a=new Lh({});let p=i7(l);return o=new Tu({props:{$$slots:{backdrop:[fX]},$$scope:{ctx:l}}}),{c(){fe(e.$$.fragment),t=he(),n=_("div"),fe(a.$$.fragment),r=he(),c=_("div"),p.c(),s=he(),fe(o.$$.fragment),h(n,"class","side-bar-column"),h(c,"class","main-content-column"),h(c,"id","content")},m(R,E){Fe(e,R,E),D(R,t,E),D(R,n,E),Fe(a,n,null),D(R,r,E),D(R,c,E),p.m(c,null),D(R,s,E),Fe(o,R,E),I=!0,m||(u=Qe(window,"keydown",l[2]),m=!0)},p(R,[E]){E&1&&yt(i,i=R[0])?(ot(),L(p,1,1,lt),It(),p=i7(R),p.c(),H(p,1),p.m(c,null)):p.p(R,E);const W={};E&256&&(W.$$scope={dirty:E,ctx:R}),o.$set(W)},i(R){I||(H(e.$$.fragment,R),H(a.$$.fragment,R),H(p),H(o.$$.fragment,R),I=!0)},o(R){L(e.$$.fragment,R),L(a.$$.fragment,R),L(p),L(o.$$.fragment,R),I=!1},d(R){Ye(e,R),R&&z(t),R&&z(n),Ye(a),R&&z(r),R&&z(c),p.d(R),R&&z(s),Ye(o,R),m=!1,u()}}}function QX(l,e,t){let n,a,r;tl(l,bu,m=>t(0,n=m)),tl(l,il,m=>t(4,a=m)),tl(l,p7,m=>t(5,r=m));const c=new URLSearchParams(r);c.has("key")&&_7({apiKey:c.get("key")}),c.has("petals")&&(console.log("enablePetals"),wa("enablePetals",!0));const i={"/":V9,"/chat/new":Yo({component:AX,conditions:()=>fn()}),"/chat/:chatId":Yo({component:YX,conditions:m=>a.find(u=>{var p;return u.id===parseInt((p=m==null?void 0:m.params)==null?void 0:p.chatId)})!==void 0}),"*":V9},s=(...m)=>{W7()},o=m=>Pu(m),I=()=>ia("/");return l.$$.update=()=>{l.$$.dirty&1&&s(n)},[n,i,o,I]}class HX extends Ht{constructor(e){super(),Qt(this,e,QX,SX,yt,{})}}new HX({target:document.getElementById("app")}); diff --git a/index.html b/index.html index 604f019..7e415cd 100644 --- a/index.html +++ b/index.html @@ -8,7 +8,7 @@ ChatGPT-web - +