import{d as e,i as t,m as n,t as r,y as i}from"./hooks.module-5xe-uC6c.js";import{E as a,I as o,Tt as s,bt as c}from"./content_renderer-CoENEE63.js";import{s as l}from"./options-CDt8ZGCW.js";import{t as u}from"./jsxRuntime.module--xb8gfv5.js";import{B as d}from"./hooks-CSTgmcXO.js";e();function f({children:e,className:f,size:h,title:g,customTitleBarButtons:_,header:v,footer:y,footerStyle:b,footerAlignment:x,onShown:S,onSubmit:C,helpPageId:w,minWidth:T,maxWidth:E,zIndex:D,scrollable:O,onHidden:k,modalRef:A,formRef:j,bodyStyle:M,show:N,stackable:P,keepInDom:F,noFocus:I,sidebar:L,isFullPageOnMobile:R}){let z=d(A),B=r(),V=r();n(()=>{let e=z.current;if(!e)return;S&&e.addEventListener(`shown.bs.modal`,S);function t(){k(),V.current&&`focus`in V.current&&V.current.focus()}return e.addEventListener(`hidden.bs.modal`,t),()=>{S&&e.removeEventListener(`shown.bs.modal`,S),e.removeEventListener(`hidden.bs.modal`,t)}},[S,k]),n(()=>{N&&z.current?(V.current=document.activeElement,c($(z.current),!P,{focus:!I}).then(e=>{B.current=s.getOrCreateInstance(e[0])})):B.current?.hide()},[N,z.current,I]);let H=t(()=>{let e={};return D&&(e.zIndex=D),e},[D]),U=t(()=>{let e={};return E&&(e.maxWidth=`${E}px`),T&&(e.minWidth=T),e},[E,T]);return u(`div`,{className:`modal fade mx-auto ${f}`,tabIndex:-1,style:H,role:`dialog`,ref:z,children:(N||F)&&u(`div`,{className:a(`modal-dialog`,`modal-${h}`,{"modal-dialog-scrollable":O,"modal-dialog-full-page-on-mobile":R,"modal-content-with-sidebar":L}),style:U,role:`document`,children:u(`div`,{className:a(`modal-content`,L&&`modal-content-with-sidebar`),children:[L&&u(`div`,{className:`modal-sidebar`,children:[g&&u(`div`,{className:`modal-sidebar-header`,children:u(`h5`,{children:g})}),L]}),u(p,{sidebar:!!L,children:[u(`div`,{className:`modal-header`,children:[!g||typeof g==`string`?u(`h5`,{className:`modal-title`,children:g??u(i,{children:`\xA0`})}):g,v,w&&u(`button`,{className:`help-button`,type:`button`,title:l(`modal.help_title`),onClick:()=>o.triggerCommand(`openInPopup`,{noteIdOrPath:`_help_${w}`}),children:`?`}),_?.filter(e=>e!==null).map(e=>u(`button`,{type:`button`,className:a(`custom-title-bar-button bx`,e.iconClassName),title:e.title,onClick:e.onClick})),u(`button`,{type:`button`,className:`btn-close`,"data-bs-dismiss":`modal`,"aria-label":l(`modal.close`)})]}),C?u(`form`,{ref:j,onSubmit:e=>{e.preventDefault(),C()},children:u(m,{footer:y,bodyStyle:M,footerStyle:b,footerAlignment:x,children:e})}):u(m,{footer:y,bodyStyle:M,footerStyle:b,footerAlignment:x,children:e})]})]})})})}function p({sidebar:e,children:t}){return e?u(`div`,{className:`modal-main`,children:t}):u(i,{children:t})}function m({children:e,footer:n,footerAlignment:r,bodyStyle:a,footerStyle:o}){let s=t(()=>{let e=o??{};return r===`between`&&(e.justifyContent=`space-between`),e},[o,r]);return u(i,{children:[u(`div`,{className:`modal-body`,style:a,children:e}),n&&u(`div`,{className:`modal-footer`,style:s,children:n})]})}export{f as t};