import{a as p,R as e,P as f,d as g,B as d,u as r,m as y,H as E}from"./index-Bm2SqMk3.js";const w=y()(t=>({paper:{margin:t.spacing(),padding:t.spacing()},submit:{marginTop:25,marginBottom:100,display:"block"}}));function k(t){const{webUtils:n}=window.require("electron");return r.isElectron?{localPath:n.getPathForFile(t),locationType:"LocalPathLocation"}:E.storeBlobLocation({blob:t})}function W({model:t}){const{classes:n}=w(),[s,m]=p.useState(""),[c,b]=p.useState(`MultiWiggle${+Date.now()}`);return e.createElement(f,{className:n.paper},e.createElement("ul",null,e.createElement("li",null,"Enter list of URLs for bigwig files in the textbox"),e.createElement("li",null,"Or, use the button below the text box to select files from your computer")),e.createElement(g,{multiline:!0,fullWidth:!0,rows:10,value:s,placeholder:"Paste list of URLs here, or use file selector below",variant:"outlined",onChange:a=>{m(a.target.value)}}),e.createElement(d,{variant:"outlined",component:"label"},"Choose Files from your computer",e.createElement("input",{type:"file",hidden:!0,multiple:!0,onChange:({target:a})=>{const i=[...a.files||[]].map(l=>({type:"BigWigAdapter",bigWigLocation:k(l),source:l.name}));m(JSON.stringify(i,null,2))}})),e.createElement(g,{value:c,helperText:"Track name",onChange:a=>{b(a.target.value)}}),e.createElement(d,{variant:"contained",className:n.submit,onClick:()=>{var a;const i=r.getSession(t);try{const l=[`${c.toLowerCase().replaceAll(" ","_")}-${Date.now()}`,i.adminMode?"":"-sessionTrack"].join("");let o;try{o=JSON.parse(s)}catch{o=s.split(/\n|\r\n|\r/).map(u=>u.trim()).filter(u=>!!u)}const h=typeof o[0]=="string"?{bigWigs:o}:{subadapters:o};r.isSessionWithAddTracks(i)&&(i.addTrackConf({trackId:l,type:"MultiQuantitativeTrack",name:c,assemblyNames:[t.assembly],adapter:{type:"MultiWiggleAdapter",...h}}),(a=t.view)===null||a===void 0||a.showTrack(l)),t.clearData(),r.isSessionModelWithWidgets(i)&&i.hideWidget(t)}catch(l){console.error(l),i.notifyError(`${l}`,l)}}},"Submit"),e.createElement("p",null,"Additional notes: "),e.createElement("ul",null,e.createElement("li",null,"The list of bigwig files in the text box can be a list of URLs, or a list of elements like"," ",e.createElement("code",null,'[{"type":"BigWigAdapter","bigWigLocation":{"uri":"http://host/file.bw"}, "color":"green","source":"name for subtrack"}]')," ","to apply e.g. the color attribute to the view"),e.createElement("li",null,'Adding local files will update the textbox with JSON contents that are ready to submit with the "Submit" button')))}export{W as default};
