import{r as e}from"./chunk-QTnfLwEv.js";import{n as t,t as n}from"./jsx-runtime-BWRPWl8p.js";import{a as r,i,r as a}from"./ThemeProvider-tBC-zLZT.js";import{a as o,i as s,o as c,r as l,t as u}from"./useMergedRefs-CiPe5pGZ.js";import{t as d}from"./useCallbackRef-ByuobuL2.js";import{Mi as f,Ni as ee,Pi as p,Sa as te,ba as m,ga as h,ji as g,xa as _}from"./index-DccLTdzK.js";var v=e(r()),y=e(t());function b(e){let t=(0,y.useRef)(e);return t.current=e,t}function ne(e){let t=b(e);(0,y.useEffect)(()=>()=>t.current(),[])}var x;function S(e){if((!x&&x!==0||e)&&o){var t=document.createElement(`div`);t.style.position=`absolute`,t.style.top=`-9999px`,t.style.width=`50px`,t.style.height=`50px`,t.style.overflow=`scroll`,document.body.appendChild(t),x=t.offsetWidth-t.clientWidth,document.body.removeChild(t)}return x}var C=n(),w=y.forwardRef(({className:e,bsPrefix:t,as:n=`div`,...r},i)=>(t=a(t,`modal-body`),(0,C.jsx)(n,{ref:i,className:(0,v.default)(e,t),...r})));w.displayName=`ModalBody`;var T=y.forwardRef(({bsPrefix:e,className:t,contentClassName:n,centered:r,size:i,fullscreen:o,children:s,scrollable:c,...l},u)=>{e=a(e,`modal`);let d=`${e}-dialog`,f=typeof o==`string`?`${e}-fullscreen-${o}`:`${e}-fullscreen`;return(0,C.jsx)(`div`,{...l,ref:u,className:(0,v.default)(d,t,i&&`${e}-${i}`,r&&`${d}-centered`,c&&`${d}-scrollable`,o&&f),children:(0,C.jsx)(`div`,{className:(0,v.default)(`${e}-content`,n),children:s})})});T.displayName=`ModalDialog`;var E=y.forwardRef(({className:e,bsPrefix:t,as:n=`div`,...r},i)=>(t=a(t,`modal-footer`),(0,C.jsx)(n,{ref:i,className:(0,v.default)(e,t),...r})));E.displayName=`ModalFooter`;var D=y.forwardRef(({bsPrefix:e,className:t,closeLabel:n=`Close`,closeButton:r=!1,...i},o)=>(e=a(e,`modal-header`),(0,C.jsx)(g,{ref:o,...i,className:(0,v.default)(t,e),closeLabel:n,closeButton:r})));D.displayName=`ModalHeader`;var O=m(`h4`),k=y.forwardRef(({className:e,bsPrefix:t,as:n=O,...r},i)=>(t=a(t,`modal-title`),(0,C.jsx)(n,{ref:i,className:(0,v.default)(e,t),...r})));k.displayName=`ModalTitle`;function re(e){return(0,C.jsx)(h,{...e,timeout:null})}function ie(e){return(0,C.jsx)(h,{...e,timeout:null})}var A=y.forwardRef(({bsPrefix:e,className:t,style:n,dialogClassName:r,contentClassName:m,children:h,dialogAs:g=T,"data-bs-theme":b,"aria-labelledby":x,"aria-describedby":w,"aria-label":E,show:D=!1,animation:O=!0,backdrop:k=!0,keyboard:A=!0,onEscapeKeyDown:j,onShow:ae,onHide:M,container:oe,autoFocus:se=!0,enforceFocus:ce=!0,restoreFocus:le=!0,restoreFocusOptions:ue,onEntered:de,onExit:fe,onExiting:N,onEnter:P,onEntering:F,onExited:I,backdropClassName:L,manager:R,...z},B)=>{let[V,pe]=(0,y.useState)({}),[me,H]=(0,y.useState)(!1),U=(0,y.useRef)(!1),W=(0,y.useRef)(!1),G=(0,y.useRef)(null),[K,he]=d(),ge=u(B,he),q=_(M),_e=i();e=a(e,`modal`);let ve=(0,y.useMemo)(()=>({onHide:q}),[q]);function J(){return R||ee({isRTL:_e})}function Y(e){if(!o)return;let t=J().getScrollbarWidth()>0,n=e.scrollHeight>c(e).documentElement.clientHeight;pe({paddingRight:t&&!n?S():void 0,paddingLeft:!t&&n?S():void 0})}let X=_(()=>{K&&Y(K.dialog)});ne(()=>{l(window,`resize`,X),G.current==null||G.current()});let ye=()=>{U.current=!0},be=e=>{U.current&&K&&e.target===K.dialog&&(W.current=!0),U.current=!1},Z=()=>{H(!0),G.current=te(K.dialog,()=>{H(!1)})},xe=e=>{e.target===e.currentTarget&&Z()},Q=e=>{if(k===`static`){xe(e);return}if(W.current||e.target!==e.currentTarget){W.current=!1;return}M?.()},Se=e=>{A?j?.(e):(e.preventDefault(),k===`static`&&Z())},Ce=(e,t)=>{e&&Y(e),P?.(e,t)},we=e=>{G.current==null||G.current(),fe?.(e)},Te=(e,t)=>{F?.(e,t),s(window,`resize`,X)},Ee=e=>{e&&(e.style.display=``),I?.(e),l(window,`resize`,X)},De=(0,y.useCallback)(t=>(0,C.jsx)(`div`,{...t,className:(0,v.default)(`${e}-backdrop`,L,!O&&`show`)}),[O,L,e]),$={...n,...V};return $.display=`block`,(0,C.jsx)(f.Provider,{value:ve,children:(0,C.jsx)(p,{show:D,ref:ge,backdrop:k,container:oe,keyboard:!0,autoFocus:se,enforceFocus:ce,restoreFocus:le,restoreFocusOptions:ue,onEscapeKeyDown:Se,onShow:ae,onHide:M,onEnter:Ce,onEntering:Te,onEntered:de,onExit:we,onExiting:N,onExited:Ee,manager:J(),transition:O?re:void 0,backdropTransition:O?ie:void 0,renderBackdrop:De,renderDialog:n=>(0,C.jsx)(`div`,{role:`dialog`,...n,style:$,className:(0,v.default)(t,e,me&&`${e}-static`,!O&&`show`),onClick:k?Q:void 0,onMouseUp:be,"data-bs-theme":b,"aria-label":E,"aria-labelledby":x,"aria-describedby":w,children:(0,C.jsx)(g,{...z,onMouseDown:ye,className:r,contentClassName:m,children:h})})})})});A.displayName=`Modal`;var j=Object.assign(A,{Body:w,Header:D,Title:k,Footer:E,Dialog:T,TRANSITION_DURATION:300,BACKDROP_TRANSITION_DURATION:150});export{j as t};