"use strict";(globalThis.webpackChunk_jbrowse_web=globalThis.webpackChunk_jbrowse_web||[]).push([[6095],{86095:(e,s,r)=>{r.r(s),r.d(s,{default:()=>R});var o=r(7552),t=r(67112),a=r(90542),n=r(99546),i=r(29772),l=r(69500);const c=(0,i.A)((0,l.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 h=r(72851),d=r(76218),u=r(31378),w=r(89870),j=r(61282),p=r(30698),x=r(69092),S=r(31409),b=r.n(S),C=r(68446),f=r(36422),g=r(430),k=r(17765),m=r(49409),y=r(93062);function A({url:e}){return(0,l.jsx)(y.A,{label:"URL",value:e,variant:"filled",fullWidth:!0,onClick:e=>{e.target.select()},slotProps:{input:{readOnly:!0}}})}const L=(0,o.lazy)((()=>r.e(2267).then(r.bind(r,82267)))),R=(0,C.observer)((function({handleClose:e,session:s}){const[r,i]=(0,o.useState)(""),[S,C]=(0,o.useState)(""),[y,R]=(0,o.useState)(""),[v,P]=(0,o.useState)(""),[U,I]=(0,o.useState)(!0),[B,D]=(0,o.useState)(),[J,M]=(0,o.useState)(!1),[,V]=(0,g.useQueryParam)("password",g.StringParam),[,$]=(0,g.useQueryParam)("session",g.StringParam),_=s.shareURL,z=(0,n.localStorageGetItem)("jbrowse-shareURL")||"short",W=(0,f.getSnapshot)(s);(0,o.useEffect)((()=>{(async()=>{if(!B)try{if("short"===z){I(!0);const e=new URL(window.location.href),s=await(0,k.J)(W,_,e.href),r=new URLSearchParams(e.search);r.set("session",`share-${s.json.sessionId}`),r.set("password",s.password),e.search=r.toString(),R(e.href),i(`share-${s.json.sessionId}`),C(s.password)}else{const e=await(0,m.eW)(JSON.stringify((0,f.getSnapshot)(s))),r=new URL(window.location.href),o=new URLSearchParams(r.search);o.set("session",`encoded-${e}`),i(`encoded-${e}`),r.search=o.toString(),P(r.toString())}}catch(e){console.error(e),D(e)}finally{I(!1)}})()}),[z,B,s,_,W]);const E="short"===z&&U||!!B;return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(t.Dialog,{maxWidth:"xl",open:!0,onClose:e,title:"JBrowse Shareable Link",children:[(0,l.jsxs)(d.A,{children:[(0,l.jsxs)(u.A,{children:["Copy the URL below to share your current JBrowse session.",(0,l.jsx)(w.A,{onClick:()=>{M(!0)},children:(0,l.jsx)(h.A,{})})]}),"short"===z?B?(0,l.jsx)(t.ErrorMessage,{error:B,onReset:()=>{D(void 0)}}):U?(0,l.jsx)(j.A,{children:"Generating short URL..."}):(0,l.jsx)(A,{url:y}):(0,l.jsx)(A,{url:v})]}),(0,l.jsxs)(p.A,{children:[(0,l.jsx)(x.A,{startIcon:(0,l.jsx)(c,{}),disabled:E,onClick:e=>{e.preventDefault(),V(S,"replaceIn"),$(r,"replaceIn"),alert("Now press Ctrl+D (PC) or Cmd+D (Mac)")},children:"Create browser Bookmark"}),(0,l.jsx)(x.A,{startIcon:(0,l.jsx)(a.PM,{}),disabled:E,onClick:()=>{b()(y||v),s.notify("Copied to clipboard","success")},children:"Copy to Clipboard"}),(0,l.jsx)(x.A,{onClick:e,autoFocus:!0,children:"Close"})]})]}),(0,l.jsx)(L,{open:J,currentSetting:z,onClose:()=>{M(!1)}})]})}))}}]);
//# sourceMappingURL=6095.e9ad0891.chunk.js.map