import{u as h,a as s,R as e,c as p,D as z,M as r,i as w,C as D,T as b,e as F,B as y,k as N,d as R}from"./index-Bm2SqMk3.js";function M(){return e.createElement("div",null,e.createElement(N,{size:20,style:{marginRight:20}}),e.createElement(b,{display:"inline"},"Creating SVG"))}function o(n,a){return h.useLocalStorage(`svg-${n}`,a)}function c({children:n,...a}){return e.createElement("div",null,e.createElement(R,{...a},n))}function G({model:n,handleClose:a}){const l=h.getSession(n),i=typeof OffscreenCanvas<"u",[u,C]=s.useState(i),[S,m]=s.useState(!1),[g,f]=s.useState(),[E,k]=o("file","jbrowse.svg"),[v,x]=o("tracklabels","offset"),[d,T]=o("theme",l.themeName||"default");return e.createElement(p.Dialog,{open:!0,onClose:a,title:"Export SVG"},e.createElement(z,null,g?e.createElement(p.ErrorMessage,{error:g}):S?e.createElement(M,null):null,e.createElement(c,{helperText:"filename",value:E,onChange:t=>{k(t.target.value)}}),e.createElement(c,{select:!0,label:"Track label positioning",variant:"outlined",style:{width:150},value:v,onChange:t=>{x(t.target.value)}},e.createElement(r,{value:"offset"},"Offset"),e.createElement(r,{value:"overlay"},"Overlay"),e.createElement(r,{value:"left"},"Left"),e.createElement(r,{value:"none"},"None")),l.allThemes?e.createElement(c,{select:!0,label:"Theme",variant:"outlined",value:d,onChange:t=>{T(t.target.value)}},Object.entries(l.allThemes()).map(([t,L])=>e.createElement(r,{key:t,value:t},L.name||"(Unknown name)"))):null,i?e.createElement(w,{control:e.createElement(D,{checked:u,onChange:()=>{C(t=>!t)}}),label:"Rasterize canvas based tracks? File may be much larger if this is turned off"}):e.createElement(b,null,"Note: rasterizing layers not yet supported in this browser, so SVG size may be large")),e.createElement(F,null,e.createElement(y,{variant:"contained",color:"secondary",onClick:()=>{a()}},"Cancel"),e.createElement(y,{variant:"contained",color:"primary",type:"submit",onClick:async()=>{m(!0),f(void 0);try{await n.exportSvg({rasterizeLayers:u,filename:E,trackLabels:v,themeName:d}),a()}catch(t){console.error(t),f(t)}finally{m(!1)}}},"Submit")))}export{G as default};
