import{r as a,a as w,j as e}from"./sikshya-admin-sikshya-react-E_TY_un4.js";import{j}from"./sikshya-admin.js";import{ad as h}from"./sikshya-admin-sikshya-vendor-BVAk_Gwu.js";let N=0;const d=[];function L({open:r,title:p,description:i,onClose:n,children:k,footer:x,size:o="md"}){const m=a.useId(),u=a.useId(),c=a.useRef(null),b=a.useRef(n);if(b.current=n,a.useEffect(()=>{if(!r)return;const t=++N,v={id:t,close:()=>{b.current()}};d.push(v);const f=s=>{if(s.key!=="Escape")return;const l=d[d.length-1];!l||l.id!==t||(s.preventDefault(),l.close())};document.addEventListener("keydown",f);const g=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.removeEventListener("keydown",f);const s=d.findIndex(l=>l.id===t);s!==-1&&d.splice(s,1),document.body.style.overflow=g}},[r]),a.useEffect(()=>{if(!r||!c.current)return;const t=c.current.querySelector('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])');t==null||t.focus()},[r]),!r||typeof document>"u")return null;const y=o==="sm"?"max-w-md":o==="comfortable"?"max-w-2xl":o==="lg"?"max-w-4xl":o==="xl"?"max-w-6xl":"max-w-lg";return w.createPortal(e.jsxs("div",{className:"sikshya-admin-theme fixed inset-0 flex items-center justify-center p-4 sm:p-6",style:{zIndex:j},role:"presentation",children:[e.jsx("button",{type:"button",className:"absolute inset-0 z-0 bg-slate-900/60 backdrop-blur-[2px] dark:bg-slate-950/70","aria-label":h("Close dialog","sikshya"),onClick:n}),e.jsxs("div",{ref:c,role:"dialog","aria-modal":"true","aria-labelledby":m,"aria-describedby":i?u:void 0,className:`relative z-10 flex max-h-[min(92dvh,920px)] w-full ${y} flex-col overflow-hidden rounded-2xl border border-slate-200 bg-white shadow-2xl ring-1 ring-black/5 dark:border-slate-700 dark:bg-slate-900 dark:ring-white/10`,children:[e.jsxs("div",{className:"flex shrink-0 items-start justify-between gap-3 border-b border-slate-100 px-6 py-4 dark:border-slate-800",children:[e.jsxs("div",{className:"min-w-0 flex-1 pr-2",children:[e.jsx("h2",{id:m,className:"text-lg font-semibold text-slate-900 dark:text-white",children:p}),e.jsx("div",{className:"mt-1 min-h-[2.75rem] text-sm leading-snug text-slate-500 dark:text-slate-400",children:i?e.jsx("p",{id:u,children:i}):e.jsx("span",{className:"block select-none opacity-0","aria-hidden":!0,children:" "})})]}),e.jsx("button",{type:"button",className:"shrink-0 rounded-lg p-2 text-slate-500 hover:bg-slate-100 hover:text-slate-800 dark:text-slate-400 dark:hover:bg-slate-800 dark:hover:text-white","aria-label":h("Close","sikshya"),onClick:n,children:e.jsx("span",{className:"block text-xl leading-none","aria-hidden":!0,children:"×"})})]}),e.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto px-6 py-5",children:k}),x?e.jsx("div",{className:"shrink-0 border-t border-slate-100 bg-slate-50/80 px-6 py-4 dark:border-slate-800 dark:bg-slate-800/40",children:x}):null]})]}),document.body)}export{L as M};
