import{a6 as t,ag as e,w as o,o as i,f as n,ah as a,ai as l,g as s,aj as r,ak as c,al as d}from"./index.9313841a.js";const{passive:p}=r,u=["both","horizontal","vertical"];var f=t({name:"QScrollObserver",props:{axis:{type:String,validator:t=>u.includes(t),default:"vertical"},debounce:[String,Number],scrollTarget:e},emits:["scroll"],setup(t,{emit:e}){const r={position:{top:0,left:0},direction:"down",directionChanged:!1,delta:{top:0,left:0},inflectionPoint:{top:0,left:0}};let u,f,g=null;function m(){null==g||g();const o=Math.max(0,c(u)),i=d(u),n={top:o-r.position.top,left:i-r.position.left};if("vertical"===t.axis&&0===n.top||"horizontal"===t.axis&&0===n.left)return;const a=Math.abs(n.top)>=Math.abs(n.left)?n.top<0?"up":"down":n.left<0?"left":"right";r.position={top:o,left:i},r.directionChanged=r.direction!==a,r.delta=n,!0===r.directionChanged&&(r.direction=a,r.inflectionPoint=r.position),e("scroll",{...r})}function v(){u=l(f,t.scrollTarget),u.addEventListener("scroll",h,p),h(!0)}function b(){void 0!==u&&(u.removeEventListener("scroll",h,p),u=void 0)}function h(e){if(!0===e||0===t.debounce||"0"===t.debounce)m();else if(null===g){const[e,o]=t.debounce?[setTimeout(m,t.debounce),clearTimeout]:[requestAnimationFrame(m),cancelAnimationFrame];g=()=>{o(e),g=null}}}o((()=>t.scrollTarget),(()=>{b(),v()}));const{proxy:x}=s();return o((()=>x.$q.lang.rtl),m),i((()=>{f=x.$el.parentNode,v()})),n((()=>{null==g||g(),b()})),Object.assign(x,{trigger:h,getPosition:()=>r}),a}});export{f as Q};
