"use strict";(globalThis.webpackChunk_jbrowse_web=globalThis.webpackChunk_jbrowse_web||[]).push([[7663],{47663:(e,t,r)=>{r.r(t),r.d(t,{default:()=>R});var s=r(7552),a=r(36422),n=r(68446),o=r(49823),l=r(1343),c=r(29499),i=r(99123),h=r(61723),u=r(36715),d=r(58507),m=r(5401),w=r(31409),p=r.n(w),E=r(430),S=r(22168),b=r(90542),C=r(74893),g=r(69500);const f=(0,C.A)((0,g.jsx)("path",{d:"M21 7h-2v2h-2V7h-2V5h2V3h2v2h2zm-2 14-7-3-7 3V5c0-1.1.9-2 2-2h7c-.63.84-1 1.87-1 3 0 2.76 2.24 5 5 5 .34 0 .68-.03 1-.1z"}),"BookmarkAdd");var k=r(49409),y=r(17765);const A=(0,s.lazy)((()=>r.e(4741).then(r.bind(r,84741))));function L({url:e}){return s.createElement(l.A,{label:"URL",value:e,InputProps:{readOnly:!0},variant:"filled",fullWidth:!0,onClick:e=>{e.target.select()}})}const R=(0,n.observer)((function({handleClose:e,session:t}){const[r,n]=(0,s.useState)(""),[l,w]=(0,s.useState)(""),[C,g]=(0,s.useState)(""),[R,v]=(0,s.useState)(""),[P,U]=(0,s.useState)(!0),[I,j]=(0,s.useState)(),[B,D]=(0,s.useState)(!1),[,J]=(0,E.useQueryParam)("password",E.StringParam),[,M]=(0,E.useQueryParam)("session",E.StringParam),V=t.shareURL,$=localStorage.getItem("jbrowse-shareURL")||"short",_=(0,a.getSnapshot)(t);(0,s.useEffect)((()=>{(async()=>{if(!I)try{if("short"===$){U(!0);const e=new URL(window.location.href),t=await(0,y.J)(_,V,e.href),r=new URLSearchParams(e.search);r.set("session",`share-${t.json.sessionId}`),r.set("password",t.password),e.search=r.toString(),g(e.href),n(`share-${t.json.sessionId}`),w(t.password)}else{const e=await(0,k.eW)(JSON.stringify((0,a.getSnapshot)(t))),r=new URL(window.location.href),s=new URLSearchParams(r.search);s.set("session",`encoded-${e}`),n(`encoded-${e}`),r.search=s.toString(),v(r.toString())}}catch(e){j(e)}finally{U(!1)}})()}),[$,I,t,V,_]);const x="short"===$&&P||!!I;return s.createElement(s.Fragment,null,s.createElement(o.Dialog,{maxWidth:"xl",open:!0,onClose:e,title:"JBrowse Shareable Link"},s.createElement(c.A,null,s.createElement(i.A,null,"Copy the URL below to share your current JBrowse session.",s.createElement(h.A,{onClick:()=>{D(!0)}},s.createElement(S.A,null))),"short"===$?I?s.createElement(o.ErrorMessage,{error:I,onReset:()=>{j(void 0)}}):P?s.createElement(u.A,null,"Generating short URL..."):s.createElement(L,{url:C}):s.createElement(L,{url:R})),s.createElement(d.A,null,s.createElement(m.A,{startIcon:s.createElement(f,null),disabled:x,onClick:e=>{e.preventDefault(),J(l,"replaceIn"),M(r,"replaceIn"),alert("Now press Ctrl+D (PC) or Cmd+D (Mac)")}},"Create browser Bookmark"),s.createElement(m.A,{onClick:()=>{p()(C||R),t.notify("Copied to clipboard","success")},startIcon:s.createElement(b.PM,null),disabled:x},"Copy to Clipboard"),s.createElement(m.A,{onClick:e,autoFocus:!0},"Close"))),s.createElement(A,{open:B,onClose:()=>{D(!1)},currentSetting:$}))}))}}]);
//# sourceMappingURL=7663.e79b053a.chunk.js.map