import{w as b,K as W,L as $,v as l,k as x,p as g,q as C,x as u,l as o,s,V as k,D as c,N as f,B as L,z as N,X as D,C as M,u as X,r as B,f as m}from"./x-CuOWXDIc.js";const R={key:0,class:"drawer-wrap"},K={class:"drawer__header"},P={class:"drawer__title"},T={key:1,class:"drawer__footer"},U={__name:"Drawer",props:{modelValue:{type:Boolean,default:!1},title:{type:String,default:""},size:{type:String,default:"md"},position:{type:String,default:"right"},closeOnOverlay:{type:Boolean,default:!0},closeOnEscape:{type:Boolean,default:!0},pushed:{type:Boolean,default:!1},pushOffset:{type:Number,default:0},resizable:{type:Boolean,default:!1},minWidth:{type:Number,default:320},maxWidth:{type:Number,default:0},noPadding:{type:Boolean,default:!1}},emits:["update:modelValue","close"],setup(a,{emit:E}){const t=a,y=E;function r(){y("update:modelValue",!1),y("close")}function S(){t.closeOnOverlay&&r()}function v(e){e.key==="Escape"&&t.closeOnEscape&&t.modelValue&&r()}b(()=>t.modelValue,e=>{document.body.style.overflow=e?"hidden":""}),W(()=>document.addEventListener("keydown",v)),$(()=>{document.removeEventListener("keydown",v),document.body.style.overflow=""});const V=m(()=>{const e=t.pushOffset||(t.pushed?180:0);return e?{transform:t.position==="right"?`translateX(-${e}px)`:`translateX(${e}px)`}:{}}),w=m(()=>t.position==="left"?"-100%":"100%"),n=B(null),d=B(!1),O=m(()=>n.value?{"--drawer-slide":w.value,width:`${n.value}px`}:{"--drawer-slide":w.value});b(()=>t.modelValue,e=>{e||(n.value=null)});function _(e){t.resizable&&(e.preventDefault(),d.value=!0,document.body.style.cursor="col-resize",document.body.style.userSelect="none",document.addEventListener("mousemove",p),document.addEventListener("mouseup",h))}function p(e){const z=t.maxWidth||window.innerWidth*.9;let i;t.position==="left"?i=e.clientX:i=window.innerWidth-e.clientX,n.value=Math.max(t.minWidth,Math.min(z,i))}function h(){d.value=!1,document.body.style.cursor="",document.body.style.userSelect="",document.removeEventListener("mousemove",p),document.removeEventListener("mouseup",h)}return(e,z)=>(l(),x(X,{to:"body"},[g(M,{name:"drawer",duration:300,appear:""},{default:C(()=>[a.modelValue?(l(),u("div",R,[o("div",{class:s(["drawer-overlay",a.pushed||a.pushOffset>0?"drawer-overlay--dim":""]),onClick:S},null,2),o("div",{class:s(["drawer-push",`drawer--${a.size}`,a.position==="left"?"drawer--left":""]),style:k(V.value)},[o("div",{class:s(["drawer-panel","drawer",{"drawer--resizing":d.value}]),style:k(O.value)},[a.resizable?(l(),u("div",{key:0,class:s(["drawer__resize",a.position==="left"?"drawer__resize--right":""]),onMousedown:_},null,34)):c("",!0),o("div",K,[f(e.$slots,"header",{},()=>[o("h3",P,L(a.title),1)]),o("button",{class:"drawer__close",onClick:r},[g(N(D),{class:"icon-lg"})])]),o("div",{class:s(["drawer__body",{"drawer__body--no-padding":a.noPadding}])},[f(e.$slots,"default")],2),e.$slots.footer?(l(),u("div",T,[f(e.$slots,"footer")])):c("",!0)],6)],6)])):c("",!0)]),_:3})]))}};export{U as _};
