text: import{S as e,i as t,s as l,e as a,t as s,k as n,c,a as r,g as i,d as o,n as d,b as h,N as f,f as p,F as u,G as E,h as v,Q as w,M as m,j as g,L as T,m as b,o as y,v as D,r as x,w as C,z as B,T as I}from"../../chunks/vendor-c052606d.js";import{T as k,x as S,g as V,a as N,R,n as F}from"../../chunks/requests-531e903b.js";/* empty css                                                       */const{document:O}=I;function U(e,t,l){const a=e.slice();return a[11]=t[l],a[13]=l,a}function H(e,t,l){const a=e.slice();return a[14]=t[l],a[13]=l,a}function A(e,t,l){const a=e.slice();return a[16]=t[l],a[13]=l,a}function L(e){let t,l,E,v,w,g,T,b,y,D,x,C=e[1],B=[];for(let a=0;a<C.length;a+=1)B[a]=G(A(e,C,a));return{c(){t=a("div"),l=a("div"),E=a("table"),v=a("thead"),w=a("tr"),g=a("th"),T=s("Filename"),b=n(),y=a("th"),D=s("Actions"),x=n();for(let e=0;e<B.length;e+=1)B[e].c();this.h()},l(e){t=c(e,"DIV",{class:!0});var a=r(t);l=c(a,"DIV",{class:!0});var s=r(l);E=c(s,"TABLE",{class:!0,style:!0});var n=r(E);v=c(n,"THEAD",{});var h=r(v);w=c(h,"TR",{class:!0});var f=r(w);g=c(f,"TH",{class:!0});var p=r(g);T=i(p,"Filename"),p.forEach(o),b=d(f),y=c(f,"TH",{class:!0});var u=r(y);D=i(u,"Actions"),u.forEach(o),f.forEach(o),h.forEach(o),x=d(n);for(let t=0;t<B.length;t+=1)B[t].l(n);n.forEach(o),s.forEach(o),a.forEach(o),this.h()},h(){h(g,"class","w3-left-align"),h(y,"class","w3-right-align"),h(w,"class","w3-dark-grey"),h(E,"class","w3-table-all"),f(E,"width","100%"),h(l,"class","w3-responsive"),h(t,"class","w3-container")},m(e,a){p(e,t,a),u(t,l),u(l,E),u(E,v),u(v,w),u(w,g),u(g,T),u(w,b),u(w,y),u(y,D),u(E,x);for(let t=0;t<B.length;t+=1)B[t].m(E,null)},p(e,t){if(50&t){let l;for(C=e[1],l=0;l<C.length;l+=1){const a=A(e,C,l);B[l]?B[l].p(a,t):(B[l]=G(a),B[l].c(),B[l].m(E,null))}for(;l<B.length;l+=1)B[l].d(1);B.length=C.length}},d(e){e&&o(t),m(B,e)}}}function G(e){let t,l,f,m,g,T,b,y,D,x,C,B,I,k,S=e[16]+"";return{c(){t=a("tr"),l=a("td"),f=s(S),m=n(),g=a("td"),T=a("div"),b=a("button"),y=s("Edit"),D=n(),x=a("button"),C=s("Download"),B=n(),this.h()},l(e){t=c(e,"TR",{});var a=r(t);l=c(a,"TD",{class:!0});var s=r(l);f=i(s,S),s.forEach(o),m=d(a),g=c(a,"TD",{class:!0});var n=r(g);T=c(n,"DIV",{});var h=r(T);b=c(h,"BUTTON",{index:!0});var p=r(b);y=i(p,"Edit"),p.forEach(o),D=d(h),x=c(h,"BUTTON",{index:!0});var u=r(x);C=i(u,"Download"),u.forEach(o),h.forEach(o),n.forEach(o),B=d(a),a.forEach(o),this.h()},h(){h(l,"class","w3-left-align"),h(b,"index",e[13]),h(x,"index",e[13]),h(g,"class","w3-right-align")},m(a,s){p(a,t,s),u(t,l),u(l,f),u(t,m),u(t,g),u(g,T),u(T,b),u(b,y),u(T,D),u(T,x),u(x,C),u(t,B),I||(k=[E(b,"click",e[5]),E(x,"click",e[4])],I=!0)},p(e,t){2&t&&S!==(S=e[16]+"")&&v(f,S)},d(e){e&&o(t),I=!1,w(k)}}}function j(e){let t,l,E,v,w,g,T,b,y,D,x,C,B=e[2],I=[];for(let a=0;a<B.length;a+=1)I[a]=P(H(e,B,a));return{c(){t=a("div"),l=a("div"),E=a("table"),v=a("thead"),w=a("tr"),g=a("th"),T=s("Content"),b=n(),y=a("th"),D=s("Labels"),x=n(),C=a("tbody");for(let e=0;e<I.length;e+=1)I[e].c();this.h()},l(e){t=c(e,"DIV",{class:!0});var a=r(t);l=c(a,"DIV",{class:!0});var s=r(l);E=c(s,"TABLE",{id:!0,class:!0,style:!0});var n=r(E);v=c(n,"THEAD",{});var h=r(v);w=c(h,"TR",{class:!0});var f=r(w);g=c(f,"TH",{class:!0});var p=r(g);T=i(p,"Content"),p.forEach(o),b=d(f),y=c(f,"TH",{class:!0});var u=r(y);D=i(u,"Labels"),u.forEach(o),f.forEach(o),h.forEach(o),x=d(n),C=c(n,"TBODY",{});var m=r(C);for(let t=0;t<I.length;t+=1)I[t].l(m);m.forEach(o),n.forEach(o),s.forEach(o),a.forEach(o),this.h()},h(){h(g,"class","w3-left-align"),h(y,"class","w3-right-align"),h(w,"class","w3-dark-grey"),h(E,"id","editTable"),h(E,"class","w3-table-all"),f(E,"width","100%"),h(l,"class","w3-responsive"),h(t,"class","w3-container")},m(e,a){p(e,t,a),u(t,l),u(l,E),u(E,v),u(v,w),u(w,g),u(g,T),u(w,b),u(w,y),u(y,D),u(E,x),u(E,C);for(let t=0;t<I.length;t+=1)I[t].m(C,null)},p(e,t){if(4&t){let l;for(B=e[2],l=0;l<B.length;l+=1){const a=H(e,B,l);I[l]?I[l].p(a,t):(I[l]=P(a),I[l].c(),I[l].m(C,null))}for(;l<I.length;l+=1)I[l].d(1);I.length=B.length}},d(e){e&&o(t),m(I,e)}}}function P(e){let t,l,f,E,w,m,g,T,b=JSON.stringify(e[14],null,2)+"";return{c(){t=a("tr"),l=a("td"),f=s(b),E=n(),w=a("td"),m=a("div"),g=a("input"),T=n(),this.h()},l(e){t=c(e,"TR",{});var a=r(t);l=c(a,"TD",{class:!0});var s=r(l);f=i(s,b),s.forEach(o),E=d(a),w=c(a,"TD",{class:!0});var n=r(w);m=c(n,"DIV",{});var h=r(m);g=c(h,"INPUT",{class:!0,type:!0,checked:!0,index:!0}),h.forEach(o),n.forEach(o),T=d(a),a.forEach(o),this.h()},h(){h(l,"class","w3-left-align"),h(g,"class","w3-check"),h(g,"type","checkbox"),g.checked="",h(g,"index",e[13]),h(w,"class","w3-right-align")},m(e,a){p(e,t,a),u(t,l),u(l,f),u(t,E),u(t,w),u(w,m),u(m,g),u(t,T)},p(e,t){4&t&&b!==(b=JSON.stringify(e[14],null,2)+"")&&v(f,b)},d(e){e&&o(t)}}}function $(e){let t,l,E,v,w,g,T,b,y,D,x,C=e[0],B=[];for(let a=0;a<C.length;a+=1)B[a]=J(U(e,C,a));return{c(){t=a("div"),l=a("div"),E=a("table"),v=a("thead"),w=a("tr"),g=a("th"),T=s("Filename"),b=n(),y=a("th"),D=s("Actions"),x=n();for(let e=0;e<B.length;e+=1)B[e].c();this.h()},l(e){t=c(e,"DIV",{class:!0});var a=r(t);l=c(a,"DIV",{class:!0});var s=r(l);E=c(s,"TABLE",{class:!0,style:!0});var n=r(E);v=c(n,"THEAD",{});var h=r(v);w=c(h,"TR",{class:!0});var f=r(w);g=c(f,"TH",{class:!0});var p=r(g);T=i(p,"Filename"),p.forEach(o),b=d(f),y=c(f,"TH",{class:!0});var u=r(y);D=i(u,"Actions"),u.forEach(o),f.forEach(o),h.forEach(o),x=d(n);for(let t=0;t<B.length;t+=1)B[t].l(n);n.forEach(o),s.forEach(o),a.forEach(o),this.h()},h(){h(g,"class","w3-left-align"),h(y,"class","w3-right-align"),h(w,"class","w3-dark-grey"),h(E,"class","w3-table-all"),f(E,"width","100%"),h(l,"class","w3-responsive"),h(t,"class","w3-container")},m(e,a){p(e,t,a),u(t,l),u(l,E),u(E,v),u(v,w),u(w,g),u(g,T),u(w,b),u(w,y),u(y,D),u(E,x);for(let t=0;t<B.length;t+=1)B[t].m(E,null)},p(e,t){if(769&t){let l;for(C=e[0],l=0;l<C.length;l+=1){const a=U(e,C,l);B[l]?B[l].p(a,t):(B[l]=J(a),B[l].c(),B[l].m(E,null))}for(;l<B.length;l+=1)B[l].d(1);B.length=C.length}},d(e){e&&o(t),m(B,e)}}}function J(e){let t,l,f,m,g,T,b,y,D,x,C,B,I,k,S=e[11]+"";return{c(){t=a("tr"),l=a("td"),f=s(S),m=n(),g=a("td"),T=a("div"),b=a("button"),y=s("Delete"),D=n(),x=a("button"),C=s("Download"),B=n(),this.h()},l(e){t=c(e,"TR",{});var a=r(t);l=c(a,"TD",{class:!0});var s=r(l);f=i(s,S),s.forEach(o),m=d(a),g=c(a,"TD",{class:!0});var n=r(g);T=c(n,"DIV",{});var h=r(T);b=c(h,"BUTTON",{index:!0});var p=r(b);y=i(p,"Delete"),p.forEach(o),D=d(h),x=c(h,"BUTTON",{index:!0});var u=r(x);C=i(u,"Download"),u.forEach(o),h.forEach(o),n.forEach(o),B=d(a),a.forEach(o),this.h()},h(){h(l,"class","w3-left-align"),h(b,"index",e[13]),h(x,"index",e[13]),h(g,"class","w3-right-align")},m(a,s){p(a,t,s),u(t,l),u(l,f),u(t,m),u(t,g),u(g,T),u(T,b),u(b,y),u(T,D),u(T,x),u(x,C),u(t,B),I||(k=[E(b,"click",e[8]),E(x,"click",e[9])],I=!0)},p(e,t){1&t&&S!==(S=e[11]+"")&&v(f,S)},d(e){e&&o(t),I=!1,w(k)}}}function q(e){let t,l,v,m,B,I,S,V,N,R,F,U,H,A,G,P,J,q,z,Y,_,K,W,X,Z,ee,te,le,ae,se,ne,ce,re,ie,oe,de,he,fe,pe,ue,Ee,ve,we,me,ge,Te,be,ye,De,xe,Ce,Be,Ie,ke,Se,Ve,Ne,Re,Fe,Oe,Ue,He,Ae,Le;l=new k({});let Ge=e[1].length>0&&L(e),je=e[2].length>0&&j(e),Pe=e[0].length>0&&$(e);return{c(){t=n(),g(l.$$.fragment),v=n(),m=a("div"),B=a("h1"),I=a("b"),S=s("Capfiles"),V=n(),Ge&&Ge.c(),N=n(),R=a("hr"),F=n(),U=a("div"),H=a("h1"),A=a("b"),G=s("Edit Capfile Content"),P=s('\n\non click on "Edit" in capfiles table, displays table with capfile content\n\n\n'),J=a("div"),q=a("div"),z=a("button"),Y=s("Apply Filter"),_=n(),K=a("div"),W=a("input"),X=n(),Z=a("br"),ee=n(),te=a("div"),le=a("button"),ae=s("Toggle All Labels"),se=n(),ne=a("br"),ce=n(),je&&je.c(),re=n(),ie=a("br"),oe=n(),de=a("div"),he=a("div"),fe=a("input"),pe=n(),ue=a("div"),Ee=a("button"),ve=s("Convert to CSV and Store to GridFs"),we=n(),me=a("div"),ge=a("button"),Te=s("Download Table as CSV"),be=n(),ye=a("hr"),De=n(),xe=a("div"),Ce=a("h1"),Be=a("b"),Ie=s("Gridfs Files (CSVs stored in GridFS)"),ke=n(),Se=a("button"),Ve=s("Reload GrifFS"),Ne=n(),Re=a("hr"),Fe=n(),Pe&&Pe.c(),Oe=n(),Ue=a("hr"),this.h()},l(e){T('[data-svelte="svelte-qmgm2y"]',O.head).forEach(o),t=d(e),b(l.$$.fragment,e),v=d(e),m=c(e,"DIV",{class:!0});var a=r(m);B=c(a,"H1",{class:!0,style:!0});var s=r(B);I=c(s,"B",{});var n=r(I);S=i(n,"Capfiles"),n.forEach(o),s.forEach(o),a.forEach(o),V=d(e),Ge&&Ge.l(e),N=d(e),R=c(e,"HR",{class:!0}),F=d(e),U=c(e,"DIV",{class:!0});var h=r(U);H=c(h,"H1",{class:!0,style:!0});var f=r(H);A=c(f,"B",{});var p=r(A);G=i(p,"Edit Capfile Content"),p.forEach(o),f.forEach(o),h.forEach(o),P=i(e,'\n\non click on "Edit" in capfiles table, displays table with capfile content\n\n\n'),J=c(e,"DIV",{class:!0});var u=r(J);q=c(u,"DIV",{class:!0});var E=r(q);z=c(E,"BUTTON",{ref:!0,class:!0});var w=r(z);Y=i(w,"Apply Filter"),w.forEach(o),E.forEach(o),_=d(u),K=c(u,"DIV",{class:!0});var g=r(K);W=c(g,"INPUT",{id:!0,class:!0,name:!0,type:!0,placeholder:!0}),g.forEach(o),u.forEach(o),X=d(e),Z=c(e,"BR",{}),ee=d(e),te=c(e,"DIV",{class:!0});var y=r(te);le=c(y,"BUTTON",{class:!0});var D=r(le);ae=i(D,"Toggle All Labels"),D.forEach(o),y.forEach(o),se=d(e),ne=c(e,"BR",{}),ce=d(e),je&&je.l(e),re=d(e),ie=c(e,"BR",{}),oe=d(e),de=c(e,"DIV",{class:!0});var x=r(de);he=c(x,"DIV",{class:!0});var C=r(he);fe=c(C,"INPUT",{id:!0,class:!0,name:!0,type:!0,placeholder:!0}),C.forEach(o),pe=d(x),ue=c(x,"DIV",{class:!0});var k=r(ue);Ee=c(k,"BUTTON",{class:!0});var L=r(Ee);ve=i(L,"Convert to CSV and Store to GridFs"),L.forEach(o),k.forEach(o),we=d(x),me=c(x,"DIV",{class:!0});var j=r(me);ge=c(j,"BUTTON",{class:!0});var $=r(ge);Te=i($,"Download Table as CSV"),$.forEach(o),j.forEach(o),x.forEach(o),be=d(e),ye=c(e,"HR",{class:!0}),De=d(e),xe=c(e,"DIV",{class:!0});var M=r(xe);Ce=c(M,"H1",{class:!0,style:!0});var Q=r(Ce);Be=c(Q,"B",{});var He=r(Be);Ie=i(He,"Gridfs Files (CSVs stored in GridFS)"),He.forEach(o),Q.forEach(o),M.forEach(o),ke=d(e),Se=c(e,"BUTTON",{class:!0});var Ae=r(Se);Ve=i(Ae,"Reload GrifFS"),Ae.forEach(o),Ne=d(e),Re=c(e,"HR",{class:!0}),Fe=d(e),Pe&&Pe.l(e),Oe=d(e),Ue=c(e,"HR",{class:!0}),this.h()},h(){O.title="Database",h(B,"class","w3-text-yellow"),f(B,"text-shadow","1px 1px 0 #444"),h(m,"class","w3-panel w3-blue"),h(R,"class","svelte-lxonyp"),h(H,"class","w3-text-yellow"),f(H,"text-shadow","1px 1px 0 #444"),h(U,"class","w3-panel w3-blue"),h(z,"ref","filterTable"),h(z,"class","w3-col w3-input w3-border"),h(q,"class","w3-third"),h(W,"id","filterTable"),h(W,"class","w3-input w3-border"),h(W,"name","name"),h(W,"type","text"),h(W,"placeholder","Filter String"),h(K,"class","w3-rest"),h(J,"class","w3-row w3-section"),h(le,"class","w3-col w3-input w3-border"),h(te,"class","w3-row w3-section"),h(fe,"id","filenameCSV"),h(fe,"class","w3-input w3-border"),h(fe,"name","filename"),h(fe,"type","text"),h(fe,"placeholder","Filename"),h(he,"class","w3-third"),h(Ee,"class","w3-col w3-input w3-border"),h(ue,"class","w3-third"),h(ge,"class","w3-col w3-input w3-border"),h(me,"class","w3-rest"),h(de,"class","w3-row w3-section"),h(ye,"class","svelte-lxonyp"),h(Ce,"class","w3-text-yellow"),f(Ce,"text-shadow","1px 1px 0 #444"),h(xe,"class","w3-panel w3-blue"),h(Se,"class","w3-col w3-input w3-border"),h(Re,"class","svelte-lxonyp"),h(Ue,"class","svelte-lxonyp")},m(a,s){p(a,t,s),y(l,a,s),p(a,v,s),p(a,m,s),u(m,B),u(B,I),u(I,S),p(a,V,s),Ge&&Ge.m(a,s),p(a,N,s),p(a,R,s),p(a,F,s),p(a,U,s),u(U,H),u(H,A),u(A,G),p(a,P,s),p(a,J,s),u(J,q),u(q,z),u(z,Y),u(J,_),u(J,K),u(K,W),p(a,X,s),p(a,Z,s),p(a,ee,s),p(a,te,s),u(te,le),u(le,ae),p(a,se,s),p(a,ne,s),p(a,ce,s),je&&je.m(a,s),p(a,re,s),p(a,ie,s),p(a,oe,s),p(a,de,s),u(de,he),u(he,fe),u(de,pe),u(de,ue),u(ue,Ee),u(Ee,ve),u(de,we),u(de,me),u(me,ge),u(ge,Te),p(a,be,s),p(a,ye,s),p(a,De,s),p(a,xe,s),u(xe,Ce),u(Ce,Be),u(Be,Ie),p(a,ke,s),p(a,Se,s),u(Se,Ve),p(a,Ne,s),p(a,Re,s),p(a,Fe,s),Pe&&Pe.m(a,s),p(a,Oe,s),p(a,Ue,s),He=!0,Ae||(Le=[E(z,"click",M),E(le,"click",Q),E(Ee,"click",e[6]),E(ge,"click",e[7]),E(Se,"click",e[3])],Ae=!0)},p(e,[t]){e[1].length>0?Ge?Ge.p(e,t):(Ge=L(e),Ge.c(),Ge.m(N.parentNode,N)):Ge&&(Ge.d(1),Ge=null),e[2].length>0?je?je.p(e,t):(je=j(e),je.c(),je.m(re.parentNode,re)):je&&(je.d(1),je=null),e[0].length>0?Pe?Pe.p(e,t):(Pe=$(e),Pe.c(),Pe.m(Oe.parentNode,Oe)):Pe&&(Pe.d(1),Pe=null)},i(e){He||(D(l.$$.fragment,e),He=!0)},o(e){x(l.$$.fragment,e),He=!1},d(e){e&&o(t),C(l,e),e&&o(v),e&&o(m),e&&o(V),Ge&&Ge.d(e),e&&o(N),e&&o(R),e&&o(F),e&&o(U),e&&o(P),e&&o(J),e&&o(X),e&&o(Z),e&&o(ee),e&&o(te),e&&o(se),e&&o(ne),e&&o(ce),je&&je.d(e),e&&o(re),e&&o(ie),e&&o(oe),e&&o(de),e&&o(be),e&&o(ye),e&&o(De),e&&o(xe),e&&o(ke),e&&o(Se),e&&o(Ne),e&&o(Re),e&&o(Fe),Pe&&Pe.d(e),e&&o(Oe),e&&o(Ue),Ae=!1,w(Le)}}}function z(e,t){let l=document.createElement("a");document.body.appendChild(l),l.style="display: none";let a=window.URL.createObjectURL(e);l.href=a,l.download=t,l.click(),window.URL.revokeObjectURL(a)}function M(){let e=document.getElementById("editTable"),t=this.parentElement.nextElementSibling.firstElementChild.value,l=e.children[1].childNodes;for(let a=0;a<l.length;a++){l[a].style.display="none";let e=l[a].getElementsByTagName("td")[0];e&&e.innerText.toUpperCase().indexOf(t)>-1&&(l[a].style.display="")}}function Q(){let e=document.getElementById("editTable").children[1].childNodes;for(let t=0;t<e.length;t++)if("none"!=e[t].style.display){let l=e[t].getElementsByTagName("td")[1].firstElementChild.firstElementChild;l.checked=!l.checked}}function Y(e,t,l){let a=[],s=[],n=[];function c(){S("/datasets/all",(function(e){let t=JSON.parse(e.response);t.data&&(F.success("Found data."),l(0,a=t.data),console.log("gridfsData",a))}))}function r(){let e=document.getElementById("filenameCSV").value;if(""==e)return void F.danger("Please provide a filename with .csv ending");let t=e.split(".");if("csv"!=t[t.length-1])return void F.danger("File ending must be .csv");let l=document.getElementById("editTable"),a=[],s=[],n=l.querySelectorAll("thead th");for(let r=0;r<n.length;r++)s.push(n[r].innerText);a.push(s.join(";"));let c=l.querySelectorAll("tbody tr");for(let r=0;r<c.length;r++)if(s=[],"none"!=c[r].style.display){let e=c[r].getElementsByTagName("td");s.push(e[0].innerText.replace(";"," ")),e[1].firstElementChild.firstElementChild.checked?s.push("True"):s.push("False"),a.push(s.join(";"))}return[e,new Blob([a.join("\n")],{type:"text/csv"})]}return B((async()=>{c(),S("/capfile/all",(function(e){let t=JSON.parse(e.response);t.data&&(F.success("Found data."),l(1,s=t.data),console.log("capfileData",s))}))})),[a,s,n,c,function(){let e=this.parentElement.parentElement.parentElement.firstElementChild.innerText;V("/capfile/download","POST",{filepath:e},(function(e){z(new Blob([e.response],{type:"octet/stream"}),decodeURIComponent(e.getResponseHeader("Content-Disposition").split("filename=")[1].split(";")[0]))}))},function(){let e=this.parentElement.parentElement.parentElement.firstElementChild.innerText;N("/capfile/edit","POST",{filepath:e},(function(e){e.data&&(l(2,n=e.data),console.log("editData:",n),F.success("Loading data successfull."))}))},function(){let e=r(),t=e[0],l=e[1];R("/datasets/upload","POST",{filename:t,Files:l},(function(e){JSON.parse(e.response).data&&F.success("Upload worked, repload gridfs.")}))},function(){let e=r(),t=e[0];z(e[1],t)},function(){let e=this.parentElement.parentElement.parentElement.firstElementChild.innerText;N("/datasets/file","DELETE",{filename:e},(function(e){e.data&&F.success("Deletion successfull, reload Gridfs data.")}))},function(){let e=this.parentElement.parentElement.parentElement.firstElementChild.innerText;V("/datasets/download","POST",{filename:e},(function(e){z(new Blob([e.response],{type:"octet/stream"}),decodeURIComponent(e.getResponseHeader("Content-Disposition").split("filename=")[1].split(";")[0]))}))}]}export default class extends e{constructor(e){super(),t(this,e,Y,q,l,{})}}
  