import{n as e,s as t}from"./jsx-runtime-Bzw2jH9X.js";import{E as n,Et as r,Ot as i,gt as a,ht as o,kt as s,lt as c,m as l,pt as u,ut as d,xt as f}from"./useSize--KU1gilk.js";import{un as p}from"./services-DDmOapmW.js";function m(e){let t=`rc-scrollbar-measure-${Math.random().toString(36).substring(7)}`,n=document.createElement(`div`);n.id=t;let r=n.style;r.position=`absolute`,r.left=`0`,r.top=`0`,r.width=`100px`,r.height=`100px`,r.overflow=`scroll`;let i,a;if(e){let n=getComputedStyle(e);r.scrollbarColor=n.scrollbarColor,r.scrollbarWidth=n.scrollbarWidth;let o=getComputedStyle(e,`::-webkit-scrollbar`),s=parseInt(o.width,10),c=parseInt(o.height,10);try{let e=s?`width: ${o.width};`:``,n=c?`height: ${o.height};`:``;d(`
#${t}::-webkit-scrollbar {
${e}
${n}
}`,t)}catch(e){console.error(e),i=s,a=c}}document.body.appendChild(n);let o=e&&i&&!Number.isNaN(i)?i:n.offsetWidth-n.clientWidth,s=e&&a&&!Number.isNaN(a)?a:n.offsetHeight-n.clientHeight;return document.body.removeChild(n),c(t),{width:o,height:s}}function h(e){return typeof document>`u`||!e||!(e instanceof Element)?{width:0,height:0}:m(e)}var g=e=>`${e}-css-var`,_=t(p()),v=t(e()),y=v.createContext(null),b=!1;function x(e){return typeof e==`boolean`&&(b=e),b}var S=[];function C(e,t){let[n]=v.useState(()=>i()?document.createElement(`div`):null),a=v.useRef(!1),o=v.useContext(y),[s,c]=v.useState(S),l=o||(a.current?void 0:e=>{c(t=>[e,...t])});function u(){n.parentElement||document.body.appendChild(n),a.current=!0}function d(){n.parentElement?.removeChild(n),a.current=!1}return r(()=>(e?o?o(u):u():d(),d),[e]),r(()=>{s.length&&(s.forEach(e=>e()),c(S))},[s]),[n,l]}function w(){return document.body.scrollHeight>(window.innerHeight||document.documentElement.clientHeight)&&window.innerWidth>document.body.offsetWidth}var T=`rc-util-locker-${Date.now()}`,E=0;function D(e){let t=!!e,[n]=v.useState(()=>(E+=1,`${T}_${E}`));r(()=>{if(t){let e=h(document.body).width,t=w();d(`
html body {
overflow-y: hidden;
${t?`width: calc(100% - ${e}px);`:``}
}`,n)}else c(n);return()=>{c(n)}},[t,n])}var O=[],k=200,A=0,j=e=>{if(e.key===`Escape`&&!e.isComposing){if(Date.now()-A<k)return;let t=O.length;for(let n=t-1;n>=0;--n)O[n].onEsc({top:n===t-1,event:e})}},M=()=>{A=Date.now()};function N(){window.addEventListener(`keydown`,j),window.addEventListener(`compositionend`,M)}function P(){O.length===0&&(window.removeEventListener(`keydown`,j),window.removeEventListener(`compositionend`,M))}function F(e,t){let n=f(),r=s(t),i=()=>{O.find(e=>e.id===n)||O.push({id:n,onEsc:r})},a=()=>{O=O.filter(e=>e.id!==n)};(0,v.useMemo)(()=>{e?i():e||a()},[e]),(0,v.useEffect)(()=>{if(e)return i(),N(),()=>{a(),P()}},[e])}var I=e=>e===!1?!1:!i()||!e?null:typeof e==`string`?document.querySelector(e):typeof e==`function`?e():e,L=v.forwardRef((e,t)=>{let{open:n,autoLock:r,getContainer:s,debug:c,autoDestroy:l=!0,children:d,onEsc:f}=e,[p,m]=v.useState(n),h=p||n;v.useEffect(()=>{(l||n)&&m(n)},[n,l]);let[g,b]=v.useState(()=>I(s));v.useEffect(()=>{let e=I(s);b(()=>e??null)});let[S,w]=C(h&&!g,c),T=g??S;D(r&&n&&i()&&(T===S||T===document.body)),F(n,f);let E=null;d&&o(d)&&t&&(E=u(d));let O=a(E,t);if(!h||!i()||g===void 0)return null;let k=T===!1||x(),A=d;return t&&(A=v.cloneElement(d,{ref:O})),v.createElement(y.Provider,{value:w},k?A:(0,_.createPortal)(A,T))}),R=v.createContext(void 0),z=100,B=1e3,V={Modal:z,Drawer:z,Popover:z,Popconfirm:z,Tooltip:z,Tour:z,FloatButton:z},H={SelectLike:50,Dropdown:50,DatePicker:50,Menu:50,ImagePreview:1},U=e=>e in V,W=(e,t)=>{let[,r]=n(),i=v.useContext(R),a=U(e),o;if(t!==void 0)o=[t,t];else{let n=i??0;n+=a?(i?0:r.zIndexPopupBase)+V[e]:H[e],o=[i===void 0?t:n,n]}return o},G=()=>({height:0,opacity:0}),K=e=>({height:e?.scrollHeight??0,opacity:+!!e}),q=e=>({height:e?.offsetHeight??0}),J=(e,t)=>t?.deadline===!0||l(t)&&t.propertyName===`height`,Y=(e=`ant`)=>({motionName:`${e}-motion-collapse`,onAppearStart:G,onEnterStart:G,onAppearActive:K,onEnterActive:K,onLeaveStart:q,onLeaveActive:G,onAppearEnd:J,onEnterEnd:J,onLeaveEnd:J,motionDeadline:500}),X=(e,t,n)=>n===void 0?`${e}-${t}`:n;export{R as a,W as i,Y as n,L as o,B as r,g as s,X as t};