"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const o=require("vue"),a=require("../hooks/useState.js"),v=require("../raf.js"),M=require("../type.js"),V=require("./util.js");function i(r){return Number.isNaN(r)?0:r}const H=o.defineComponent({props:{target:M.objectType(),className:String},setup(r){const s=o.shallowRef(null),[t,b]=a.default(null),[h,g]=a.default([]),[y,N]=a.default(0),[T,R]=a.default(0),[w,C]=a.default(0),[E,S]=a.default(0),[W,x]=a.default(!1);function u(){const{target:e}=r,n=getComputedStyle(e);b(V.getTargetWaveColor(e));const m=n.position==="static",{borderLeftWidth:B,borderTopWidth:L}=n;N(m?e.offsetLeft:i(-Number.parseFloat(B))),R(m?e.offsetTop:i(-Number.parseFloat(L))),C(e.offsetWidth),S(e.offsetHeight);const{borderTopLeftRadius:$,borderTopRightRadius:F,borderBottomLeftRadius:O,borderBottomRightRadius:j}=n;g([$,F,j,O].map(z=>i(Number.parseFloat(z))))}let l,d,c;const f=()=>{clearTimeout(c),v.default.cancel(d),l?.disconnect()},p=()=>{const e=s.value?.parentElement;e&&(o.render(null,e),e.parentElement&&e.parentElement.removeChild(e))};o.onMounted(()=>{f(),c=setTimeout(()=>{p()},5e3);const{target:e}=r;e&&(d=v.default(()=>{u(),x(!0)}),typeof ResizeObserver<"u"&&(l=new ResizeObserver(u),l.observe(e)))}),o.onBeforeUnmount(()=>{f()});const q=e=>{e.propertyName==="opacity"&&p()};return()=>{if(!W.value)return null;const e={left:`${y.value}px`,top:`${T.value}px`,width:`${w.value}px`,height:`${E.value}px`,borderRadius:h.value.map(n=>`${n}px`).join(" ")};return t&&(e["--wave-color"]=t.value),o.createVNode(o.Transition,{appear:!0,name:"wave-motion",appearFromClass:"wave-motion-appear",appearActiveClass:"wave-motion-appear",appearToClass:"wave-motion-appear wave-motion-appear-active"},{default:()=>[o.createVNode("div",{ref:s,class:r.className,style:e,onTransitionend:q},null)]})}}});function I(r,s){const t=document.createElement("div");return t.style.position="absolute",t.style.left="0px",t.style.top="0px",r?.insertBefore(t,r?.firstChild),o.render(o.createVNode(H,{target:r,className:s},null),t),()=>{o.render(null,t),t.parentElement&&t.parentElement.removeChild(t)}}exports.default=I;
