"use strict";const r=require("vue"),c=require("./unwrapElement.js"),s=require("./floating-ui.dom.js"),R=16,L=128;function T(a,e,o){var b;const p=()=>{var d;return(d=e.value)==null?void 0:d.isExpanded()},m=[s.offset(o==null?void 0:o.offset),s.size({padding:R,apply({rects:d,elements:t,availableHeight:i,availableWidth:l}){Object.assign(t.floating.style,{width:"".concat(o!=null&&o.useAvailableWidth?l:d.reference.width,"px"),maxHeight:"".concat(Math.max(L,i),"px")})}}),s.flip({padding:R-1}),s.hide({strategy:"escaped"}),s.hide()],{floatingStyles:x,placement:$,middlewareData:v,update:H}=c.useFloating(a,e,{middleware:m,placement:(b=o==null?void 0:o.placement)!=null?b:"bottom"}),B=r.computed(()=>{var t,i;return!p()||!!((t=v.value.hide)!=null&&t.escaped)||((i=v.value.hide)==null?void 0:i.referenceHidden)?"hidden":"visible"});r.watch([x,B,$],([d,t,i])=>{var l,g,h,f,n;Object.assign((g=(l=e.value)==null?void 0:l.$el.style)!=null?g:{},{visibility:t,position:d.position,top:"".concat(d.top,"px"),right:"unset",left:"".concat(d.left,"px"),transform:(h=d.transform)!=null?h:"none",borderTopLeftRadius:i==="bottom"&&t==="visible"?"0":"",borderTopRightRadius:i==="bottom"&&t==="visible"?"0":"",borderBottomLeftRadius:i==="top"&&t==="visible"?"0":"",borderBottomRightRadius:i==="top"&&t==="visible"?"0":""}),Object.assign((n=(f=c.unwrapElement(a.value))==null?void 0:f.style)!=null?n:{},{borderTopLeftRadius:i==="top"&&t==="visible"?"0":"",borderTopRightRadius:i==="top"&&t==="visible"?"0":"",borderBottomLeftRadius:i==="bottom"&&t==="visible"?"0":"",borderBottomRightRadius:i==="bottom"&&t==="visible"?"0":""})});let u=null;r.watch(p,d=>{var t;d?u=s.autoUpdate(a.value&&"$el"in a.value?a.value.$el:a,(t=e.value)==null?void 0:t.$el,H):u&&(u(),u=null)})}module.exports=T;
