"use strict";(globalThis.webpackChunk_jbrowse_web=globalThis.webpackChunk_jbrowse_web||[]).push([[6095],{86095:(e,s,r)=>{r.r(s),r.d(s,{default:()=>U});var o=r(7552),t=r(67112),n=r(99546),a=r(29772),l=r(69500);const i=(0,a.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 c=r(8328),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),f=r(68446),C=r(36422),g=r(430),m=r(17765),k=r(49409),y=r(67758),A=r(93062);function L(e){const s=(0,y.c)(3),{url:r}=e;let o,t;return s[0]===Symbol.for("react.memo_cache_sentinel")?(o={input:{readOnly:!0}},s[0]=o):o=s[0],s[1]!==r?(t=(0,l.jsx)(A.A,{label:"URL",value:r,variant:"filled",fullWidth:!0,onClick:R,slotProps:o}),s[1]=r,s[2]=t):t=s[2],t}function R(e){e.target.select()}const v=(0,o.lazy)(()=>r.e(2267).then(r.bind(r,82267))),U=(0,f.observer)(function({handleClose:e,session:s}){const[r,a]=(0,o.useState)(""),[S,f]=(0,o.useState)(""),[y,A]=(0,o.useState)(""),[R,U]=(0,o.useState)(""),[P,I]=(0,o.useState)(!0),[_,B]=(0,o.useState)(),[D,J]=(0,o.useState)(!1),[,V]=(0,g.useQueryParam)("password",g.StringParam),[,$]=(0,g.useQueryParam)("session",g.StringParam),z=s.shareURL,M=(0,n.localStorageGetItem)("jbrowse-shareURL")||"short",W=(0,C.getSnapshot)(s);(0,o.useEffect)(()=>{(async()=>{if(!_)try{if("short"===M){I(!0);const e=new URL(window.location.href),s=await(0,m.J)(W,z,e.href),r=new URLSearchParams(e.search);r.set("session",`share-${s.json.sessionId}`),r.set("password",s.password),e.search=r.toString(),A(e.href),a(`share-${s.json.sessionId}`),f(s.password)}else{const e=await(0,k.eW)(JSON.stringify((0,C.getSnapshot)(s))),r=new URL(window.location.href),o=new URLSearchParams(r.search);o.set("session",`encoded-${e}`),a(`encoded-${e}`),r.search=o.toString(),U(r.toString())}}catch(e){console.error(e),B(e)}finally{I(!1)}})()},[M,_,s,z,W]);const E="short"===M&&P||!!_;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:()=>{J(!0)},children:(0,l.jsx)(h.A,{})})]}),"short"===M?_?(0,l.jsx)(t.ErrorMessage,{error:_,onReset:()=>{B(void 0)}}):P?(0,l.jsx)(j.A,{children:"Generating short URL..."}):(0,l.jsx)(L,{url:y}):(0,l.jsx)(L,{url:R})]}),(0,l.jsxs)(p.A,{children:[(0,l.jsx)(x.A,{startIcon:(0,l.jsx)(i,{}),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)(c.A,{}),disabled:E,onClick:()=>{b()(y||R),s.notify("Copied to clipboard","success")},children:"Copy to Clipboard"}),(0,l.jsx)(x.A,{onClick:e,autoFocus:!0,children:"Close"})]})]}),(0,l.jsx)(v,{open:D,currentSetting:M,onClose:()=>{J(!1)}})]})})}}]);
//# sourceMappingURL=6095.f99baf79.chunk.js.map