text: (this.webpackJsonpclient=this.webpackJsonpclient||[]).push([[0],{34:function(e,t,a){e.exports=a(78)},39:function(e,t,a){},40:function(e,t,a){e.exports=a.p+"static/media/logo.5d5d9eef.svg"},41:function(e,t,a){},60:function(e,t,a){},77:function(e,t,a){},78:function(e,t,a){"use strict";a.r(t);var n=a(0),r=a.n(n),c=a(8),i=a.n(c),o=(a(39),a(40),a(41),a(4)),s=a.n(o),l=a(7),m=a(6),u=a(9),d=a(12),g=a(10),p=a(14),h=a(29),f=a.n(h),y=function(e){function t(){var e,a;Object(m.a)(this,t);for(var n=arguments.length,r=new Array(n),c=0;c<n;c++)r[c]=arguments[c];return(a=Object(d.a)(this,(e=Object(g.a)(t)).call.apply(e,[this].concat(r)))).setRef=function(e){a.webcam=e},a.screenshotImage=function(){return a.webcam.getScreenshot()},a}return Object(p.a)(t,e),Object(u.a)(t,[{key:"render",value:function(){return r.a.createElement("div",null,r.a.createElement(f.a,{audio:!1,style:{width:"100%"},ref:this.setRef,screenshotFormat:"image/jpeg"}))}}]),t}(r.a.Component),v=a(30),w=a.n(v),b=function e(){Object(m.a)(this,e),this.getStyledimage=function(){var e=Object(l.a)(s.a.mark((function e(t,a){return s.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new Promise(function(){var e=Object(l.a)(s.a.mark((function e(n,r){var c;return s.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:try{(c=new FormData).set("image",t),w.a.post("".concat("https://max-fast-neural-style-transfer.max.us-south.containers.appdomain.cloud/model/predict","?model=").concat(a),c,{responseType:"blob",headers:{"Content-Type":"multipart/form-data",accept:"application/json"}}).then((function(e){var t=new window.FileReader;t.readAsDataURL(e.data),t.onload=function(){var e=t.result;n(e)}}))}catch(i){console.log("Errorororo"),console.log(i),r(i)}case 1:case"end":return e.stop()}}),e)})));return function(t,a){return e.apply(this,arguments)}}()));case 1:case"end":return e.stop()}}),e)})));return function(t,a){return e.apply(this,arguments)}}()},E=(a(60),a(31)),I=a.n(E),S=a(33),j=a.n(S),x={gridStyle:{backgroundColor:"#282c34"},buttonStyle:{width:"100%"},cardStyle:{backgroundColor:"#282c34",height:"100%"},webcamStyle:{margin:"auto",display:"block"},previewStyle:{maxWidth:"70%",marginTop:"4px"}},k=function(e){function t(e){var a;return Object(m.a)(this,t),(a=Object(d.a)(this,Object(g.a)(t).call(this,e))).postGetStyledImage=function(){var e=Object(l.a)(s.a.mark((function e(t){var n,r,c,i;return s.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=t.target.id,e.next=3,a.webcam.current.screenshotImage();case 3:return r=e.sent,c=a.dataURLtoBlob(r),a.setState({isLoadingImage:!0,styleImg:r}),e.next=8,a.service.getStyledimage(c,n);case 8:i=e.sent,a.setState({styleImg:i,isLoadingImage:!1});case 10:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),a.dataURLtoBlob=function(e){for(var t=e.split(","),a=t[0].match(/:(.*?);/)[1],n=atob(t[1]),r=n.length,c=new Uint8Array(r);r--;)c[r]=n.charCodeAt(r);return new Blob([c],{type:a})},a.renderPreviewImages=function(){return r.a.createElement("div",{className:"imagePreviewContainer"},r.a.createElement("img",{id:"candy",className:"imagePreview",src:"/candy.jpg",onClick:a.postGetStyledImage}),r.a.createElement("img",{id:"mosaic",className:"imagePreview",src:"/mosaic.jpg",onClick:a.postGetStyledImage}),r.a.createElement("img",{id:"rain_princess",className:"imagePreview",src:"/rain-princess-cropped.jpg",onClick:a.postGetStyledImage}),r.a.createElement("img",{id:"udnie",className:"imagePreview",src:"/udnie.jpg",onClick:a.postGetStyledImage}))},a.webcam=r.a.createRef(),a.service=new b,a.state={styleImg:null,isLoadingImage:!1},a}return Object(p.a)(t,e),Object(u.a)(t,[{key:"render",value:function(){return r.a.createElement("div",null,r.a.createElement("div",{className:"bx--grid",style:x.gridStyle},r.a.createElement("div",{className:"bx--row"},r.a.createElement("div",{className:"bx--col-lg-7"},r.a.createElement("div",{style:x.cardStyle},r.a.createElement(y,{style:x.webcamStyle,ref:this.webcam}))),r.a.createElement("div",{className:"bx--col-lg-2",style:x.previewStyle},this.renderPreviewImages()),r.a.createElement("div",{className:"bx--col-lg-7"},r.a.createElement("div",{style:x.cardStyle},r.a.createElement(j.a,{active:this.state.isLoadingImage,spinner:r.a.createElement("div",null,r.a.createElement("br",null)," ",r.a.createElement(I.a,{loading:"true",color:"#0043ce"})),text:"Your image is being created"},this.state.styleImg?r.a.createElement("img",{alt:"",src:this.state.styleImg?this.state.styleImg:""}):""))))))}}]),t}(r.a.Component);a(77);var O=function(){return r.a.createElement("div",{className:"App"},r.a.createElement("br",null),r.a.createElement("div",{style:{height:"24%",color:"white",fontFamily:"IBM Plex Sans, Helvetica Neue, Arial, sans-serif"}},r.a.createElement("h1",null,"Fast style transfer"),r.a.createElement("p",null,"Click on one of the paintings to get a snapshot in that style")),r.a.createElement(k,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}$/));i.a.render(r.a.createElement(O,null),document.getElementById("root")),"serviceWorker"in navigator&&navigator.serviceWorker.ready.then((function(e){e.unregister()})).catch((function(e){console.error(e.message)}))}},[[34,1,2]]]);
  //# sourceMappingURL=main.8b9aa2b5.chunk.js.map