(function(a,o){typeof exports=="object"&&typeof module!="undefined"?o(exports,require("vue"),require("@floating-ui/dom")):typeof define=="function"&&define.amd?define(["exports","vue","@floating-ui/dom"],o):(a=typeof globalThis!="undefined"?globalThis:a||self,o(a.index={},a.Vue,a.dom))})(this,function(a,o,p){"use strict";const E={modelValue:{type:Boolean,default:!1},lockScroll:{type:Boolean,default:!0},closeOnClickOverlay:{type:Boolean,default:!0}};function k(){if(document.documentElement.scrollHeight>document.documentElement.clientHeight){const e=document.documentElement.scrollTop,t=document.documentElement.getAttribute("style");return document.documentElement.style.position="fixed",document.documentElement.style.top=`-${e}px`,document.documentElement.style.width=document.documentElement.style.width||"100%",document.documentElement.style.overflowY="scroll",()=>{t?document.documentElement.setAttribute("style",t):document.documentElement.removeAttribute("style"),document.documentElement.scrollTop=e}}}function C(e,t){let n;const s=l=>{l.preventDefault(),t.emit("click",l),e.closeOnClickOverlay&&t.emit("update:modelValue",!1)},r=()=>{n==null||n()};return o.watch(()=>e.modelValue,l=>{l?e.lockScroll&&(n=k()):r()}),o.onUnmounted(r),{onClick:s}}function h(e,t,n){let s=e;return t&&(s+=`__${t}`),n&&(s+=`--${n}`),s}function O(e,t=!1){const n=t?`.devui-${e}`:`devui-${e}`;return{b:()=>h(n),e:i=>i?h(n,i):"",m:i=>i?h(n,"",i):"",em:(i,u)=>i&&u?h(n,i,u):""}}var L="";const b=o.defineComponent({name:"DFixedOverlay",inheritAttrs:!1,props:E,emits:["update:modelValue","click"],setup(e,t){const{modelValue:n}=o.toRefs(e),s=O("fixed-overlay"),{onClick:r}=C(e,t);return()=>o.createVNode(o.Transition,{name:s.m("fade")},{default:()=>{var l,c;return[n.value&&o.createVNode("div",o.mergeProps({class:s.b()},t.attrs,{onClick:r}),[(c=(l=t.slots).default)==null?void 0:c.call(l)])]}})}}),A={modelValue:{type:Boolean,default:!1},origin:{type:Object,require:!0},position:{type:Array,default:["bottom"]},offset:{type:[Number,Object],default:8},shiftOffset:{type:Number},align:{type:String,default:null},showArrow:{type:Boolean,default:!1},isArrowCenter:{type:Boolean,default:!0},clickEventBubble:{type:Boolean,default:!1}};function V(e,t,n,s){let{x:r,y:l}=t;if(!e){const{width:c,height:i}=s;r&&n.includes("start")&&(r=12),r&&n.includes("end")&&(r=Math.round(c-24)),l&&n.includes("start")&&(l=10),l&&n.includes("end")&&(l=i-14)}return{x:r,y:l}}function B(e,t){const{position:n,showArrow:s}=o.toRefs(e),r=o.ref(),l=o.ref(),c=(f,d,m,y)=>{const{x:v,y:w}=V(e.isArrowCenter,m,d,y.getBoundingClientRect()),x={top:"bottom",right:"left",bottom:"top",left:"right"}[d.split("-")[0]];Object.assign(f.style,{left:v?`${v}px`:"",top:w?`${w}px`:"",right:"",bottom:"",[x]:"-4px"})},i=async()=>{const f=e.origin,d=o.unref(r.value),m=o.unref(l.value),[y,...v]=n.value,w=[p.offset(e.offset)];w.push(v.length?p.flip({fallbackPlacements:v}):p.flip()),s.value&&w.push(p.arrow({element:l.value}));const{x,y:R,placement:P,middlewareData:T}=await p.computePosition(f,d,{strategy:"fixed",placement:y,middleware:w});let j=x,N=R;t("positionChange",P),Object.assign(d.style,{top:`${N}px`,left:`${j}px`}),e.showArrow&&c(m,P,T.arrow,d)},u=f=>{var m,y;const d=f.target;(d==null?void 0:d.contains((y=(m=e.origin)==null?void 0:m.$el)!=null?y:e.origin))&&i()};return o.watch(()=>e.modelValue,()=>{e.modelValue&&e.origin?(o.nextTick(i),window.addEventListener("scroll",u,!0),window.addEventListener("resize",i)):(window.removeEventListener("scroll",u,!0),window.removeEventListener("resize",i))}),o.onUnmounted(()=>{window.removeEventListener("scroll",u,!0),window.removeEventListener("resize",i)}),{arrowRef:l,overlayRef:r,updatePosition:i}}var S="";const g=o.defineComponent({name:"DFlexibleOverlay",inheritAttrs:!1,props:A,emits:["update:modelValue","positionChange"],setup(e,{slots:t,attrs:n,emit:s,expose:r}){const l=O("flexible-overlay"),{clickEventBubble:c}=o.toRefs(e),{arrowRef:i,overlayRef:u,updatePosition:f}=B(e,s);return r({updatePosition:f}),()=>{var d;return e.modelValue&&o.createVNode("div",o.mergeProps({ref:u,class:l.b()},n,{onClick:o.withModifiers(()=>({}),[c.value?"":"stop"]),onPointerup:o.withModifiers(()=>({}),["stop"])}),[(d=t.default)==null?void 0:d.call(t),e.showArrow&&o.createVNode("div",{ref:i,class:l.e("arrow")},null)])}}}),$=typeof window!="undefined";var F={title:"Overlay \u906E\u7F69\u5C42",category:"\u901A\u7528",status:"100%",install(e){if(e.component(b.name,b),e.component(g.name,g),$&&!document.getElementById("d-overlay-anchor")){const t=document.createElement("div");t.setAttribute("id","d-overlay-anchor"),t.style.position="fixed",t.style.left="0",t.style.top="0",t.style.zIndex="1000",document.body.appendChild(t)}}};a.FixedOverlay=b,a.FlexibleOverlay=g,a.default=F,a.fixedOverlayProps=E,a.flexibleOverlayProps=A,Object.defineProperty(a,"__esModule",{value:!0}),a[Symbol.toStringTag]="Module"});
