import{Y as S,ai as w,r as i,x as k,R as C,O as f,n as L,G as Q}from"./index.72e24882.js";import{B as g,c as $}from"./browse.0916686d.js";import{G as x,S as p,r as D}from"./index.esm.31c0e330.js";import{h as M}from"./Input.ed778d26.js";function B(e,a,t,l,n){const[s,m]=i.exports.useState(()=>n&&t?t(e).matches:l?l(e).matches:a);return k(()=>{let u=!0;if(!t)return;const r=t(e),c=()=>{u&&m(r.matches)};return c(),r.addListener(c),()=>{u=!1,r.removeListener(c)}},[e,t]),s}const y=C["useSyncExternalStore"];function I(e,a,t,l,n){const s=i.exports.useCallback(()=>a,[a]),m=i.exports.useMemo(()=>{if(n&&t)return()=>t(e).matches;if(l!==null){const{matches:o}=l(e);return()=>o}return s},[s,e,l,n,t]),[u,r]=i.exports.useMemo(()=>{if(t===null)return[s,()=>()=>{}];const o=t(e);return[()=>o.matches,d=>(o.addListener(d),()=>{o.removeListener(d)})]},[s,t,e]);return y(r,u,m)}function b(e,a={}){const t=S(),l=typeof window<"u"&&typeof window.matchMedia<"u",{defaultMatches:n=!1,matchMedia:s=l?window.matchMedia:null,ssrMatchMedia:m=null,noSsr:u=!1}=w({name:"MuiUseMediaQuery",props:a,theme:t});let r=typeof e=="function"?e(t):e;return r=r.replace(/^@media( ?)/m,""),(y!==void 0?I:B)(r,n,s,m,u)}const T=e=>{const a=(s,m)=>{e.setValue(m)},t=s=>{e.setValue(s.target.value===""?e.value:Number(s.target.value))},l=()=>{e.value<e.min?e.setValue(e.min):e.value>e.max&&e.setValue(e.max)},n=[{value:e.min,label:e.min},{value:e.max,label:e.max}];return f.createElement(g,null,f.createElement(x,{container:!0,spacing:2,alignItems:"center"},f.createElement(x,{item:!0,xs:!0},f.createElement(p,{getAriaLabel:()=>"Array slice range",value:e.value,min:e.min,max:e.max,marks:n,onChange:a,valueLabelDisplay:"auto"})),f.createElement(x,{item:!0},f.createElement(M,{value:e.value,size:"small",onChange:t,onBlur:l,inputProps:{step:1,min:e.min,max:e.max,type:"number","aria-labelledby":"min-input-slider"}}))))},U=e=>{const a=e.structure.shape,t=a.length,l=a.slice(0,t-2).map(d=>Math.floor(d/2)),n=$(),s=b(n.breakpoints.down("sm")),m=b(n.breakpoints.down("md"));var u;s?u=n.breakpoints.values.sm:m?u=n.breakpoints.values.md:u=n.breakpoints.values.lg;const r=Math.ceil(Math.max(...a.slice(t-2,t))/u),[c,o]=i.exports.useState(l);return i.exports.createElement(g,null,i.exports.createElement(V,{link:e.link,cuts:c,stride:r}),a.length>2?i.exports.createElement(L,{id:"input-slider",gutterBottom:!0},"Choose a planar cut through this ",a.length,"-dimensional array."):"",r!==1?i.exports.createElement(Q,{severity:"info"},"This large array has been downsampled by a factor of ",r,".",i.exports.createElement("br",null),'Use the "Download" tab to access a full-resolution image.'):"",a.slice(0,t-2).map((d,h)=>d>1?i.exports.createElement(T,{key:`slider-${h}`,min:0,max:d-1,value:c[h],setValue:D(E=>{const v=c.slice();v[h]=E,o(v)},100,{maxWait:200})}):""))},V=e=>{var a;return a=`${e.link}?format=image/png&slice=${e.cuts.join(",")}`,e.stride!==1&&(a=a.concat(`,::${e.stride},::${e.stride}`)),i.exports.createElement(g,{component:"img",sx:{maxWidth:1},alt:"Data rendered",src:a,loading:"lazy"})};export{U as default};
