import{D as ne,C as le,E as ie,F as Pe,S as ce,i as ue,s as fe,e as m,t as D,k as $,G as M,c as p,a as g,g as A,d as c,n as S,H as T,b as t,I as k,J as Le,f as j,K as i,x as R,h as Ae,L as de,M as he,N as P,O as ge,P as Se,Q as _e,R as Re,j as Te,m as je,o as Ve,T as ze,U as Ge,V as qe,u as ve,v as Be,y as me}from"../chunks/vendor-f44913f5.js";import{p as Ke}from"../chunks/stores-79a3d42c.js";const Qe=ne.default?ne.default:ne,Je="configs";let W='[{ "base_url": "http://localhost:3001", "access_token": "token" }]';const Y=le(JSON.parse(W)),Ue="active_config_index";let pe=0;const Z=le(pe),Fe=ie([Y,Z],([s,e])=>(console.log("[store] Update activeConfig"),s[e])),He=ie([Fe],([s])=>(console.log("[store] Update activeClient"),s?new Qe({baseUrl:s.base_url,token:s.access_token}):void 0)),Xe=ie([He],async([s],e)=>{if(console.log("[store] Update models"),e({}),!s)return;const{data:l}=await s.getModels();e(l)}),We=le(""),Ye={models:Xe,configs:Y,activeConfigIndex:Z,activeConfig:Fe,activeClient:He,filterModels:We};typeof window!="undefined"&&(W=JSON.parse(localStorage.getItem(Je)||W),Y.set(W),Y.subscribe(s=>{localStorage.setItem(Je,JSON.stringify(s))}),pe=parseInt(`${localStorage.getItem(Ue)||"0"}`,10),Z.set(pe),Z.subscribe(s=>{localStorage.setItem(Ue,`${s}`)}));const we={stores:Ye,stringify:s=>JSON.stringify(s,null,2),parse:s=>JSON.parse(s),sanitize:s=>Pe(s,"created_at","updated_at","version","_id")};function Ze(s){let e,l,a,n,u,f;return{c(){e=m("a"),l=D(`NOT CONNECTED \xA0

								`),a=M("svg"),n=M("path"),this.h()},l(d){e=p(d,"A",{href:!0,class:!0,"aria-current":!0});var _=g(e);l=A(_,`NOT CONNECTED \xA0

								`),a=T(_,"svg",{xmlns:!0,class:!0,fill:!0,viewBox:!0,stroke:!0});var h=g(a);n=T(h,"path",{"stroke-linecap":!0,"stroke-linejoin":!0,"stroke-width":!0,d:!0}),g(n).forEach(c),h.forEach(c),_.forEach(c),this.h()},h(){t(n,"stroke-linecap","round"),t(n,"stroke-linejoin","round"),t(n,"stroke-width","2"),t(n,"d","M13 10V3L4 14h7v7l9-11h-7z"),t(a,"xmlns","http://www.w3.org/2000/svg"),t(a,"class","h-4 w-4"),t(a,"fill","none"),t(a,"viewBox","0 0 24 24"),t(a,"stroke","currentColor"),t(e,"href","/config"),t(e,"class","border-red-300 text-red-500 hover:bg-gray-700 hover:text-white px-3 py-2 rounded-md text-sm font-medium flex"),t(e,"aria-current",u=s[3]==="/config"?"page":""),k(e,"bg-gray-900",s[3]==="/config"),k(e,"text-white",s[3]==="/config")},m(d,_){j(d,e,_),i(e,l),i(e,a),i(a,n)},p(d,_){_&8&&u!==(u=d[3]==="/config"?"page":"")&&t(e,"aria-current",u),_&8&&k(e,"bg-gray-900",d[3]==="/config"),_&8&&k(e,"text-white",d[3]==="/config")},i(d){d&&(f||de(()=>{f=he(e,_e,{delay:1e3}),f.start()}))},o:P,d(d){d&&c(e)}}}function et(s){let e,l=(s[0].name||"Models")+"",a,n,u,f,d,_,h;return{c(){e=m("a"),a=D(l),n=D(`

								\xA0

								`),u=M("svg"),f=M("path"),this.h()},l(r){e=p(r,"A",{href:!0,class:!0,"aria-current":!0});var o=g(e);a=A(o,l),n=A(o,`

								\xA0

								`),u=T(o,"svg",{xmlns:!0,class:!0,fill:!0,viewBox:!0,stroke:!0});var w=g(u);f=T(w,"path",{"stroke-linecap":!0,"stroke-linejoin":!0,"stroke-width":!0,d:!0}),g(f).forEach(c),w.forEach(c),o.forEach(c),this.h()},h(){t(f,"stroke-linecap","round"),t(f,"stroke-linejoin","round"),t(f,"stroke-width","2"),t(f,"d","M9.663 17h4.673M12 3v1m6.364 1.636l-.707.707M21 12h-1M4 12H3m3.343-5.657l-.707-.707m2.828 9.9a5 5 0 117.072 0l-.548.547A3.374 3.374 0 0014 18.469V19a2 2 0 11-4 0v-.531c0-.895-.356-1.754-.988-2.386l-.548-.547z"),t(u,"xmlns","http://www.w3.org/2000/svg"),t(u,"class","h-4 w-4"),t(u,"fill","none"),t(u,"viewBox","0 0 24 24"),t(u,"stroke","currentColor"),t(e,"href",d=s[6](s[2],"")),t(e,"class","border-blue-300 text-blue-500 hover:text-white px-3 py-2 rounded-md text-sm font-medium flex"),t(e,"aria-current",_=s[3]===s[6](s[2],"")?"page":""),k(e,"bg-gray-900",s[3]===s[6](s[2],"")),k(e,"text-white",s[3]===s[6](s[2],""))},m(r,o){j(r,e,o),i(e,a),i(e,n),i(e,u),i(u,f)},p(r,o){o&1&&l!==(l=(r[0].name||"Models")+"")&&Ae(a,l),o&4&&d!==(d=r[6](r[2],""))&&t(e,"href",d),o&12&&_!==(_=r[3]===r[6](r[2],"")?"page":"")&&t(e,"aria-current",_),o&76&&k(e,"bg-gray-900",r[3]===r[6](r[2],"")),o&76&&k(e,"text-white",r[3]===r[6](r[2],""))},i(r){r&&(h||de(()=>{h=he(e,_e,{}),h.start()}))},o:P,d(r){r&&c(e)}}}function tt(s){let e,l,a,n,u,f,d,_,h,r,o,w,V,ee,te,z,E,B,L=s[0].base_url+"",G,q,re,J,y,U,se,ae,C,I,oe,O,N;function ke(v,b){return v[1]?et:Ze}let K=ke(s),x=K(s);return{c(){e=m("nav"),l=m("div"),a=m("div"),n=m("div"),u=m("div"),f=m("code"),d=D("Datastore"),_=$(),h=m("div"),r=m("div"),o=m("a"),w=D("Config"),te=$(),x.c(),z=$(),E=m("a"),B=m("code"),G=D(L),re=$(),J=m("div"),y=m("button"),U=m("span"),se=D("Open main menu"),ae=$(),C=M("svg"),I=M("path"),oe=$(),O=M("svg"),N=M("path"),this.h()},l(v){e=p(v,"NAV",{style:!0});var b=g(e);l=p(b,"DIV",{class:!0});var be=g(l);a=p(be,"DIV",{class:!0});var Q=g(a);n=p(Q,"DIV",{class:!0});var X=g(n);u=p(X,"DIV",{class:!0});var Ee=g(u);f=p(Ee,"CODE",{class:!0});var ye=g(f);d=A(ye,"Datastore"),ye.forEach(c),Ee.forEach(c),_=S(X),h=p(X,"DIV",{class:!0});var xe=g(h);r=p(xe,"DIV",{class:!0});var F=g(r);o=p(F,"A",{href:!0,class:!0,"aria-current":!0});var Ce=g(o);w=A(Ce,"Config"),Ce.forEach(c),te=S(F),x.l(F),z=S(F),E=p(F,"A",{href:!0,class:!0,"aria-current":!0});var Oe=g(E);B=p(Oe,"CODE",{class:!0});var Ie=g(B);G=A(Ie,L),Ie.forEach(c),Oe.forEach(c),F.forEach(c),xe.forEach(c),X.forEach(c),re=S(Q),J=p(Q,"DIV",{class:!0});var Ne=g(J);y=p(Ne,"BUTTON",{type:!0,class:!0,"aria-controls":!0,"aria-expanded":!0});var H=g(y);U=p(H,"SPAN",{class:!0});var De=g(U);se=A(De,"Open main menu"),De.forEach(c),ae=S(H),C=T(H,"svg",{class:!0,xmlns:!0,fill:!0,viewBox:!0,stroke:!0,"aria-hidden":!0});var $e=g(C);I=T($e,"path",{"stroke-linecap":!0,"stroke-linejoin":!0,"stroke-width":!0,d:!0}),g(I).forEach(c),$e.forEach(c),oe=S(H),O=T(H,"svg",{class:!0,xmlns:!0,fill:!0,viewBox:!0,stroke:!0,"aria-hidden":!0});var Me=g(O);N=T(Me,"path",{"stroke-linecap":!0,"stroke-linejoin":!0,"stroke-width":!0,d:!0}),g(N).forEach(c),Me.forEach(c),H.forEach(c),Ne.forEach(c),Q.forEach(c),be.forEach(c),b.forEach(c),this.h()},h(){t(f,"class","text-gray-500"),t(u,"class","flex-shrink-0"),t(o,"href","/config"),t(o,"class","text-gray-300 hover:bg-gray-700 hover:text-white px-3 py-2 rounded-md text-sm font-medium"),t(o,"aria-current",V=s[3]==="/config"?"page":""),k(o,"bg-gray-900",s[3]==="/config"),k(o,"text-white",s[3]==="/config"),t(B,"class","text-gray-500"),t(E,"href","/config"),t(E,"class","text-gray-300 hover:text-white px-3 py-2 rounded-md text-sm font-medium"),t(E,"aria-current",q=s[3]==="/config"?"page":""),k(E,"bg-gray-900",s[3]==="/config"),k(E,"text-white",s[3]==="/config"),t(r,"class","flex space-x-4"),t(h,"class","hidden sm:block sm:ml-6"),t(n,"class","flex items-center"),t(U,"class","sr-only"),t(I,"stroke-linecap","round"),t(I,"stroke-linejoin","round"),t(I,"stroke-width","2"),t(I,"d","M4 6h16M4 12h16M4 18h16"),t(C,"class","block h-6 w-6"),t(C,"xmlns","http://www.w3.org/2000/svg"),t(C,"fill","none"),t(C,"viewBox","0 0 24 24"),t(C,"stroke","currentColor"),t(C,"aria-hidden","true"),t(N,"stroke-linecap","round"),t(N,"stroke-linejoin","round"),t(N,"stroke-width","2"),t(N,"d","M6 18L18 6M6 6l12 12"),t(O,"class","hidden h-6 w-6"),t(O,"xmlns","http://www.w3.org/2000/svg"),t(O,"fill","none"),t(O,"viewBox","0 0 24 24"),t(O,"stroke","currentColor"),t(O,"aria-hidden","true"),t(y,"type","button"),t(y,"class","inline-flex items-center justify-center p-2 rounded-md text-gray-400 hover:text-white hover:bg-gray-700 focus:outline-none focus:ring-2 focus:ring-inset focus:ring-white"),t(y,"aria-controls","mobile-menu"),t(y,"aria-expanded","false"),t(J,"class","-mr-2 flex sm:hidden"),t(a,"class","flex items-center justify-between h-16"),t(l,"class","max-w-7xl mx-auto px-4 sm:px-6 lg:px-8"),Le(e,"background-color","#171812")},m(v,b){j(v,e,b),i(e,l),i(l,a),i(a,n),i(n,u),i(u,f),i(f,d),i(n,_),i(n,h),i(h,r),i(r,o),i(o,w),i(r,te),x.m(r,null),i(r,z),i(r,E),i(E,B),i(B,G),i(a,re),i(a,J),i(J,y),i(y,U),i(U,se),i(y,ae),i(y,C),i(C,I),i(y,oe),i(y,O),i(O,N)},p(v,[b]){b&8&&V!==(V=v[3]==="/config"?"page":"")&&t(o,"aria-current",V),b&8&&k(o,"bg-gray-900",v[3]==="/config"),b&8&&k(o,"text-white",v[3]==="/config"),K===(K=ke(v))&&x?x.p(v,b):(x.d(1),x=K(v),x&&(x.c(),R(x,1),x.m(r,z))),b&1&&L!==(L=v[0].base_url+"")&&Ae(G,L),b&8&&q!==(q=v[3]==="/config"?"page":"")&&t(E,"aria-current",q),b&8&&k(E,"bg-gray-900",v[3]==="/config"),b&8&&k(E,"text-white",v[3]==="/config")},i(v){v&&(ee||de(()=>{ee=he(o,_e,{}),ee.start()})),R(x)},o:P,d(v){v&&c(e),x.d()}}}function rt(s,e,l){let a,n,u,f,d,_;ge(s,Ke,w=>l(8,_=w));const h=Se("stores").activeConfig;ge(s,h,w=>l(0,d=w));const r=Se("stores").models;ge(s,r,w=>l(7,f=w));function o(w,V){return`/${w||"datastore"}/${V}`.toLowerCase()}return s.$$.update=()=>{s.$$.dirty&256&&l(3,a=_.path),s.$$.dirty&1&&l(2,n=d.name||"datastore"),s.$$.dirty&128&&l(1,u=Object.keys(f||{})[0])},[d,u,n,a,h,r,o,f,_]}class st extends ce{constructor(e){super();ue(this,e,rt,tt,fe,{})}}function at(s){let e,l;return{c(){e=m("footer"),l=D("..."),this.h()},l(a){e=p(a,"FOOTER",{class:!0});var n=g(e);l=A(n,"..."),n.forEach(c),this.h()},h(){t(e,"class","w-full mt-auto bg-gray-700")},m(a,n){j(a,e,n),i(e,l)},p:P,i:P,o:P,d(a){a&&c(e)}}}class ot extends ce{constructor(e){super();ue(this,e,null,at,fe,{})}}function nt(s){let e,l,a,n,u,f,d;e=new st({});const _=s[1].default,h=Re(_,s,s[0],null);return f=new ot({}),{c(){Te(e.$$.fragment),l=$(),a=m("div"),n=m("main"),h&&h.c(),u=$(),Te(f.$$.fragment),this.h()},l(r){je(e.$$.fragment,r),l=S(r),a=p(r,"DIV",{class:!0});var o=g(a);n=p(o,"MAIN",{role:!0,class:!0});var w=g(n);h&&h.l(w),w.forEach(c),o.forEach(c),u=S(r),je(f.$$.fragment,r),this.h()},h(){t(n,"role","main"),t(n,"class","bg-gray-100 w-full h-screen flex-grow overflow-auto"),t(a,"class","w-full flex flex-col sm:flex-row flex-grow overflow-hidden")},m(r,o){Ve(e,r,o),j(r,l,o),j(r,a,o),i(a,n),h&&h.m(n,null),j(r,u,o),Ve(f,r,o),d=!0},p(r,[o]){h&&h.p&&(!d||o&1)&&ze(h,_,r,r[0],d?qe(_,r[0],o,null):Ge(r[0]),null)},i(r){d||(R(e.$$.fragment,r),R(h,r),R(f.$$.fragment,r),d=!0)},o(r){ve(e.$$.fragment,r),ve(h,r),ve(f.$$.fragment,r),d=!1},d(r){Be(e,r),r&&c(l),r&&c(a),h&&h.d(r),r&&c(u),Be(f,r)}}}function lt(s,e,l){let{$$slots:a={},$$scope:n}=e;return me("services",we),me("datastore",we.datastore),me("stores",we.stores),s.$$set=u=>{"$$scope"in u&&l(0,n=u.$$scope)},[n,a]}class ut extends ce{constructor(e){super();ue(this,e,lt,nt,fe,{})}}export{ut as default};
