import{C as _,z as R,n as q,V as F,A as P,W as O,E as N,f as D,y as M,X as T,Y as $,Z as z,g as j,r as x,F as A,j as t,N as p,$ as V}from"./index-G4l7qcMm.js";import{c as B,i as L,S as f,F as W}from"./Stack-Cwu0vGSf.js";import{d as G,o as H,b as U,B as C}from"./browse-Ypk-yEjt.js";import{u as J}from"./Input-BJwdycW3.js";import{I as X,S as Y,M as Z,b as m,P as K,T as Q}from"./Tooltip-DDkR3tcv.js";function ee(e,o){return()=>null}function te(e,o){return()=>null}function ne(e,o,a,s,r){return null}const re={configure:e=>{_.configure(e)}},oe=Object.freeze(Object.defineProperty({__proto__:null,capitalize:R,createChainedFunction:B,createSvgIcon:q,debounce:G,deprecatedPropType:ee,isMuiElement:L,ownerDocument:H,ownerWindow:U,requirePropFactory:te,setRef:F,unstable_ClassNameGenerator:re,unstable_useEnhancedEffect:P,unstable_useId:O,unsupportedProp:ne,useControlled:J,useEventCallback:N,useForkRef:D,useIsFocusVisible:M},Symbol.toStringTag,{value:"Module"}));var d={},h={};const ae=T(oe);var v;function ie(){return v||(v=1,(function(e){"use client";Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return o.createSvgIcon}});var o=ae})(h)),h}var b;function le(){if(b)return d;b=1;var e=$();Object.defineProperty(d,"__esModule",{value:!0}),d.default=void 0;var o=e(ie()),a=z();return d.default=(0,o.default)((0,a.jsx)("path",{d:"M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2m0 16H8V7h11z"}),"ContentCopy"),d}var se=le();const ce=j(se);/*! clipboard-copy. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */var y,g;function ue(){if(g)return y;g=1,y=s;function e(){return new DOMException("The request is not allowed","NotAllowedError")}async function o(r){if(!navigator.clipboard)throw e();return navigator.clipboard.writeText(r)}async function a(r){const n=document.createElement("span");n.textContent=r,n.style.whiteSpace="pre",n.style.webkitUserSelect="auto",n.style.userSelect="all",document.body.appendChild(n);const i=window.getSelection(),c=window.document.createRange();i.removeAllRanges(),c.selectNode(n),i.addRange(c);let u=!1;try{u=window.document.execCommand("copy")}finally{i.removeAllRanges(),window.document.body.removeChild(n)}if(!u)throw e()}async function s(r){try{await o(r)}catch(n){try{await a(r)}catch(i){throw i||n||e()}}}return y}var de=ue();const me=j(de),Ce=e=>{const a=x.useContext(A).structure_families[e.structureFamily].formats,[s,r]=x.useState(null),n=l=>{r(l.currentTarget)},i=()=>{r(null)},c=!!s,u=c?"link-popover":void 0,w=l=>{const E=l.target.value,I=a.find(S=>S.mimetype===E);e.setFormat(I)},k=e.format!==void 0?e.format.mimetype:"";return t.jsxs(f,{spacing:2,direction:"column",children:[t.jsx(C,{sx:{minWidth:120},children:t.jsxs(W,{fullWidth:!0,children:[t.jsx(X,{id:"formats-select-label",children:"Format *"}),t.jsx(Y,{labelId:"formats-select-label",id:"formats-select",value:k,label:"Format",onChange:w,required:!0,children:a.map(l=>t.jsx(Z,{value:l.mimetype,children:l.display_name},`format-${l.mimetype}`))})]})}),t.jsxs(f,{spacing:1,direction:"row",children:[t.jsx(m,{title:"Download to a file",children:t.jsx("span",{children:t.jsx(p,{component:"a",href:e.link?`${e.link}&filename=${e.name}${e.format.extension}`:"#",variant:"outlined",...e.link?{}:{disabled:!0},children:"Download"})})}),t.jsx(m,{title:"Get a URL to this specific data",children:t.jsx("span",{children:t.jsx(p,{"aria-describedby":u,variant:"outlined",...e.link?{}:{disabled:!0},onClick:n,children:"Link"})})}),t.jsx(K,{id:u,open:c,anchorEl:s,onClose:i,anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},PaperProps:{style:{width:500}},children:t.jsxs(C,{sx:{px:2,py:2},children:[t.jsx(f,{direction:"row",spacing:1}),t.jsx(Q,{id:"link-text",label:"Link",sx:{width:"90%"},defaultValue:e.link,InputProps:{readOnly:!0},variant:"outlined"}),t.jsx(m,{title:"Copy to clipboard",children:t.jsx(V,{onClick:()=>{me(e.link)},children:t.jsx(ce,{})})})]})}),t.jsx(m,{title:"Open in a new tab (if format is supported by web browser)",children:t.jsx("span",{children:t.jsx(p,{component:"a",href:e.link?e.link:"#",target:"_blank",variant:"outlined",...e.link?{}:{disabled:!0},children:"Open"})})})]})]})};export{Ce as D};
