"use strict";(self.webpackChunk_jbrowse_web=self.webpackChunk_jbrowse_web||[]).push([[9915],{79915:function(e,r,t){t.r(r);var n=t(33028),o=t(34795),a=t(96234),i=t(77162),s=t.n(i),c=t(30969),l=t(81073),p=t(33528),d=t(97891),u=t(22714),g=t(51526),h=t(80975),x=t(28599),b=t(53239),f=t(90550),m=t(98344),v=t(18169),j=t(43418),y=t(37574),Z=512*Math.pow(1024,2);function w(e,r){return function(t){return r[t[e]]}}var F=(0,u.Z)((function(e){return{root:{margin:e.spacing(1)},paper:{display:"flex",flexDirection:"column"},dropZone:{textAlign:"center",margin:e.spacing(2),padding:e.spacing(2),borderWidth:2,borderRadius:2,borderColor:w("isDragActive",{true:e.palette.secondary.light,false:e.palette.divider}),borderStyle:"dashed",backgroundColor:w("isDragActive",{true:(0,b.Fq)(e.palette.text.primary,e.palette.action.hoverOpacity),false:e.palette.background.default}),outline:"none",transition:"border .24s ease-in-out","&:focus":{borderColor:e.palette.secondary.light}},uploadIcon:{color:e.palette.text.secondary},rejectedFiles:{marginTop:e.spacing(4)},listItem:{padding:e.spacing(0,4)},expandIcon:{color:"#FFFFFF"},error:{margin:e.spacing(2)},errorHeader:{background:e.palette.error.light,color:e.palette.error.contrastText,padding:e.spacing(2),textAlign:"center"},errorMessage:{padding:e.spacing(2)}}}));r.default=(0,f.observer)((function(e){var r=(0,c.useState)(""),t=(0,a.Z)(r,2),i=t[0],u=t[1],b=e.model,f=(0,m.u)({accept:"application/json",maxSize:Z,multiple:!1,onDrop:function(){var e=(0,o.Z)(s().mark((function e(r,t){var n,o,i,c,g,h;return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!t.length){e.next=3;break}return r.length||t.length>1?u("Only one session at a time may be imported"):t[0].size>Z?u("File size is too large (".concat(Math.round(t[0].size/Math.pow(1024,2))," MiB), max size is ").concat(Z/Math.pow(1024,2)," MiB")):"application/json"!==t[0].type?u("File does not appear to be JSON"):u("Unknown file import error"),e.abrupt("return");case 3:return n=(0,a.Z)(r,1),o=n[0],i=(0,p.openLocation)((0,d.storeBlobLocation)({blob:o})),e.prev=5,e.next=8,i.readFile("utf8");case 8:c=e.sent,e.next=16;break;case 11:return e.prev=11,e.t0=e.catch(5),console.error(e.t0),u("Problem opening file ".concat(o.path,": ").concat(e.t0)),e.abrupt("return");case 16:try{g=JSON.parse(c).session}catch(s){console.error(s),g={error:"Error parsing ".concat(o.path,": ").concat(s)}}h=(0,l.getSession)(b);try{h.setSession(g)}catch(s){console.error(s),u("Error activating session: ".concat(s," "))}case 19:case"end":return e.stop()}}),e,null,[[5,11]])})));return function(r,t){return e.apply(this,arguments)}}()}),w=f.getRootProps,k=f.getInputProps,S=f.isDragActive,N=F({isDragActive:S});return(0,y.jsxs)("div",{className:N.root,children:[(0,y.jsx)(g.Z,{className:N.paper,children:(0,y.jsxs)("div",(0,n.Z)((0,n.Z)({},w({className:N.dropZone})),{},{children:[(0,y.jsx)("input",(0,n.Z)({},k())),(0,y.jsx)(v.Z,{className:N.uploadIcon,fontSize:"large"}),(0,y.jsx)(h.Z,{color:"textSecondary",align:"center",variant:"body1",children:"Drag and drop files here"}),(0,y.jsx)(h.Z,{color:"textSecondary",align:"center",variant:"body2",children:"or"}),(0,y.jsx)(x.Z,{color:"primary",variant:"contained",children:"Browse Files"})]}))}),i?(0,y.jsxs)(g.Z,{className:N.error,children:[(0,y.jsxs)("div",{className:N.errorHeader,children:[(0,y.jsx)(j.Z,{color:"inherit",fontSize:"large"}),(0,y.jsx)("div",{children:(0,y.jsx)(h.Z,{variant:"h6",color:"inherit",align:"center",children:"Import error"})})]}),(0,y.jsx)(h.Z,{className:N.errorMessage,children:i})]}):null]})}))}}]);
//# sourceMappingURL=9915.6578566b.chunk.js.map