import{dz as h,dA as p,r as f,cE as E,cB as S}from"./index-c5c88b67.js";function g(t,o,e,s,a){const[r,i]=f.useState(()=>a&&e?e(t).matches:s?s(t).matches:o);return E(()=>{if(!e)return;const c=e(t),n=()=>{i(c.matches)};return n(),c.addEventListener("change",n),()=>{c.removeEventListener("change",n)}},[t,e]),r}const v={...S},d=v.useSyncExternalStore;function w(t,o,e,s,a){const r=f.useCallback(()=>o,[o]),i=f.useMemo(()=>{if(a&&e)return()=>e(t).matches;if(s!==null){const{matches:u}=s(t);return()=>u}return r},[r,t,s,a,e]),[c,n]=f.useMemo(()=>{if(e===null)return[r,()=>()=>{}];const u=e(t);return[()=>u.matches,m=>(u.addEventListener("change",m),()=>{u.removeEventListener("change",m)})]},[r,e,t]);return d(n,c,i)}function L(t,o={}){const e=h(),s=typeof window<"u"&&typeof window.matchMedia<"u",{defaultMatches:a=!1,matchMedia:r=s?window.matchMedia:null,ssrMatchMedia:i=null,noSsr:c=!1}=p({name:"MuiUseMediaQuery",props:o,theme:e});let n=typeof t=="function"?t(e):t;return n=n.replace(/^@media( ?)/m,""),(d!==void 0?w:g)(n,a,r,i,c)}export{L as u};
