"use strict";(globalThis.webpackChunk_jbrowse_web=globalThis.webpackChunk_jbrowse_web||[]).push([[419],{20419:(e,s,o)=>{o.r(s),o.d(s,{default:()=>j});var r=o(7552),t=o(67112),a=o(90542),n=o(99546),i=o(76218),l=o(28194),c=o(31378),d=o(61282),h=o(93062),w=o(30698),p=o(69092),m=o(31409),f=o.n(m),k=o(68446),u=o(36422),b=o(75785),y=o(32984),g=o(69500);const x=(0,b.n9)()((()=>({flexItem:{margin:5},content:{display:"flex",flexFlow:"column",gap:"5px"}}))),j=(0,k.observer)((function({onClose:e,model:s}){const{classes:o}=x(),[m,k]=(0,r.useState)(""),[b,j]=(0,r.useState)(),[S,C]=(0,r.useState)(!0),U=(0,n.getSession)(s),{selectedBookmarks:A}=s,R=0===A.length,L=0===A.length?s.allBookmarksModel:s.sharedBookmarksModel;return(0,r.useEffect)((()=>{(async()=>{try{if(!(0,n.isSessionWithShareURL)(U))throw new Error("No shareURL configured");C(!0);const e=(0,u.getSnapshot)(L),s=new URL(window.location.href),o=await(0,y.J)(e,U.shareURL,s.href),r=new URLSearchParams(s.search);r.set("bookmarks",`share-${o.json.sessionId}`),r.set("password",o.password),s.search=r.toString(),k(s.href),C(!1)}catch(e){j(e)}finally{C(!1)}})()}),[L,U]),(0,g.jsxs)(t.Dialog,{open:!0,onClose:e,title:"Share bookmarks",children:[(0,g.jsxs)(i.A,{className:o.content,children:[(0,g.jsx)(l.A,{severity:"info",children:R?(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)("span",{children:"All bookmarks will be shared."}),(0,g.jsx)("br",{}),(0,g.jsx)("span",{children:"Use the checkboxes to select individual bookmarks to share."})]}):"Only selected bookmarks will be shared."}),(0,g.jsx)(c.A,{children:"Copy the URL below to share your bookmarks."}),b?(0,g.jsx)(t.ErrorMessage,{error:b}):S?(0,g.jsx)(d.A,{children:"Generating short URL..."}):(0,g.jsx)(h.A,{label:"URL",value:m,slotProps:{input:{readOnly:!0}},variant:"filled",fullWidth:!0,onClick:e=>{e.target.select()}}),(0,g.jsx)(c.A,{children:'The URL should be pasted into the "Import from share link" field in the "Import" form found in the "Bookmarked regions" drawer.'})]}),(0,g.jsx)(w.A,{children:(0,g.jsx)(p.A,{className:o.flexItem,"data-testid":"dialogShare",variant:"contained",color:"primary",disabled:S,startIcon:(0,g.jsx)(a.PM,{}),onClick:async()=>{f()(m),U.notify("Copied to clipboard","success"),e()},children:"Copy share link"})})]})}))},32984:(e,s,o)=>{o.d(s,{J:()=>i,Z:()=>l});var r=o(84495);const t=async(e,s)=>(await Promise.all([o.e(7753),o.e(9831),o.e(5156)]).then(o.t.bind(o,29831,23))).encrypt(e,s).toString(),a=async(e,s)=>{const r=await Promise.all([o.e(7753),o.e(9831),o.e(5156)]).then(o.t.bind(o,29831,23)),t=await Promise.all([o.e(7753),o.e(6235)]).then(o.t.bind(o,12598,23));return r.decrypt(e,s).toString(t)};function n(e){try{return JSON.parse(e).message}catch(s){return e}}async function i(e,s,o){const a=await(0,r.eW)(JSON.stringify(e)),i=window.btoa([...window.crypto.getRandomValues(new Uint8Array(10))].map((e=>String.fromCharCode(e))).join("")).replaceAll(/[+/]/g,"").slice(0,5);const l=await t(a,i),c=new FormData;c.append("session",l),c.append("dateShared",`${Date.now()}`),c.append("referer",o);const d=await fetch(`${s}share`,{method:"POST",mode:"cors",body:c});if(!d.ok){const e=await d.text();throw new Error(n(e))}return{json:await d.json(),encryptedSession:l,password:i}}async function l(e,s,o){const r=s.split("share-")[1],t=`${e}?sessionId=${encodeURIComponent(r)}`,i=await fetch(t);if(!i.ok)throw new Error(n(await i.text()));const l=await i.json();return a(l.session,o)}}}]);
//# sourceMappingURL=419.2dd24d51.chunk.js.map