import{D as _e,C as Z,E as ve,F as We,S as me,i as pe,s as we,e as m,t as A,k as D,G as V,c as p,a as h,g as N,d as u,n as $,H as j,b as e,I as w,J as Ye,f as B,K as i,x as z,h as Je,L as ee,M as te,N as L,O as be,P as Pe,Q as re,R as Ze,j as Fe,m as Le,o as Re,T as et,U as tt,V as rt,u as ke,v as ze,y as Ee}from"../chunks/vendor-cb8fe21e.js";import{p as at}from"../chunks/stores-3696a338.js";const st=_e.default?_e.default:_e,Ge="configs";let ae='[{ "base_url": "http://localhost:3001", "access_token": "token" }]';const se=Z(JSON.parse(ae)),qe="active_config_index";let ye=0;const oe=Z(ye),Ke=ve([se,oe],([a,t])=>(console.log("[store] Update activeConfig"),a[t])),Qe=ve([Ke],([a])=>(console.log("[store] Update activeClient"),a?new st({baseUrl:a.base_url,token:a.access_token}):void 0)),ot=ve([Qe],async([a],t)=>{if(console.log("[store] Update models"),t({}),!!a)try{const{data:l}=await a.getModels();t(l)}catch(l){console.error(l)}}),nt=Z(""),Xe="editor_value";let xe="";const Ce=Z(xe),it={models:ot,configs:se,activeConfigIndex:oe,activeConfig:Ke,activeClient:Qe,filterModels:nt,editorValue:Ce};typeof window!="undefined"&&(ae=JSON.parse(localStorage.getItem(Ge)||ae),se.set(ae),se.subscribe(a=>{localStorage.setItem(Ge,JSON.stringify(a))}),ye=parseInt(`${localStorage.getItem(qe)||"0"}`,10),oe.set(ye),oe.subscribe(a=>{localStorage.setItem(qe,`${a}`)}),xe=localStorage.getItem(Xe)||"",Ce.set(xe),Ce.subscribe(a=>{localStorage.setItem(Xe,`${a}`)}));const Ie={stores:it,stringify:a=>JSON.stringify(a,null,2),parse:a=>JSON.parse(a),sanitize:a=>We(a,"created_at","updated_at","version","_id")};function lt(a){let t,l,s,n,c,f;return{c(){t=m("a"),l=A(`NOT CONNECTED \xA0

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

								`),s=j(_,"svg",{xmlns:!0,class:!0,fill:!0,viewBox:!0,stroke:!0});var g=h(s);n=j(g,"path",{"stroke-linecap":!0,"stroke-linejoin":!0,"stroke-width":!0,d:!0}),h(n).forEach(u),g.forEach(u),_.forEach(u),this.h()},h(){e(n,"stroke-linecap","round"),e(n,"stroke-linejoin","round"),e(n,"stroke-width","2"),e(n,"d","M13 10V3L4 14h7v7l9-11h-7z"),e(s,"xmlns","http://www.w3.org/2000/svg"),e(s,"class","h-4 w-4"),e(s,"fill","none"),e(s,"viewBox","0 0 24 24"),e(s,"stroke","currentColor"),e(t,"href","/config"),e(t,"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"),e(t,"aria-current",c=a[3]==="/config"?"page":""),w(t,"bg-gray-900",a[3]==="/config"),w(t,"text-white",a[3]==="/config")},m(d,_){B(d,t,_),i(t,l),i(t,s),i(s,n)},p(d,_){_&8&&c!==(c=d[3]==="/config"?"page":"")&&e(t,"aria-current",c),_&8&&w(t,"bg-gray-900",d[3]==="/config"),_&8&&w(t,"text-white",d[3]==="/config")},i(d){d&&(f||ee(()=>{f=te(t,re,{delay:1e3}),f.start()}))},o:L,d(d){d&&u(t)}}}function ut(a){let t,l=(a[0].name||"Models")+"",s,n,c,f,d,_,g;return{c(){t=m("a"),s=A(l),n=A(`

								\xA0

								`),c=V("svg"),f=V("path"),this.h()},l(r){t=p(r,"A",{href:!0,class:!0,"aria-current":!0});var o=h(t);s=N(o,l),n=N(o,`

								\xA0

								`),c=j(o,"svg",{xmlns:!0,class:!0,fill:!0,viewBox:!0,stroke:!0});var b=h(c);f=j(b,"path",{"stroke-linecap":!0,"stroke-linejoin":!0,"stroke-width":!0,d:!0}),h(f).forEach(u),b.forEach(u),o.forEach(u),this.h()},h(){e(f,"stroke-linecap","round"),e(f,"stroke-linejoin","round"),e(f,"stroke-width","2"),e(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"),e(c,"xmlns","http://www.w3.org/2000/svg"),e(c,"class","h-4 w-4"),e(c,"fill","none"),e(c,"viewBox","0 0 24 24"),e(c,"stroke","currentColor"),e(t,"href",d=a[6](a[2],"")),e(t,"class","border-blue-300 text-blue-500 hover:text-white px-3 py-2 rounded-md text-sm font-medium flex"),e(t,"aria-current",_=a[3]===a[6](a[2],"")?"page":""),w(t,"bg-gray-900",a[3]===a[6](a[2],"")),w(t,"text-white",a[3]===a[6](a[2],""))},m(r,o){B(r,t,o),i(t,s),i(t,n),i(t,c),i(c,f)},p(r,o){o&1&&l!==(l=(r[0].name||"Models")+"")&&Je(s,l),o&4&&d!==(d=r[6](r[2],""))&&e(t,"href",d),o&12&&_!==(_=r[3]===r[6](r[2],"")?"page":"")&&e(t,"aria-current",_),o&76&&w(t,"bg-gray-900",r[3]===r[6](r[2],"")),o&76&&w(t,"text-white",r[3]===r[6](r[2],""))},i(r){r&&(g||ee(()=>{g=te(t,re,{}),g.start()}))},o:L,d(r){r&&u(t)}}}function ct(a){let t,l,s,n,c,f,d,_,g,r,o,b,U,ne,ie,E,le,G,ue,ce,q,y,H,R=a[0].base_url+"",K,Q,fe,J,x,P,de,ge,I,M,he,O,S;function Oe(v,k){return v[1]?ut:lt}let X=Oe(a),C=X(a);return{c(){t=m("nav"),l=m("div"),s=m("div"),n=m("div"),c=m("div"),f=m("code"),d=A("Datastore"),_=D(),g=m("div"),r=m("div"),o=m("a"),b=A("Config"),ie=D(),E=m("a"),le=A("Aggregation"),ce=D(),C.c(),q=D(),y=m("a"),H=m("code"),K=A(R),fe=D(),J=m("div"),x=m("button"),P=m("span"),de=A("Open main menu"),ge=D(),I=V("svg"),M=V("path"),he=D(),O=V("svg"),S=V("path"),this.h()},l(v){t=p(v,"NAV",{style:!0});var k=h(t);l=p(k,"DIV",{class:!0});var Ae=h(l);s=p(Ae,"DIV",{class:!0});var W=h(s);n=p(W,"DIV",{class:!0});var Y=h(n);c=p(Y,"DIV",{class:!0});var De=h(c);f=p(De,"CODE",{class:!0});var Ne=h(f);d=N(Ne,"Datastore"),Ne.forEach(u),De.forEach(u),_=$(Y),g=p(Y,"DIV",{class:!0});var $e=h(g);r=p($e,"DIV",{class:!0});var T=h(r);o=p(T,"A",{href:!0,class:!0,"aria-current":!0});var Me=h(o);b=N(Me,"Config"),Me.forEach(u),ie=$(T),E=p(T,"A",{href:!0,class:!0,"aria-current":!0});var Se=h(E);le=N(Se,"Aggregation"),Se.forEach(u),ce=$(T),C.l(T),q=$(T),y=p(T,"A",{href:!0,class:!0,"aria-current":!0});var Te=h(y);H=p(Te,"CODE",{class:!0});var Ve=h(H);K=N(Ve,R),Ve.forEach(u),Te.forEach(u),T.forEach(u),$e.forEach(u),Y.forEach(u),fe=$(W),J=p(W,"DIV",{class:!0});var je=h(J);x=p(je,"BUTTON",{type:!0,class:!0,"aria-controls":!0,"aria-expanded":!0});var F=h(x);P=p(F,"SPAN",{class:!0});var Be=h(P);de=N(Be,"Open main menu"),Be.forEach(u),ge=$(F),I=j(F,"svg",{class:!0,xmlns:!0,fill:!0,viewBox:!0,stroke:!0,"aria-hidden":!0});var Ue=h(I);M=j(Ue,"path",{"stroke-linecap":!0,"stroke-linejoin":!0,"stroke-width":!0,d:!0}),h(M).forEach(u),Ue.forEach(u),he=$(F),O=j(F,"svg",{class:!0,xmlns:!0,fill:!0,viewBox:!0,stroke:!0,"aria-hidden":!0});var He=h(O);S=j(He,"path",{"stroke-linecap":!0,"stroke-linejoin":!0,"stroke-width":!0,d:!0}),h(S).forEach(u),He.forEach(u),F.forEach(u),je.forEach(u),W.forEach(u),Ae.forEach(u),k.forEach(u),this.h()},h(){e(f,"class","text-gray-500"),e(c,"class","flex-shrink-0"),e(o,"href","/config"),e(o,"class","text-gray-300 hover:bg-gray-700 hover:text-white px-3 py-2 rounded-md text-sm font-medium"),e(o,"aria-current",U=a[3]==="/config"?"page":""),w(o,"bg-gray-900",a[3]==="/config"),w(o,"text-white",a[3]==="/config"),e(E,"href","/aggregation"),e(E,"class","text-gray-300 hover:bg-gray-700 hover:text-white px-3 py-2 rounded-md text-sm font-medium"),e(E,"aria-current",G=a[3]==="/aggregation"?"page":""),w(E,"bg-gray-900",a[3]==="/aggregation"),w(E,"text-white",a[3]==="/aggregation"),e(H,"class","text-gray-500"),e(y,"href","/config"),e(y,"class","text-gray-300 hover:text-white px-3 py-2 rounded-md text-sm font-medium"),e(y,"aria-current",Q=a[3]==="/config"?"page":""),w(y,"bg-gray-900",a[3]==="/config"),w(y,"text-white",a[3]==="/config"),e(r,"class","flex space-x-4"),e(g,"class","hidden sm:block sm:ml-6"),e(n,"class","flex items-center"),e(P,"class","sr-only"),e(M,"stroke-linecap","round"),e(M,"stroke-linejoin","round"),e(M,"stroke-width","2"),e(M,"d","M4 6h16M4 12h16M4 18h16"),e(I,"class","block h-6 w-6"),e(I,"xmlns","http://www.w3.org/2000/svg"),e(I,"fill","none"),e(I,"viewBox","0 0 24 24"),e(I,"stroke","currentColor"),e(I,"aria-hidden","true"),e(S,"stroke-linecap","round"),e(S,"stroke-linejoin","round"),e(S,"stroke-width","2"),e(S,"d","M6 18L18 6M6 6l12 12"),e(O,"class","hidden h-6 w-6"),e(O,"xmlns","http://www.w3.org/2000/svg"),e(O,"fill","none"),e(O,"viewBox","0 0 24 24"),e(O,"stroke","currentColor"),e(O,"aria-hidden","true"),e(x,"type","button"),e(x,"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"),e(x,"aria-controls","mobile-menu"),e(x,"aria-expanded","false"),e(J,"class","-mr-2 flex sm:hidden"),e(s,"class","flex items-center justify-between h-16"),e(l,"class","max-w-7xl mx-auto px-4 sm:px-6 lg:px-8"),Ye(t,"background-color","#171812")},m(v,k){B(v,t,k),i(t,l),i(l,s),i(s,n),i(n,c),i(c,f),i(f,d),i(n,_),i(n,g),i(g,r),i(r,o),i(o,b),i(r,ie),i(r,E),i(E,le),i(r,ce),C.m(r,null),i(r,q),i(r,y),i(y,H),i(H,K),i(s,fe),i(s,J),i(J,x),i(x,P),i(P,de),i(x,ge),i(x,I),i(I,M),i(x,he),i(x,O),i(O,S)},p(v,[k]){k&8&&U!==(U=v[3]==="/config"?"page":"")&&e(o,"aria-current",U),k&8&&w(o,"bg-gray-900",v[3]==="/config"),k&8&&w(o,"text-white",v[3]==="/config"),k&8&&G!==(G=v[3]==="/aggregation"?"page":"")&&e(E,"aria-current",G),k&8&&w(E,"bg-gray-900",v[3]==="/aggregation"),k&8&&w(E,"text-white",v[3]==="/aggregation"),X===(X=Oe(v))&&C?C.p(v,k):(C.d(1),C=X(v),C&&(C.c(),z(C,1),C.m(r,q))),k&1&&R!==(R=v[0].base_url+"")&&Je(K,R),k&8&&Q!==(Q=v[3]==="/config"?"page":"")&&e(y,"aria-current",Q),k&8&&w(y,"bg-gray-900",v[3]==="/config"),k&8&&w(y,"text-white",v[3]==="/config")},i(v){v&&(ne||ee(()=>{ne=te(o,re,{}),ne.start()})),v&&(ue||ee(()=>{ue=te(E,re,{}),ue.start()})),z(C)},o:L,d(v){v&&u(t),C.d()}}}function ft(a,t,l){let s,n,c,f,d,_;be(a,at,b=>l(8,_=b));const g=Pe("stores").activeConfig;be(a,g,b=>l(0,d=b));const r=Pe("stores").models;be(a,r,b=>l(7,f=b));function o(b,U){return`/${b||"datastore"}/${U}`.toLowerCase()}return a.$$.update=()=>{a.$$.dirty&256&&l(3,s=_.path),a.$$.dirty&1&&l(2,n=d.name||"datastore"),a.$$.dirty&128&&l(1,c=Object.keys(f||{})[0])},[d,c,n,s,g,r,o,f,_]}class dt extends me{constructor(t){super();pe(this,t,ft,ct,we,{})}}function gt(a){let t,l;return{c(){t=m("footer"),l=A("..."),this.h()},l(s){t=p(s,"FOOTER",{class:!0});var n=h(t);l=N(n,"..."),n.forEach(u),this.h()},h(){e(t,"class","w-full mt-auto bg-gray-700")},m(s,n){B(s,t,n),i(t,l)},p:L,i:L,o:L,d(s){s&&u(t)}}}class ht extends me{constructor(t){super();pe(this,t,null,gt,we,{})}}function _t(a){let t,l,s,n,c,f,d;t=new dt({});const _=a[1].default,g=Ze(_,a,a[0],null);return f=new ht({}),{c(){Fe(t.$$.fragment),l=D(),s=m("div"),n=m("main"),g&&g.c(),c=D(),Fe(f.$$.fragment),this.h()},l(r){Le(t.$$.fragment,r),l=$(r),s=p(r,"DIV",{class:!0});var o=h(s);n=p(o,"MAIN",{role:!0,class:!0});var b=h(n);g&&g.l(b),b.forEach(u),o.forEach(u),c=$(r),Le(f.$$.fragment,r),this.h()},h(){e(n,"role","main"),e(n,"class","bg-gray-100 w-full h-screen flex-grow overflow-auto"),e(s,"class","w-full flex flex-col sm:flex-row flex-grow overflow-hidden")},m(r,o){Re(t,r,o),B(r,l,o),B(r,s,o),i(s,n),g&&g.m(n,null),B(r,c,o),Re(f,r,o),d=!0},p(r,[o]){g&&g.p&&(!d||o&1)&&et(g,_,r,r[0],d?rt(_,r[0],o,null):tt(r[0]),null)},i(r){d||(z(t.$$.fragment,r),z(g,r),z(f.$$.fragment,r),d=!0)},o(r){ke(t.$$.fragment,r),ke(g,r),ke(f.$$.fragment,r),d=!1},d(r){ze(t,r),r&&u(l),r&&u(s),g&&g.d(r),r&&u(c),ze(f,r)}}}function vt(a,t,l){let{$$slots:s={},$$scope:n}=t;return Ee("services",Ie),Ee("datastore",Ie.datastore),Ee("stores",Ie.stores),a.$$set=c=>{"$$scope"in c&&l(0,n=c.$$scope)},[n,s]}class wt extends me{constructor(t){super();pe(this,t,vt,_t,we,{})}}export{wt as default};
