(function(g,t){typeof exports=="object"&&typeof module<"u"?t(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],t):(g=typeof globalThis<"u"?globalThis:g||self,t(g.VueStickyToParent={},g.Vue))})(this,function(g,t){"use strict";function S(e){return t.getCurrentScope()?(t.onScopeDispose(e),!0):!1}function x(e){return typeof e=="function"?e():t.unref(e)}const M=typeof window<"u"&&typeof document<"u";typeof WorkerGlobalScope<"u"&&globalThis instanceof WorkerGlobalScope;const I=e=>e!=null,W=Object.prototype.toString,R=e=>W.call(e)==="[object Object]",A=()=>{};function B(e){return t.getCurrentInstance()}function k(e,n=!0,o){B()?t.onMounted(e,o):n?e():t.nextTick(e)}function w(e){var n;const o=x(e);return(n=o==null?void 0:o.$el)!=null?n:o}const b=M?window:void 0;function _(...e){let n,o,u,c;if(typeof e[0]=="string"||Array.isArray(e[0])?([o,u,c]=e,n=b):[n,o,u,c]=e,!n)return A;Array.isArray(o)||(o=[o]),Array.isArray(u)||(u=[u]);const s=[],i=()=>{s.forEach(d=>d()),s.length=0},l=(d,r,a,f)=>(d.addEventListener(r,a,f),()=>d.removeEventListener(r,a,f)),h=t.watch(()=>[w(n),x(c)],([d,r])=>{if(i(),!d)return;const a=R(r)?{...r}:r;s.push(...o.flatMap(f=>u.map(p=>l(d,f,p,a))))},{immediate:!0,flush:"post"}),m=()=>{h(),i()};return S(m),m}function C(){const e=t.ref(!1),n=t.getCurrentInstance();return n&&t.onMounted(()=>{e.value=!0},n),e}function E(e){const n=C();return t.computed(()=>(n.value,!!e()))}function z(e,n,o={}){const{window:u=b,...c}=o;let s;const i=E(()=>u&&"MutationObserver"in u),l=()=>{s&&(s.disconnect(),s=void 0)},h=t.computed(()=>{const a=x(e),f=(Array.isArray(a)?a:[a]).map(w).filter(I);return new Set(f)}),m=t.watch(()=>h.value,a=>{l(),i.value&&a.size&&(s=new MutationObserver(n),a.forEach(f=>s.observe(f,c)))},{immediate:!0,flush:"post"}),d=()=>s==null?void 0:s.takeRecords(),r=()=>{l(),m()};return S(r),{isSupported:i,stop:r,takeRecords:d}}function L(e,n={}){const{window:o=b}=n,u=E(()=>o&&"matchMedia"in o&&typeof o.matchMedia=="function");let c;const s=t.ref(!1),i=m=>{s.value=m.matches},l=()=>{c&&("removeEventListener"in c?c.removeEventListener("change",i):c.removeListener(i))},h=t.watchEffect(()=>{u.value&&(l(),c=o.matchMedia(x(e)),"addEventListener"in c?c.addEventListener("change",i):c.addListener(i),s.value=c.matches)});return S(()=>{h(),l(),c=void 0}),s}function O(e,n,o={}){const{window:u=b,...c}=o;let s;const i=E(()=>u&&"ResizeObserver"in u),l=()=>{s&&(s.disconnect(),s=void 0)},h=t.computed(()=>Array.isArray(e)?e.map(r=>w(r)):[w(e)]),m=t.watch(h,r=>{if(l(),i.value&&u){s=new ResizeObserver(n);for(const a of r)a&&s.observe(a,c)}},{immediate:!0,flush:"post"}),d=()=>{l(),m()};return S(d),{isSupported:i,stop:d}}function V(e,n={}){const{reset:o=!0,windowResize:u=!0,windowScroll:c=!0,immediate:s=!0}=n,i=t.ref(0),l=t.ref(0),h=t.ref(0),m=t.ref(0),d=t.ref(0),r=t.ref(0),a=t.ref(0),f=t.ref(0);function p(){const v=w(e);if(!v){o&&(i.value=0,l.value=0,h.value=0,m.value=0,d.value=0,r.value=0,a.value=0,f.value=0);return}const y=v.getBoundingClientRect();i.value=y.height,l.value=y.bottom,h.value=y.left,m.value=y.right,d.value=y.top,r.value=y.width,a.value=y.x,f.value=y.y}return O(e,p),t.watch(()=>w(e),v=>!v&&p()),z(e,p,{attributeFilter:["style","class"]}),c&&_("scroll",p,{capture:!0,passive:!0}),u&&_("resize",p,{passive:!0}),k(()=>{s&&p()}),{height:i,bottom:l,left:h,right:m,top:d,width:r,x:a,y:f,update:p}}function T(e,n={width:0,height:0},o={}){const{window:u=b,box:c="content-box"}=o,s=t.computed(()=>{var r,a;return(a=(r=w(e))==null?void 0:r.namespaceURI)==null?void 0:a.includes("svg")}),i=t.ref(n.width),l=t.ref(n.height),{stop:h}=O(e,([r])=>{const a=c==="border-box"?r.borderBoxSize:c==="content-box"?r.contentBoxSize:r.devicePixelContentBoxSize;if(u&&s.value){const f=w(e);if(f){const p=f.getBoundingClientRect();i.value=p.width,l.value=p.height}}else if(a){const f=Array.isArray(a)?a:[a];i.value=f.reduce((p,{inlineSize:v})=>p+v,0),l.value=f.reduce((p,{blockSize:v})=>p+v,0)}else i.value=r.contentRect.width,l.value=r.contentRect.height},o);k(()=>{const r=w(e);r&&(i.value="offsetWidth"in r?r.offsetWidth:n.width,l.value="offsetHeight"in r?r.offsetHeight:n.height)});const m=t.watch(()=>w(e),r=>{i.value=r?n.width:0,l.value=r?n.height:0});function d(){h(),m()}return{width:i,height:l,stop:d}}function P(e={}){const{window:n=b,behavior:o="auto"}=e;if(!n)return{x:t.ref(0),y:t.ref(0)};const u=t.ref(n.scrollX),c=t.ref(n.scrollY),s=t.computed({get(){return u.value},set(l){scrollTo({left:l,behavior:o})}}),i=t.computed({get(){return c.value},set(l){scrollTo({top:l,behavior:o})}});return _(n,"scroll",()=>{u.value=n.scrollX,c.value=n.scrollY},{capture:!1,passive:!0}),{x:s,y:i}}function H(e={}){const{window:n=b,initialWidth:o=Number.POSITIVE_INFINITY,initialHeight:u=Number.POSITIVE_INFINITY,listenOrientation:c=!0,includeScrollbar:s=!0}=e,i=t.ref(o),l=t.ref(u),h=()=>{n&&(s?(i.value=n.innerWidth,l.value=n.innerHeight):(i.value=n.document.documentElement.clientWidth,l.value=n.document.documentElement.clientHeight))};if(h(),k(h),_("resize",h,{passive:!0}),c){const m=L("(orientation: portrait)");t.watch(m,()=>h())}return{width:i,height:l}}const N=((e,n)=>{const o=e.__vccOpts||e;for(const[u,c]of n)o[u]=c;return o})(t.defineComponent({name:"VueStickyToParent",__name:"VueStickyToParent",props:{parent:{}},setup(e){const n=e,o=t.ref(null),u=t.computed(()=>n.parent),{y:c}=P(),{height:s}=H(),{height:i}=T(o),{height:l}=T(u),{left:h,right:m}=V(u),d=t.computed(()=>{var f;return(((f=u.value)==null?void 0:f.getBoundingClientRect().top)??0)+c.value}),r=t.computed(()=>d.value+l.value-s.value),a=t.computed(()=>{const f=Math.max(r.value-(d.value+i.value-s.value),0),p=0,v=i.value>s.value?c.value+s.value-i.value-d.value:c.value-d.value;return v>=p&&v<=f?{...i.value>s.value?{bottom:0}:{top:0},position:"fixed",left:`${h.value}px`,right:`${m.value}px`}:{top:`${v(t.openBlock(),t.createElementBlock("div",{ref_key:"sticky",ref:o,class:"sticky-to-parent",style:t.normalizeStyle(a.value)},[t.renderSlot(f.$slots,"default",{},void 0,!0)],4))}}),[["__scopeId","data-v-4311b530"]]);g.VueStickyToParent=N,Object.defineProperty(g,Symbol.toStringTag,{value:"Module"})});