(this.webpackJsonpclient=this.webpackJsonpclient||[]).push([[0],{108:function(e,t){var a="";t.getToken=function(){return a},t.setToken=function(e){a=e}},178:function(e,t){var a="",n="",r="";t.getUploadURL=function(){return a},t.setUploadURL=function(e){a=e},t.getFileName=function(){return n},t.setFileName=function(e){n=e},t.getType=function(){return r},t.setType=function(e){r=e}},185:function(e,t,a){e.exports=a(417)},190:function(e,t,a){},225:function(e,t){},227:function(e,t){},257:function(e,t){},258:function(e,t){},323:function(e,t){},416:function(e,t,a){},417:function(e,t,a){"use strict";a.r(t);var n=a(0),r=a.n(n),l=a(179),o=a.n(l),s=(a(190),a(36)),i=a(20),c=a(184),u=a(19),m=a.n(u),p=a(38),d=a(63),f=a.n(d),h=(a(197),a(198),new f.a.auth.GoogleAuthProvider,f.a.initializeApp({apiKey:"AIzaSyDracy4thbIQapk8BAV1AQqOjmyiEgHNuk",authDomain:"osmix-mastering-270321.firebaseapp.com",databaseURL:"https://osmix-mastering-270321.firebaseio.com",projectId:"osmix-mastering-270321",storageBucket:"osmix-mastering-270321.appspot.com",messagingSenderId:"807219358101",appId:"1:807219358101:web:021a72294dd451722f2e9c",measurementId:"G-G7GCV1F3MY"}),f.a.auth()),b=f.a.firestore(),g=function(){var e=Object(p.a)(m.a.mark((function e(t,a){var n,r,l,o;return m.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t){e.next=2;break}return e.abrupt("return");case 2:return n=b.doc("users/".concat(t.uid)),e.next=5,n.get();case 5:if(e.sent.exists){e.next=16;break}return r=t.email,l=t.displayName,o=t.photoURL,e.prev=8,e.next=11,n.set({displayName:l,email:r,photoURL:o});case 11:e.next=16;break;case 13:e.prev=13,e.t0=e.catch(8),console.errot("Error creating user document",e.t0);case 16:return e.abrupt("return",v(t.uid));case 17:case"end":return e.stop()}}),e,null,[[8,13]])})));return function(t,a){return e.apply(this,arguments)}}(),v=function(){var e=Object(p.a)(m.a.mark((function e(t){var a;return m.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t){e.next=2;break}return e.abrupt("return",null);case 2:return e.prev=2,e.next=5,b.doc("users/".concat(t)).get();case 5:return a=e.sent,e.abrupt("return",Object(c.a)({uid:t},a.data()));case 9:e.prev=9,e.t0=e.catch(2),console.error("Error fetching user",e.t0);case 12:case"end":return e.stop()}}),e,null,[[2,9]])})));return function(t){return e.apply(this,arguments)}}(),E=function(){var e=Object(n.useState)(""),t=Object(i.a)(e,2),a=t[0],l=t[1],o=Object(n.useState)(""),c=Object(i.a)(o,2),u=c[0],m=c[1],p=Object(n.useState)(null),d=Object(i.a)(p,2),f=d[0],b=d[1],g=function(e){var t=e.currentTarget,a=t.name,n=t.value;"userEmail"===a?l(n):"userPassword"===a&&m(n)};return r.a.createElement("div",null,r.a.createElement("img",{id:"image",className:"mb-4",src:"https://storage.googleapis.com/app_static/OSmix-Primary-Logo-Black.svg",alt:"",width:"150",height:"150"}),r.a.createElement("h1",{className:"h3 mb-3 font-weight-normal",id:"welcomeTxt"},"Please sign in"),r.a.createElement("div",null,null!==f&&r.a.createElement("div",null,f),r.a.createElement("form",{className:"form-signin"},r.a.createElement("input",{type:"email",className:"form-control",name:"userEmail",value:a,placeholder:"Email",id:"userEmail",onChange:function(e){return g(e)}}),r.a.createElement("input",{type:"password",className:"form-control",name:"userPassword",value:u,placeholder:"Your Password",id:"userPassword",onChange:function(e){return g(e)}}),r.a.createElement("button",{className:"btn btn-lg btn-primary btn-block",onClick:function(e){!function(e,t,a){e.preventDefault(),h.signInWithEmailAndPassword(t,a).catch((function(e){b("Error signing in with password and email!"),console.error("Error signing in with password and email!",e)}))}(e,a,u)}},"Sign in")),r.a.createElement("p",{className:"text-center my-3"},r.a.createElement(s.a,{to:"passwordReset",className:"text-blue-500 hover:text-blue-600"},"Forgot Password?"))),r.a.createElement("p",{className:"mt-5 mb-3 text-muted"},"\xa9 2020 | OSMix Music"))},w=a(181),y=function(){var e=Object(n.useState)(""),t=Object(i.a)(e,2),a=t[0],l=t[1],o=Object(n.useState)(""),c=Object(i.a)(o,2),u=c[0],d=c[1],f=Object(n.useState)(""),h=Object(i.a)(f,2),b=h[0],v=h[1],E=Object(n.useState)(null),y=Object(i.a)(E,2),x=y[0],O=y[1],N=function(){var e=Object(p.a)(m.a.mark((function e(t,a,n){var r,o;return m.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t.preventDefault(),e.prev=1,e.next=4,w.auth.createUserWithEmailAndPassword(a,n);case 4:r=e.sent,o=r.user,g(o,{displayName:b}),e.next=12;break;case 9:e.prev=9,e.t0=e.catch(1),O("Error signing up with email and password");case 12:l(""),d(""),v("");case 15:case"end":return e.stop()}}),e,null,[[1,9]])})));return function(t,a,n){return e.apply(this,arguments)}}(),j=function(e){var t=e.currentTarget,a=t.name,n=t.value;"userEmail"===a?l(n):"userPassword"===a?d(n):"displayName"===a&&v(n)};return r.a.createElement("div",{className:"mt-8"},r.a.createElement("h1",{className:"text-3xl mb-2 text-center font-bold"},"Sign Up"),r.a.createElement("div",{className:"border border-blue-400 mx-auto w-11/12 md:w-2/4 rounded py-8 px-4 md:px-8"},null!==x&&r.a.createElement("div",{className:"py-4 bg-red-600 w-full text-white text-center mb-3"},x),r.a.createElement("form",{className:""},r.a.createElement("label",{htmlFor:"displayName",className:"block"},"Display Name:"),r.a.createElement("input",{type:"text",className:"my-1 p-1 w-full ",name:"displayName",value:b,placeholder:"E.g: Faruq",id:"displayName",onChange:function(e){return j(e)}}),r.a.createElement("label",{htmlFor:"userEmail",className:"block"},"Email:"),r.a.createElement("input",{type:"email",className:"my-1 p-1 w-full",name:"userEmail",value:a,placeholder:"E.g: faruq123@gmail.com",id:"userEmail",onChange:function(e){return j(e)}}),r.a.createElement("label",{htmlFor:"userPassword",className:"block"},"Password:"),r.a.createElement("input",{type:"password",className:"mt-1 mb-3 p-1 w-full",name:"userPassword",value:u,placeholder:"Your Password",id:"userPassword",onChange:function(e){return j(e)}}),r.a.createElement("button",{className:"bg-green-400 hover:bg-green-500 w-full py-2 text-white",onClick:function(e){N(e,a,u)}},"Sign up")),r.a.createElement("p",{className:"text-center my-3"},"or"),r.a.createElement("button",{className:"bg-red-500 hover:bg-red-600 w-full py-2 text-white"},"Sign In with Google"),r.a.createElement("p",{className:"text-center my-3"},"Already have an account?"," ",r.a.createElement(s.a,{to:"/",className:"text-blue-500 hover:text-blue-600"},"Sign in here"))))},x=a(33),O=a(34),N=a(35),j=a(37),k=Object(n.createContext)({user:null}),S=function(e){Object(j.a)(a,e);var t=Object(N.a)(a);function a(){var e;Object(x.a)(this,a);for(var n=arguments.length,r=new Array(n),l=0;l=200&&a.status<300?n(a.responseText):r("oh no")},a.send(t)}}},{key:"render",value:function(){var e=this;return r.a.createElement("div",{className:"UploadSong"},r.a.createElement(P.FilePond,{name:"songPond",ref:function(t){return e.pond=t},files:this.state.files,acceptedFileTypes:"audio/wav",allowFileEncode:!0,fileValidateTypeDetectType:function(e,t){return new Promise((function(e,a){e(t)}))},allowMultiple:!0,maxFiles:5,instantUpload:!1,server:{process:this.uploadFile.bind(this)},oninit:function(){return e.handleInit()},onupdatefiles:function(t){e.setState({files:t.map((function(e){return e.file}))})}}))}}]),a}(n.Component),M=a(78),D=a(108),z=a(178),B=function(e){Object(j.a)(a,e);var t=Object(N.a)(a);function a(e){var n;return Object(x.a)(this,a),(n=t.call(this,e)).state={files:[],uploadValue:0,filesMetadata:[],rows:[],messag:""},n}return Object(O.a)(a,[{key:"handleInit",value:function(){console.log("FilePond instance for uploading stems has been initialised",this.pond)}},{key:"uploadFile",value:function(e,t,a,n,r,l,o){z.setFileName(t.name),z.setType("stem"),console.log("Upload started for: "+t.name);var s=t.size;console.log("Size: "+s);this.pond.getFile();!function(e){M(e,(function(e,t,a){if(e)throw new Error(e);var n=JSON.parse(t.body);z.setUploadURL(n.data),i()}))}({method:"POST",url:"https://osmix-api-service-mdxh2upvfa-uc.a.run.app/v1/upload-url",headers:{"Content-Type":"application/json",Authorization:"Bearer "+D.getToken()},body:JSON.stringify({filename:z.getFileName(),type:z.getType()})});var i=function(){(new FormData).append(e,t,t.name);var a=new XMLHttpRequest;a.addEventListener("readystatechange",(function(){this.readyState})),a.open("PUT",z.getUploadURL(),!0),a.setRequestHeader("Content-Type","audio/basic"),a.upload.onprogress=function(e){l(e.lengthComputable,e.loaded,e.total)},a.onload=function(){a.status>=200&&a.status<300?n(a.responseText):r("oh no")},a.send(t)}}},{key:"render",value:function(){var e=this;return r.a.createElement("div",{className:"UploadStem"},r.a.createElement(P.FilePond,{name:"stemPond",ref:function(t){return e.pond=t},files:this.state.files,acceptedFileTypes:"audio/wav",allowFileEncode:!0,fileValidateTypeDetectType:function(e,t){return new Promise((function(e,a){e(t)}))},allowMultiple:!0,maxFiles:5,instantUpload:!1,server:{process:this.uploadFile.bind(this)},oninit:function(){return e.handleInit()},onupdatefiles:function(t){e.setState({files:t.map((function(e){return e.file}))})}}))}}]),a}(n.Component),J=a(78),q=a(108);h.onAuthStateChanged((function(e){if(e){var t={method:"POST",url:"https://osmix-api-service-mdxh2upvfa-uc.a.run.app/osmixadmin/login",headers:{"Content-Type":"application/json",Authorization:"Bearer YouCantS33ME"},body:JSON.stringify({email:h.currentUser.email,password:"DuckDuckG00S3!"})};J(t,(function(e,t){if(e)throw new Error(e);var a=JSON.parse(t.body);q.setToken(a.data.token)}))}}));var V=function(e){Object(j.a)(a,e);var t=Object(N.a)(a);function a(e){var n;return Object(x.a)(this,a),(n=t.call(this,e)).state={files:[],uploadValue:0,filesMetadata:[],rows:[],message:""},n}return Object(O.a)(a,[{key:"handleInit",value:function(){console.log("FilePond instance has initialised",this.pond)}},{key:"render",value:function(){return r.a.createElement("div",null,r.a.createElement("img",{id:"image",className:"mb-4",src:"https://storage.googleapis.com/app_static/UPM_Black.svg",alt:"",width:"300",height:"150"}),r.a.createElement("div",{className:"user"},r.a.createElement("span",{style:{padding:"1rem"}},"Hello, ",h.currentUser.email)),r.a.createElement("br",null),r.a.createElement("br",null),r.a.createElement("div",null,r.a.createElement("label",null,"Upload your song file(s): "),r.a.createElement(L,null)),r.a.createElement("div",null,r.a.createElement("label",null,"Upload your stem file(s): "),r.a.createElement(B,null)),r.a.createElement("br",null),r.a.createElement("button",{className:"btn btn-lg btn-secondary btn-block",onClick:function(){h.signOut()}},"Sign out"))}}]),a}(n.Component),G=function(){var e=Object(n.useState)(""),t=Object(i.a)(e,2),a=t[0],l=t[1],o=Object(n.useState)(!1),c=Object(i.a)(o,2),u=c[0],m=c[1],p=Object(n.useState)(null),d=Object(i.a)(p,2),f=d[0],b=d[1];return r.a.createElement("div",{className:"mt-8"},r.a.createElement("h1",{className:"text-xl text-center font-bold mb-3"},"Reset your Password"),r.a.createElement("div",null,r.a.createElement("form",{action:""},u&&r.a.createElement("div",{className:"py-3 bg-green-400 w-full text-white text-center mb-3"},"An email has been sent to you!"),null!==f&&r.a.createElement("div",{className:"py-3 bg-red-600 w-full text-black text-center mb-3"},f),r.a.createElement("input",{type:"email",name:"userEmail",id:"userEmail",value:a,placeholder:"Email address",onChange:function(e){var t=e.currentTarget,a=t.name,n=t.value;"userEmail"===a&&l(n)},className:"mb-3"}),r.a.createElement("br",null)," ",r.a.createElement("br",null)," ",r.a.createElement("button",{class:"btn btn-lg btn-danger btn-block",onClick:function(e){!function(e){e.preventDefault(),h.sendPasswordResetEmail(a).then((function(){m(!0),setTimeout((function(){m(!1)}),3e3)})).catch((function(){b("Error resetting password")}))}(e)}},"Send me a reset link")),r.a.createElement("br",null),r.a.createElement(s.a,{to:"/",class:"btn btn-lg btn-primary btn-block"},"\u2190 back to sign in page")))};var H=function(){return Object(n.useContext)(k)?r.a.createElement(V,null):r.a.createElement(s.b,null,r.a.createElement(y,{path:"signUp"}),r.a.createElement(E,{path:"/"}),r.a.createElement(G,{path:"passwordReset"}))};a(416);var W=function(){return r.a.createElement(S,null,r.a.createElement(H,null))};Boolean("localhost"===window.location.hostname||"[::1]"===window.location.hostname||window.location.hostname.match(/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/));o.a.render(r.a.createElement(r.a.StrictMode,null,r.a.createElement(W,null)),document.getElementById("root")),"serviceWorker"in navigator&&navigator.serviceWorker.ready.then((function(e){e.unregister()})).catch((function(e){console.error(e.message)}))}},[[185,1,2]]]); //# sourceMappingURL=main.61d213e4.chunk.js.map