import{a as e}from"./chunk-BNv3lrIs.js";import{n as t,t as n}from"./jsx-runtime-pmtNMKr4.js";import{a as r,i,r as a}from"./ThemeProvider-B0jyGdy2.js";import{a as o,i as s,n as c,o as l,s as u}from"./querySelectorAll-PdiS4z27.js";import{r as d,s as f}from"./NoopTransition-Cq5lMZDg.js";import{n as p}from"./contains-Br1lEy1a.js";import{n as m,t as ee}from"./useCallbackRef-BxvGShaf.js";import{Hi as h,gi as te,hi as ne,mi as g,yi as _}from"./index-CBXvBSuP.js";var v=e(r()),y=e(t());function b(e){let t=(0,y.useRef)(e);return t.current=e,t}function re(e){let t=b(e);(0,y.useEffect)(()=>()=>t.current(),[])}var x=n(),S=y.forwardRef(({className:e,bsPrefix:t,as:n=`div`,...r},i)=>(t=a(t,`modal-body`),(0,x.jsx)(n,{ref:i,className:(0,v.default)(e,t),...r})));S.displayName=`ModalBody`;var C=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,x.jsx)(`div`,{...l,ref:u,className:(0,v.default)(d,t,i&&`${e}-${i}`,r&&`${d}-centered`,c&&`${d}-scrollable`,o&&f),children:(0,x.jsx)(`div`,{className:(0,v.default)(`${e}-content`,n),children:s})})});C.displayName=`ModalDialog`;var w=y.forwardRef(({className:e,bsPrefix:t,as:n=`div`,...r},i)=>(t=a(t,`modal-footer`),(0,x.jsx)(n,{ref:i,className:(0,v.default)(e,t),...r})));w.displayName=`ModalFooter`;var T=y.forwardRef(({bsPrefix:e,className:t,closeLabel:n=`Close`,closeButton:r=!1,...i},o)=>(e=a(e,`modal-header`),(0,x.jsx)(g,{ref:o,...i,className:(0,v.default)(t,e),closeLabel:n,closeButton:r})));T.displayName=`ModalHeader`;var E=h(`h4`),D=y.forwardRef(({className:e,bsPrefix:t,as:n=E,...r},i)=>(t=a(t,`modal-title`),(0,x.jsx)(n,{ref:i,className:(0,v.default)(e,t),...r})));D.displayName=`ModalTitle`;function ie(e){return(0,x.jsx)(d,{...e,timeout:null})}function ae(e){return(0,x.jsx)(d,{...e,timeout:null})}var O=y.forwardRef(({bsPrefix:e,className:t,style:n,dialogClassName:r,contentClassName:d,children:h,dialogAs:g=C,"data-bs-theme":b,"aria-labelledby":S,"aria-describedby":w,"aria-label":T,show:E=!1,animation:D=!0,backdrop:O=!0,keyboard:k=!0,onEscapeKeyDown:oe,onShow:se,onHide:A,container:ce,autoFocus:le=!0,enforceFocus:ue=!0,restoreFocus:de=!0,restoreFocusOptions:fe,onEntered:j,onExit:M,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]=ee(),ge=c(B,he),q=p(A),_e=i();e=a(e,`modal`);let ve=(0,y.useMemo)(()=>({onHide:q}),[q]);function J(){return R||te({isRTL:_e})}function Y(e){if(!l)return;let t=J().getScrollbarWidth()>0,n=e.scrollHeight>u(e).documentElement.clientHeight;pe({paddingRight:t&&!n?m():void 0,paddingLeft:!t&&n?m():void 0})}let X=p(()=>{K&&Y(K.dialog)});re(()=>{s(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=f(K.dialog,()=>{H(!1)})},xe=e=>{e.target===e.currentTarget&&Z()},Q=e=>{if(O===`static`){xe(e);return}if(W.current||e.target!==e.currentTarget){W.current=!1;return}A?.()},Se=e=>{k?oe?.(e):(e.preventDefault(),O===`static`&&Z())},Ce=(e,t)=>{e&&Y(e),P?.(e,t)},we=e=>{G.current==null||G.current(),M?.(e)},Te=(e,t)=>{F?.(e,t),o(window,`resize`,X)},Ee=e=>{e&&(e.style.display=``),I?.(e),s(window,`resize`,X)},De=(0,y.useCallback)(t=>(0,x.jsx)(`div`,{...t,className:(0,v.default)(`${e}-backdrop`,L,!D&&`show`)}),[D,L,e]),$={...n,...V};return $.display=`block`,(0,x.jsx)(ne.Provider,{value:ve,children:(0,x.jsx)(_,{show:E,ref:ge,backdrop:O,container:ce,keyboard:!0,autoFocus:le,enforceFocus:ue,restoreFocus:de,restoreFocusOptions:fe,onEscapeKeyDown:Se,onShow:se,onHide:A,onEnter:Ce,onEntering:Te,onEntered:j,onExit:we,onExiting:N,onExited:Ee,manager:J(),transition:D?ie:void 0,backdropTransition:D?ae:void 0,renderBackdrop:De,renderDialog:n=>(0,x.jsx)(`div`,{role:`dialog`,...n,style:$,className:(0,v.default)(t,e,me&&`${e}-static`,!D&&`show`),onClick:O?Q:void 0,onMouseUp:be,"data-bs-theme":b,"aria-label":T,"aria-labelledby":S,"aria-describedby":w,children:(0,x.jsx)(g,{...z,onMouseDown:ye,className:r,contentClassName:d,children:h})})})})});O.displayName=`Modal`;var k=Object.assign(O,{Body:S,Header:T,Title:D,Footer:w,Dialog:C,TRANSITION_DURATION:300,BACKDROP_TRANSITION_DURATION:150});export{k as t};