import{s as e}from"./chunk-Bj-mKKzh.js";import{n as t}from"./jsx-runtime-CiQ1k8xo.js";import{lt as n,p as r}from"./vscode-api-DjORcpSo.js";function i(e,t){if(e!==`electron`)return`native`;switch(t){case`win32`:case`linux`:return`application-menu`;case`darwin`:case`unknown`:return`native`}}function a(){return document.documentElement.dataset.codexWindowChrome===`application-menu`}var o=n(),s=e(t(),1),c=16,l=Object.freeze({default:Object.freeze({left:0,right:0}),mac:Object.freeze({legacy:Object.freeze({left:66+c,right:0}),modern:Object.freeze({left:76+c,right:0})}),applicationMenu:Object.freeze({left:0,right:0})}),u=/mac os x (\d+)[_.](\d+)/i;function d(e){let t=u.exec(e);if(!t)return l.mac.modern;let n=Number.parseInt(t[1]??``,10),r=Number.parseInt(t[2]??``,10);return Number.isNaN(n)||Number.isNaN(r)?l.mac.modern:n===10&&r<=15?l.mac.legacy:l.mac.modern}function f(){if(typeof window>`u`||typeof navigator>`u`)return null;let e=navigator.windowControlsOverlay;if(!e?.visible)return null;let t=e.getTitlebarAreaRect();return{left:Math.max(0,Math.round(t.x)),right:Math.max(0,Math.round(window.innerWidth-(t.x+t.width)))}}function p(e,t){if(e)return l.default;if(a())return t??l.applicationMenu;if(typeof navigator>`u`)return l.default;let n=navigator,r=(n.userAgent??``).toLowerCase(),i=n.userAgentData?.platform?.toLowerCase()??n.platform?.toLowerCase()??r;return i.includes(`darwin`)||i.includes(`mac`)||r.includes(`mac os x`)||r.includes(`macintosh`)?d(r):i.includes(`win`)||r.includes(`windows`)||i.includes(`linux`)?t??l.applicationMenu:l.default}function m(){let e=(0,o.c)(9),[t,n]=(0,s.useState)(!1),[i,a]=(0,s.useState)(h),c,l;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(c=e=>{n(e.isFullScreen)},l=[],e[0]=c,e[1]=l):(c=e[0],l=e[1]),r(`window-fullscreen-changed`,c,l);let u,d;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(u=()=>{if(typeof window>`u`){a(null);return}let e=navigator.windowControlsOverlay;if(!e){a(null);return}let t=()=>{a(f())};return t(),e.addEventListener(`geometrychange`,t),window.addEventListener(`resize`,t),()=>{e.removeEventListener(`geometrychange`,t),window.removeEventListener(`resize`,t)}},d=[],e[2]=u,e[3]=d):(u=e[2],d=e[3]),(0,s.useEffect)(u,d);let m,g;e[4]===Symbol.for(`react.memo_cache_sentinel`)?(m=()=>{let e=window.matchMedia(`(display-mode: fullscreen)`);n(e.matches);let t=e=>{n(e.matches)};return e.addEventListener(`change`,t),()=>{e.removeEventListener(`change`,t)}},g=[],e[4]=m,e[5]=g):(m=e[4],g=e[5]),(0,s.useEffect)(m,g);let _;return e[6]!==t||e[7]!==i?(_=p(t,i),e[6]=t,e[7]=i,e[8]=_):_=e[8],_}function h(){return f()}export{i as n,a as r,m as t};
//# sourceMappingURL=use-window-controls-safe-area-BFjpBJf4.js.map