import{i as e}from"./rolldown-runtime-B1FJdls4.js";import{m as t,p as n}from"./vendor-dnd-C1cICjTT.js";import{s as r}from"./vendor-markdown-Db1-9wH7.js";import{n as i}from"./axisEvents-Dhd0R1o7.js";import{TopDock as a}from"./TopDock-DPL2nSAd.js";var o=e(t(),1),s=n(),c=r(),l=.18,u=.22;function d(){let[e,t]=(0,o.useState)(!1),n=(0,o.useRef)(null),r=(0,o.useRef)(e);r.current=e,(0,o.useEffect)(()=>{let e=null,n=i(`mc:navigate-project`,()=>{r.current&&(e!==null&&window.clearTimeout(e),e=window.setTimeout(()=>{e=null,r.current&&t(!1)},340))});return()=>{e!==null&&window.clearTimeout(e),n()}},[]),(0,o.useEffect)(()=>{if(!e)return;let n=e=>{e.key===`Escape`&&t(!1)};return window.addEventListener(`keydown`,n),()=>window.removeEventListener(`keydown`,n)},[e]);let d=(0,o.useCallback)(()=>t(!1),[]);return(0,o.useEffect)(()=>{let e=n.current;if(!e)return;let r=n=>{n.pointerType!==`mouse`&&(e.setPointerCapture?.(n.pointerId),t(!0))};return e.addEventListener(`pointerdown`,r,{passive:!0}),()=>e.removeEventListener(`pointerdown`,r)},[]),(0,o.useEffect)(()=>{if(e)return;let n=null,r=null,i=!1,a=e=>{if(e.pointerType===`mouse`)return;let t=window.innerWidth||document.documentElement.clientWidth||0,a=window.innerHeight||document.documentElement.clientHeight||0,o=a*l,s=a*(1-u);t<=0||a<=0||e.clientX<t-18||e.clientY<o||e.clientY>s||(n=e.clientX,r=e.clientY,i=!0)},o=e=>{if(!i||n==null||r==null)return;let a=e.clientX-n,o=Math.abs(e.clientY-r);if(o>Math.abs(a)&&o>12){i=!1;return}a<-36&&(i=!1,t(!0))},s=()=>{i=!1,n=null,r=null};return window.addEventListener(`pointerdown`,a,{passive:!0}),window.addEventListener(`pointermove`,o,{passive:!0}),window.addEventListener(`pointerup`,s,{passive:!0}),window.addEventListener(`pointercancel`,s,{passive:!0}),()=>{window.removeEventListener(`pointerdown`,a),window.removeEventListener(`pointermove`,o),window.removeEventListener(`pointerup`,s),window.removeEventListener(`pointercancel`,s)}},[e]),typeof document>`u`?null:(0,s.createPortal)((0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(`button`,{ref:n,type:`button`,"aria-label":`Open project dock`,"aria-hidden":e,tabIndex:e?-1:0,"data-testid":`mobile-project-dock-edge-target`,className:`fixed right-0 z-[90] w-4 bg-transparent border-0 p-0 ${e?`pointer-events-none`:``}`,style:{top:`${l*100}dvh`,bottom:`${u*100}dvh`,touchAction:`pan-y`}}),(0,c.jsx)(`div`,{className:`fixed inset-0 z-[100] transition-opacity duration-200 ${e?`opacity-100 pointer-events-auto`:`opacity-0 pointer-events-none`}`,"aria-hidden":!e,children:(0,c.jsx)(`div`,{className:`absolute inset-0 mc-scrim`,onClick:d,"data-testid":`mobile-project-dock-backdrop`})}),(0,c.jsx)(`div`,{"data-testid":`mobile-project-dock-drawer`,children:(0,c.jsx)(a,{placement:`right`,mobile:!0,open:e})})]}),document.body)}export{d as MobileProjectDock};