sticky-scroll-trigger 0.15.0 → 0.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* @license
|
|
3
|
-
* StickyScrollTrigger v0.
|
|
3
|
+
* StickyScrollTrigger v0.17.0
|
|
4
4
|
* Copyright (c) 2026 Kuninori Ogino
|
|
5
5
|
* Released under the MIT License
|
|
6
6
|
* https://github.com/kuninori-ogino/sticky-scroll-trigger
|
|
7
7
|
*/
|
|
8
|
-
const e=e=>{let t=typeof e==`string`?document.querySelector(e):e;if(!t){let t=typeof e==`string`?`"${e}"`:String(e);throw Error(`StickyScrollTrigger: root ${t} not found`)}return t},t=(e,t)=>{let n=typeof e==`string`?document.querySelector(e):e;if(!n){let n=typeof e==`string`?`"${e}"`:String(e);throw Error(`${t}: element ${n} not found`)}return n},n=(e,n,r)=>n===void 0?e:t(n,r),r=e=>{let t=e.id?`#${e.id}`:``,n=e.classList.length>0?`.${Array.from(e.classList).join(`.`)}`:``;return`<${e.tagName.toLowerCase()}${t}${n}>`},i=e=>{let t=0,n=e;for(;n;){t+=n.offsetTop;let e=n.offsetParent;e&&(t+=e.clientTop),n=e}return t},a=()=>{let e=document.createElement(`div`);e.style.height=`100vh`,e.style.position=`absolute`,document.body.appendChild(e);let t=e.offsetHeight||window.innerHeight;return e.remove(),t},o=()=>document.documentElement.scrollHeight||document.body.scrollHeight,s=/* @__PURE__ */ new Set,c=()=>{s.forEach(e=>{e.isConnected||s.delete(e)});let e=[...s].map(e=>({inner:e,height:e.style.height}));e.forEach(({inner:e})=>{e.style.height=``});let t=o();return e.forEach(({inner:e,height:t})=>{e.style.height=t}),t},l=e=>Math.max(0,o()-e),u=(e,t)=>e===`none`||e===`hidden`?0:parseFloat(t),d=e=>{let t=e.offsetHeight,n=getComputedStyle(e),r=parseFloat(n.height);if(!Number.isFinite(r))return t;let i=n.boxSizing===`border-box`?r:r+parseFloat(n.paddingTop)+parseFloat(n.paddingBottom)+u(n.borderTopStyle,n.borderTopWidth)+u(n.borderBottomStyle,n.borderBottomWidth);return t>0&&Math.abs(i-t)>=1?t:i},f=(e,t)=>{let n=e.compareDocumentPosition(t);return n&Node.DOCUMENT_POSITION_FOLLOWING?-1:n&Node.DOCUMENT_POSITION_PRECEDING?1:0},p=e=>{e.style.position=``,e.style.top=``},m=e=>({position:e.style.position,top:e.style.top}),h=(e,t)=>{e.style.position=t.position,e.style.top=t.top},g=e=>{let t=e.map(m);return e.forEach(p),()=>e.forEach((e,n)=>h(e,t[n]))},_=(e,t)=>{try{return t()}finally{e()}},v=e=>{let t=e.map(({after:e,height:t})=>{let n=document.createElement(`div`);return n.style.cssText=`height:${t}px;margin:0;padding:0;border:0`,e.after(n),n});return()=>t.forEach(e=>e.remove())},y=()=>{let e=document.createElement(`div`);return e.style.setProperty(`transition`,`none`,`important`),e},b=(e,t)=>{if(!e.parentNode)throw Error(`StickyScrollTrigger: ${r(e)} is not attached to the document`);let n=y(),i=y(),a=y();if(a.setAttribute(`aria-hidden`,`true`),a.style.pointerEvents=`none`,e.parentNode.insertBefore(n,e),n.appendChild(i),i.appendChild(e),n.appendChild(a),t){let e=y();e.style.display=`flow-root`,i.appendChild(e)}return{container:n,wrapper:i,padding:a}},x=e=>{let t=e.parentNode;if(!t)throw Error(`createOverlapScroll: trigger ${r(e)} is not attached to the document`);let n=y();for(t.insertBefore(n,t.firstChild);n.nextSibling;){let t=n.nextSibling;if(n.appendChild(t),t===e)break}return n},S=e=>{let t=e.parentNode;if(t){for(;e.firstChild;)t.insertBefore(e.firstChild,e);e.remove()}},C=e=>{if(!e.parentNode)throw Error(`createStickyPin: trigger ${r(e)} is not attached to the document`);let t=y(),n=y();return t.style.display=`flow-root`,e.parentNode.insertBefore(t,e),t.appendChild(n),n.appendChild(e),s.add(n),{outer:t,inner:n}},ee=(e,t,n)=>{let r=e.parentNode;h(t,n),r&&r.insertBefore(t,e),e.firstElementChild instanceof HTMLElement&&s.delete(e.firstElementChild),e.remove()},w={position:`relative`,zIndex:`1`},T=/* @__PURE__ */ new WeakMap,te=e=>{let t=[];for(let n=e;n;n=n.nextElementSibling){if(!(n instanceof HTMLElement))continue;let e=n,r=T.get(e);if(r)r.count+=1;else{let t=getComputedStyle(e),n=[];t.position===`static`&&n.push(`position`),t.zIndex===`auto`&&n.push(`zIndex`),n.forEach(t=>{e.style[t]=w[t]}),T.set(e,{count:1,applied:n})}t.push(e)}return()=>{t.forEach(e=>{let t=T.get(e);t&&(--t.count,!(t.count>0)&&(t.applied.forEach(t=>{e.style[t]===w[t]&&(e.style[t]=``)}),T.delete(e)))}),t.length=0}},ne=e=>e.constructor,E=e=>e?.isRefreshing===!0,re=e=>!!e?.isScrolling?.(),ie=e=>!!(e?.isScrolling?.()||e?.isUpdating===!0),D=(e,t,n)=>{e?.addEventListener?.(t,n)},O=(e,t,n)=>{e?.removeEventListener?.(t,n)},ae=e=>{typeof e?.refresh==`function`&&e.refresh()},k=(e,t=!1)=>{if(!e||!E(e))return null;let n=e.getScrollFunc?.(window);if(!(n&&typeof n.rec==`number`&&(t||n.rec)))return null;let r=n;return{read:()=>r.rec,write:e=>{r.rec=e}}},oe=e=>{let t=e?.getScrollFunc?.(window);if(typeof t!=`function`)return;let n=t();(typeof n!=`number`||Math.abs(n-window.scrollY)>=.5)&&t(window.scrollY)},se=(e,t)=>({render:n=>{t?.render?.(n),e()}}),ce=()=>typeof CSS<`u`&&typeof CSS.supports==`function`&&CSS.supports(`font`,`-apple-system-body`)||typeof navigator<`u`&&navigator.vendor===`Apple Computer, Inc.`&&!/\bjsdom\//.test(navigator.userAgent),le=e=>{let t=e.filter(([e,t])=>t>e).sort((e,t)=>e[0]-t[0]),n=[];return t.forEach(([e,t])=>{let r=n.at(-1);r&&e<=r[1]?r[1]=Math.max(r[1],t):n.push([e,t])}),n},ue=(e,t,n)=>{let r=t;for(let[t,i]of e)if(n?t<=r:t<r)r+=i-t;else break;return r},de=e=>[e.transform,e.translate,e.scale,e.rotate].some(e=>e!==void 0&&e!==``&&e!==`none`),fe=(e,t)=>{if(!e)return!1;let n=t.get(e);if(n!==void 0)return n;let r=de(getComputedStyle(e))||fe(e.parentElement,t);return t.set(e,r),r},pe=e=>![e.overflowX,e.overflowY].every(e=>e===`visible`||e===`clip`),me=()=>pe(getComputedStyle(document.documentElement))&&pe(getComputedStyle(document.body)),he=(e,t)=>{let n=e.parentElement;if(!n||n===document.body||n===document.documentElement)return!1;let r=t.get(n);if(r!==void 0)return r;let i=getComputedStyle(n),a=i.position===`fixed`||pe(i)||he(n,t);return t.set(n,a),a},ge=(e,t)=>{let n=/* @__PURE__ */ new Map,r=e=>{if(!e)return 0;let i=n.get(e);if(i!==void 0)return i;let a=(t.has(e)||getComputedStyle(e).position===`sticky`?1:0)+r(e.parentElement);return n.set(e,a),a},i=/* @__PURE__ */ new Map,a=0;for(let t of e)t.isConnected&&!he(t,i)&&(a=Math.max(a,1+r(t.parentElement)));return a},_e=/^-?(?:\d+\.?\d*|\.\d+)(?:e[+-]?\d+)?(px|%)$/i,A=/* @__PURE__ */ new Set;let j=[],ve=0,ye=!1,M=null,N=`idle`,be=!1,xe=null;const P=/* @__PURE__ */ new Set,Se=()=>Array.from(P).some(e=>E(e)),Ce=(e,t)=>e.demotable?t<e.lo-ve?`before`:t>e.hi+ve&&!e.holdsAfter?`after`:`in`:`in`,F=(e,t=!1)=>{let{style:n}=e.el,r=e.state!==`in`,i=t&&n.position===`static`||r&&n.position===`relative`;i&&(n.position=e.position),r&&i&&n.top===e.demotedTop&&(n.top=e.top),r&&e.zIndexAuto&&n.zIndex===`0`&&(n.zIndex=e.zIndex),r&&e.willChangeAuto&&n.willChange===`opacity`&&(n.willChange=e.willChange),e.state=`in`},we=(e,t)=>{if(e.state===t)return;if(t===`in`){F(e);return}let{style:n}=e.el;n.position=`relative`,n.top=`${t===`before`?0:e.travel}px`,e.demotedTop=n.top,e.zIndexAuto&&(n.zIndex=`0`),e.willChangeAuto&&(n.willChange=`opacity`),e.state=t},I=e=>{j.forEach(t=>we(t,Ce(t,e)))},Te=()=>I(window.scrollY),Ee=e=>{e!==ye&&(ye=e,e?window.addEventListener(`scroll`,Te,{passive:!0}):window.removeEventListener(`scroll`,Te))},L=()=>{j.forEach(e=>F(e)),j=[],Ee(!1)},De=()=>{let e=M;N===`measuring`&&e!==null&&(N=`restored`,j.length&&I(e))},Oe=()=>{N=`idle`,M=null,be=!1},ke=()=>{try{Be(null)}catch(e){L(),queueMicrotask(()=>{throw e})}},Ae=()=>{let e=N!==`idle`;Oe(),e&&R().length&&ke()},je=()=>{let e=Array.from(P).find(e=>E(e));return k(e)?.read()??window.scrollY},Me=()=>(N===`idle`&&(N=`measuring`,M=je(),queueMicrotask(Ae),j.length&&I(0)),se(De)),Ne=e=>{P.has(e)||(E(e)&&(be=!0),P.add(e),D(e,`refresh`,Ae),D(e,`refreshInit`,Me))},Pe=()=>{P.size&&queueMicrotask(()=>{R().length||(P.forEach(e=>{O(e,`refresh`,Ae),O(e,`refreshInit`,Me)}),P.clear())})},Fe=e=>{let t=/* @__PURE__ */ new Map,n=e=>e.isConnected&&getComputedStyle(e).position===`sticky`&&!he(e,t);if(xe)return Array.from(/* @__PURE__ */ new Set([...xe,...j.map(e=>e.el),...e])).filter(n);let r=Array.from(document.querySelectorAll(`*`)).filter(n);return xe=r,queueMicrotask(()=>{xe=null}),r},Ie=(e,t)=>{let n=j.flatMap(n=>{let r=n.demotable?[Math.max(0,n.lo-e),Math.min(t,n.hi+(n.holdsAfter?1/0:e))]:[0,t];return r[1]>=r[0]?[{record:n,start:r[0],end:r[1]}]:[]}),r=0;return(/* @__PURE__ */ new Set([0,...n.filter(({record:e})=>e.demotable).map(({start:e})=>e)])).forEach(e=>{let t=new Set(n.filter(({start:t,end:n})=>t<=e&&e<=n).map(({record:e})=>e));t.forEach(e=>{r=Math.max(r,1+e.ancestors.filter(e=>t.has(e)).length)})}),r},Le=(e,t)=>{let n=13,r=Math.floor(e/25);if(r<n||Ie(n*25,t)>4)return 325;for(;n<r;){let e=Math.ceil((n+r)/2);Ie(e*25,t)<=4?n=e:r=e-1}return n*25},R=()=>{let e=[];return A.forEach(t=>{let n=t.deref();if(!n){A.delete(t);return}let r=n.ownedElements();r.some(e=>e.isConnected)&&e.push({client:n,owned:r,demotable:n.demotableElements()})}),e},Re=(e,t,n)=>{let r=window.scrollY,i=document.documentElement.clientHeight||window.innerHeight,a=/* @__PURE__ */ new Map,s=o();return e.forEach(e=>{let{el:o}=e,s=o.getBoundingClientRect(),c=getComputedStyle(o),l=o.parentElement,u=s.bottom+r;if(l){let t=getComputedStyle(l);u=l.getBoundingClientRect().bottom+r-parseFloat(t.borderBottomWidth)-parseFloat(t.paddingBottom),(t.display===`contents`||t.display===`inline`)&&n.add(e)}if(e.naturalTop=s.top+r,e.travel=Math.max(0,u-(e.naturalTop+s.height+parseFloat(c.marginBottom))),e.overflowBottom=e.naturalTop+o.clientTop+o.scrollHeight,(c.position!==`static`||fe(o,a))&&n.add(e),(c.bottom!==`auto`||c.left!==`auto`||c.right!==`auto`)&&n.add(e),t.has(o)&&(!c.top.endsWith(`px`)||Math.abs(parseFloat(c.top)-parseFloat(o.style.top))>.01)&&n.add(e),!t.has(o)&&c.top===`auto`)e.stickyTop=0,e.travel=0;else if(!t.has(o)){let t=_e.exec(c.top)?.[1];t?e.stickyTop=t===`%`?parseFloat(c.top)*i/100:parseFloat(c.top):n.add(e)}}),{scroll:r,viewportHeight:i,documentHeight:s}},ze=()=>{L(),Oe(),Pe()},Be=e=>{let t=R();if(!t.length){ze();return}if(e&&Ne(e),Se()||Oe(),!P.size||me()||!t.some(({demotable:e})=>e.length)){L();return}let n=/* @__PURE__ */ new Map;t.forEach(({client:e,owned:t})=>{t.forEach(t=>n.set(t,e))});let r=t.every(({client:e})=>e.mode===`auto`),i=new Set(j.filter(e=>e.state!==`in`).map(e=>e.el));if(r&&ge(n.keys(),i)<7){L();return}let a=Fe(n.keys()),o=new Set(a),s=j.filter(e=>e.state!==`in`&&!o.has(e.el));s.filter(e=>!e.el.isConnected).forEach(e=>F(e));let c=s.filter(e=>e.el.isConnected),l=new Map(j.map(e=>[e.el,e])),u=[...a.map(e=>{let t=getComputedStyle(e),n=l.get(e);return n&&n.state!==`in`?{...n,demotable:!1,position:e.style.position,top:e.style.top,stickyTop:parseFloat(e.style.top)||0,ancestors:[],state:`before`}:{el:e,demotable:!1,position:e.style.position,top:e.style.top,zIndex:e.style.zIndex,willChange:e.style.willChange,zIndexAuto:t.zIndex===`auto`,willChangeAuto:t.willChange===`auto`,stickyTop:parseFloat(e.style.top)||0,naturalTop:0,travel:0,ancestors:[],lo:0,hi:0,overflowBottom:0,holdsAfter:!1,state:`in`,demotedTop:``}}),...c];u.sort((e,t)=>f(e.el,t.el)),u.forEach((e,t)=>{e.ancestors=u.slice(0,t).filter(t=>t.el.contains(e.el))});let d=/* @__PURE__ */ new Set;u.forEach(e=>{n.has(e.el)&&e.ancestors.forEach(e=>d.add(e))});let p=u.filter(e=>n.has(e.el)||d.has(e)||e.state!==`in`||e.ancestors.some(e=>n.has(e.el))),m=new Set(p);p.forEach(e=>{e.ancestors=e.ancestors.filter(e=>m.has(e))});let h=/* @__PURE__ */ new Map;p.forEach(e=>{let t=n.get(e.el);t&&h.set(t,Math.max(h.get(t)??0,e.ancestors.length+1))});let g=new Set(t.map(({client:e})=>e).filter(e=>e.mode===`always`||(h.get(e)??0)>=7)),_=new Set(t.flatMap(e=>e.demotable));if(p.forEach(e=>{let t=n.get(e.el);e.demotable=t!==void 0&&g.has(t)&&_.has(e.el)}),j=p,!p.some(e=>e.demotable)){L();return}let v=p.filter(e=>n.has(e.el)||d.has(e)||e.state!==`in`),y=new Map(v.filter(e=>!n.has(e.el)&&e.state===`in`).map(({el:e})=>[e,e.getAttribute(`style`)])),b=()=>v.forEach(e=>{if(!y.has(e.el)){F(e,!0);return}let t=y.get(e.el);t==null?e.el.removeAttribute(`style`):e.el.setAttribute(`style`,t)});v.forEach(({el:e})=>{e.style.position=`static`});let x=/* @__PURE__ */ new Set,S;try{S=Re(v,n,x)}finally{b()}let{scroll:C,viewportHeight:ee,documentHeight:w}=S,T=Math.max(0,w-ee);p.forEach(e=>{let t=le(e.ancestors.map(e=>[e.lo,e.hi])),n=e.naturalTop-e.stickyTop;e.lo=ue(t,n,!0),e.hi=ue(t,n+e.travel,!1),(x.has(e)||e.ancestors.some(e=>x.has(e)))&&(e.demotable=!1);let r=e.ancestors.filter(e=>e.demotable&&!e.holdsAfter).reduce((e,t)=>e+t.travel,0);e.holdsAfter=e.overflowBottom+e.travel+r>w+1}),ve=Le(ee,T),I(N===`measuring`?0:(N===`restored`?M:null)??C),Ee(!0)},Ve=()=>!be||!Se()?null:(Me(),De),He=e=>{N!==`idle`&&(M=e)},Ue=L,We=()=>{j.forEach(e=>{e.state===`after`&&we(e,`before`)})},Ge=()=>new Set(j.filter(e=>e.state===`after`&&e.travel>0).map(e=>e.el)),Ke=e=>{j.length&&I(N===`measuring`?0:e)},qe=e=>{let t=new Set(e);j=j.filter(e=>!t.has(e.el)||(F(e),!1))},Je=e=>{A.add(new WeakRef(e))};let Ye=!1;const Xe=()=>{Ye||(Ye=!0,queueMicrotask(()=>{Ye=!1,ke()}))},Ze=e=>{A.forEach(t=>{t.deref()===e&&(A.delete(t),qe(e.ownedElements()))}),R().length?Xe():ze()},Qe=(e,t)=>{e.style.position=`sticky`,e.style.top=`${t}px`},$e=(e,t)=>{e.style.position=t.position,e.style.top=t.top},z=(e,t)=>{e.style.height=t},et=(e,t)=>{e.style.position=``,e.style.top=``,t&&(t.style.height=`0px`)},tt=e=>{e.style.position=``,e.style.top=``},nt=e=>{e.style.height=``},B=e=>typeof e==`function`?e():e,rt={top:0,center:.5,bottom:1},it=(e,t,n,r)=>{let i=n===`%`?parseFloat(t)/100*r:parseFloat(t);return e?.startsWith(`-`)?-i:i},at=/^(top|center|bottom|[+-]?(?:\d+(?:\.\d*)?|\.\d+))?(%|px)?(?:([+-]=?)(\d+(?:\.\d*)?|\.\d+)(%|px)?)?$/,ot=(e,t)=>{let n=at.exec(e);if(!n||!n[1]&&!n[3])throw vt.test(e)?Error(`StickyScrollTrigger: unsupported position clause "${e}": 'max' is GSAP's end-only keyword for the scroller's maximum scroll position.`):Error(`StickyScrollTrigger: unsupported position clause "${e}"`);let[,r,i,a,o,s]=n;if(r!==void 0&&a&&!a.includes(`=`)){let t=`${r}${i??``}${a}=${o}${s??``}`;throw Error(`StickyScrollTrigger: unsupported position clause "${e}": a signed offset needs an explicit '=' when it follows a keyword or number (GSAP needs it to tell "${r}" from the offset). Did you mean "${t}"?`)}let c=r!==void 0&&r in rt,l=i===`%`;return{fraction:c?rt[r]:l?parseFloat(r)/100:0,offsetPx:(!c&&!l&&r!==void 0?parseFloat(r):0)+(a?it(a,o,s,t):0)}},st=e=>typeof e==`number`||e.trim()!==``&&!Number.isNaN(Number(e)),ct=e=>typeof e==`number`?e:Number(e),lt=e=>{if(!e.startsWith(`clamp(`))return;let t=e.slice(6).replace(/\)$/,``).trim();throw Error(`StickyScrollTrigger: unsupported position clause "${e}": GSAP's clamp() wrapper isn't supported here.`+(t?` Did you mean "${t}"?`:``))},ut=e=>{let t=e.trim();return lt(t),t.split(/\s+/)},dt=(e,t)=>{let{fraction:n,offsetPx:r}=ot(e,t);return t*n+r},ft=(e,t)=>dt(ut(e)[0],t),pt=e=>ft(e,1)-ft(e,0),V=(e,t,n)=>{let[r,i=`top`]=ut(e);return dt(i,n)-dt(r,t)},mt=/^\+=(\d+(?:\.\d*)?|\.\d+)(%|px)?$/,ht=e=>typeof e==`string`&&mt.test(e.trim()),gt=(e,t)=>{if(typeof t!=`string`)return t;let n=t.trim();if(!n.startsWith(`+=`)||!/\s/.test(n))return t;let r=B(e);if(typeof r!=`string`)return t;let[i]=ut(r);try{ot(i,0)}catch(e){if(!st(r))throw e;return t}if(ot(n.split(/\s+/)[0],0),i.includes(`=`))throw Error(`StickyScrollTrigger: end "${t}" can't be resolved against start "${r}": GSAP reads an end that starts with '+=' and holds a space by prefixing it with the start clause's element token, and "${i}" carries an offset of its own, which GSAP resolves by discarding the end's. Give end a complete position clause instead, such as 'top+=100 bottom'.`);return i+n},_t=(e,t)=>{let n=mt.exec(String(e).trim());if(!n)throw Error(`StickyScrollTrigger: unsupported end format "${e}"`);let[,r,i]=n;return it(void 0,r,i,t)},vt=/^max(?:([+-]=)(\d+(?:\.\d*)?|\.\d+)(%|px)?)?$/,yt=e=>typeof e==`string`&&vt.test(e.trim()),bt=(e,t)=>{let n=vt.exec(e.trim());if(!n)throw Error(`StickyScrollTrigger: unsupported max-position format "${e}"`);let[,r,i,a]=n;return r?it(r,i,a,t):0},H=e=>typeof e==`number`?{kind:`absolute`,value:e}:ht(e)?{kind:`dwell`,value:e}:yt(e)?{kind:`max`,value:e}:st(e)?{kind:`absolute`,value:ct(e)}:{kind:`clause`,value:e},xt=(e,t,n,r,i)=>e[t].triggerEnclosedBy.some(a=>a!==t&&e[a].kind===`scene`&&i.isBefore(a,t)&&!(n.includes(a)&&a!==r)),St=(e,t)=>e.flatMap(({triggerEnclosedBy:e},n)=>n!==t&&e.includes(t)?[n]:[]),Ct=({measurements:e,world:t,order:n,ownIndex:r},i,a,o,s)=>{let{enclosedBy:c,anchorElement:l}=o,u=e[i];return c.includes(i)?+((u.start.mode===`absolute`?t.unpaddedStart(i,r,a):u.triggerTop-u.start.anchorOffset)<s-.05):n&&xt(e,i,c,l,n)?0:o.nests.includes(i)?o.fraction:+(u.triggerTop+u.triggerHeight<=o.top+.05)},wt=(e,t,n,r,i)=>t.reduce((t,{index:a,freezeStart:o,freezeEnd:s})=>{let{ownIndex:c,order:l}=e;if(a===c||l&&l.isBefore(c,a))return t;let u=Ct(e,a,o,n,r);return u===0?t:(i?.add(a),t+u*(s-o))},0),Tt=(e,t,n)=>{let r=t=>{let{start:n,triggerTop:r}=e[t];return n.mode===`clause`?r-n.anchorOffset:null},i=e.flatMap(({kind:e},t)=>e===`scene`?[t]:[]),a=i.filter(e=>r(e)!==null).sort((e,t)=>{let n=r(e)-r(t);return Math.abs(n)<=.05?e-t:n}),o=i.flatMap(t=>{let{start:n}=e[t];return n.mode===`absolute`?[{k:t,value:n.value}]:[]}).sort((e,t)=>e.value-t.value),s=0,c=0;for(let e of a){let i=r(e);for(;c<o.length&&o[c].value<i+s+.05;)s+=n(o[c].k),c+=1;if(e===t)return i+s;s+=n(e)}throw Error(`StickyScrollTrigger: internal error: clauseFreezeStart was given a layer without a clause start.`)},Et=(e,{viewportHeight:t,measureLiveEndTriggerTop:n},r,i,a,o,s=!1)=>{let c=[],l=()=>e.flatMap((e,t)=>{if(e.kind!==`scene`)return[];let n=s?null:c[t];if(n)return[{index:t,freezeStart:n.freezeStart,freezeEnd:n.freezeEnd}];let i=r?.freezeStarts[t]??null,a=r?.paddings[t]??null;return i===null||a===null?[]:[{index:t,freezeStart:i,freezeEnd:i+a}]}),u=e=>(s?null:c[e]?.paddingHeight)??r?.paddings[e]??0,d=[],f=e.map((o,s)=>{if(c[s]=null,o.kind===`cover`)return null;let f={index:s,counted:/* @__PURE__ */ new Set,runs:[]};d.push(f);let p={measurements:e,world:a,order:i,ownIndex:s},m=(e,t)=>{let n=(n,r)=>wt(p,n,e,t,r);return f.runs.push(e=>n(e,f.counted)),n(l())},{start:h}=o,g=h.mode===`absolute`?h.value:r?.freezeStarts[s]??Tt(e,s,u),_=t=>i!==null&&(i.isBefore(s,t)||xt(e,t,o.triggerEnclosedBy,s,i)),v=(t,n)=>{let r=St(e,s),i=pt(t.clause)-(h.mode===`clause`?h.elementFraction:0),a=e.reduce((e,t,n)=>i===0||t.kind!==`scene`||!r.includes(n)||_(n)?e:(f.counted.add(n),e+i*u(n)),0);if(h.mode===`clause`)return g+Math.max(0,h.anchorOffset-n+a);let c=e.reduce((e,t,n)=>n===s||t.kind!==`scene`||r.includes(n)||t.triggerTop+t.triggerHeight>o.triggerTop+.05||_(n)?e:(f.counted.add(n),e+u(n)),0);return Math.max(g,o.triggerTop-n+c+a)},y=(t,r)=>{let i;if(t.measureLive)i=n(s);else{let n=o.endTrigger.index===null?t.rawTop:e[o.endTrigger.index].triggerTop;if(n===null)i=0;else{let e={top:n,fraction:pt(t.clause),nests:o.endTrigger.nests,enclosedBy:o.endTrigger.enclosedBy,anchorElement:o.endTrigger.index};i=n+m(e,n-r)}}let a;return a=h.mode===`absolute`?h.value:o.triggerTop-h.anchorOffset+m({top:o.triggerTop,fraction:h.elementFraction,nests:St(e,s),enclosedBy:o.triggerEnclosedBy,anchorElement:s},o.triggerTop-h.anchorOffset),g+Math.max(0,i-r-a)},b;switch(o.end.mode){case`dwell`:b=g+o.end.distancePx;break;case`absolute`:{let e=a.absoluteEndLength(s);b=e===null?Math.max(g,o.end.value):g+e;break}case`auto`:case`max`:throw Error(`StickyScrollTrigger: internal error: a Scene layer reached '${o.end.mode}' end mode, which only a cover layer can have.`);case`clause`:{let e=V(o.end.clause,o.endTrigger.height,t);b=o.endTrigger.isSelf?v(o.end,e):y(o.end,e);break}}let x={freezeStart:g,freezeEnd:b,paddingHeight:Math.max(0,b-g)};return c[s]=x,x});if(o){let e=l();d.forEach(({index:t,counted:n,runs:r})=>{r.forEach(t=>t(e)),o(t,n)})}return f},Dt=(e,t,n,{viewportHeight:r,documentMaxScroll:i,measureLiveEndTriggerTop:a})=>{let o=e[t];if(o.start.mode!==`clause`)throw Error(`StickyScrollTrigger: internal error: a cover layer measurement carries an absolute start, which resolveStartSpec should have already rejected.`);let s=e=>e+kt(e,n),c=o.triggerTop-o.start.anchorOffset,l=c+kt(c,n,{countTies:!0}),u;switch(o.end.mode){case`auto`:u=s(o.coverTop);break;case`dwell`:u=l+o.end.distancePx;break;case`absolute`:u=o.end.value;break;case`max`:u=i+o.end.offsetPx;break;case`clause`:{let n=V(o.end.clause,o.endTrigger.height,r);u=o.end.measureLive?a(t)-n:s((o.endTrigger.isSelf?o.triggerTop:o.endTrigger.index===null?o.end.rawTop??0:e[o.endTrigger.index].triggerTop)-n);break}}return{freezeStart:l,freezeEnd:Math.max(l,u),engagedStart:l,engagedEnd:Math.max(l,u),stickyTop:o.start.anchorOffset-(o.triggerTop-o.wrapperTop),paddingHeight:null}},Ot=.05,kt=(e,t,{countTies:n=!1}={})=>{let r=n?-.05:Ot,i=0,a=0;return[...t].sort((e,t)=>e.freezeStart-t.freezeStart).forEach(({freezeStart:t,freezeEnd:n})=>{t<e+i-r&&(a+=n-t),i+=n-t}),a},At=(e,t)=>t.reduce((t,{freezeStart:n,freezeEnd:r})=>t+Math.min(Math.max(e-n,0),r-n),0),jt=e=>{let t=e.map(()=>-1),n=e.map(()=>0),r=e.map(()=>-1),i=[],a=0,o=0,s=c=>{t[c]=a,n[c]=a,a+=1,i.push(c);for(let i of e[c])t[i]===-1?(s(i),n[c]=Math.min(n[c],n[i])):r[i]===-1&&(n[c]=Math.min(n[c],t[i]));if(n[c]===t[c]){let e;do e=i.pop(),r[e]=o;while(e!==c);o+=1}};return e.forEach((e,n)=>{t[n]===-1&&s(n)}),r},Mt=(e,t)=>{let n=jt(e.map(({triggerEnclosedBy:n},r)=>[...t[r],...n.filter(t=>t!==r&&e[t].kind===`scene`)])),r=[];return e.map((e,t)=>t).sort((e,t)=>n[e]-n[t]||e-t).forEach((e,t)=>{r[e]=t}),{isBefore:(e,t)=>r[e]<r[t]}},Nt=(e,t)=>{let n=jt(t);return new Set(e.map(e=>n[e])).size<e.length},Pt=(e,t,n)=>{let r=e.map(()=>[]);return n.forEach((n,i)=>{let a=e[i],o=(a.end.mode===`clause`&&!a.endTrigger.isSelf?a.endTrigger.enclosedBy:a.triggerEnclosedBy).filter(e=>e!==a.endTrigger.index);n.forEach(n=>{t[n]<=.05||(r[i].push(n),e[n].triggerEnclosedBy.forEach(t=>{t!==n&&t!==i&&e[t].kind===`scene`&&!o.includes(t)&&r[t].push(n)}))})}),r},Ft=(e,t,n,r)=>{let i=new Set(t),a=[],o=[],s=0,c=-1/0;for(;i.size;){let t=-1,l=0,u=!1,d=0;for(let n of i){let{start:r,triggerTop:i}=e[n],a=r.mode===`absolute`,o=r.mode===`clause`?i-r.anchorOffset:0,c=r.mode===`absolute`?r.value:o+s,f=Math.abs(c-l)<=Ot;(t===-1||c<l-.05||f&&(a?!u||c<l:!u&&o<d-.05))&&(t=n,l=c,u=a,d=o)}let{end:f}=e[t],p=f.mode===`absolute`&&r(t)?Math.max(l,f.value):l+n[t],m=Math.max(l,c),h=Math.max(m,p);i.delete(t),a[t]=[l,p],o[t]=[m,h],s+=h-m,c=Math.max(c,h)}return{reported:a,engaged:o}},It=(e,t)=>{let n=e.flatMap(({kind:e},t)=>e===`scene`?[t]:[]),r=n.length>1,i=/* @__PURE__ */ new Map,a={...t,measureLiveEndTriggerTop:e=>{let n=i.get(e);if(n!==void 0)return n;let r=t.measureLiveEndTriggerTop(e);return i.set(e,r),r}},o=(e,t)=>e.every((e,n)=>e===t[n]||e!==null&&t[n]!==null&&Math.abs(e-t[n])<=.05),s=(e,t)=>o(e.paddings,t.paddings)&&o(e.freezeStarts,t.freezeStarts),c=e=>e.map(e=>e?Math.max(0,e.freezeEnd-e.freezeStart):0),l=(t,n)=>({paddings:e.map(({kind:e},n)=>e===`scene`?t[n]:null),freezeStarts:e.map(({kind:e},t)=>e===`scene`?n[t][0]:null)}),u=(e,t)=>{let n=n=>n(e[0]).map((r,i)=>r===null?null:e.reduce((e,r,a)=>e+t[a]*n(r)[i],0));return{paddings:n(e=>e.paddings),freezeStarts:n(e=>e.freezeStarts)}},d=null,f=(t,r,i)=>{let a=Ft(e,n,t,()=>i.endsAsRefreshed);return d={lengths:t,order:r,reported:a.reported,refreshTime:[]},a},p=t=>{if(d===null)return null;let{lengths:r,order:i,refreshTime:a}=d,o=e=>e===t||i!==null&&!i.isBefore(e,t);return a[t]??=Ft(e,n,r.map((e,t)=>o(t)?0:e),e=>!o(e)).reported,a[t]},m=(t,r)=>({unpaddedStart:(e,i,a)=>{let o=(r.startsAsRefreshed?p(i):null)??d?.reported??[],s=n.flatMap(n=>{if(n===e||n===i||!o[n]||t&&!t.isBefore(n,i))return[];let[r,s]=o[n];return Math.min(s,a)>r?[[r,Math.min(s,a)]]:[]}).sort((e,t)=>e[0]-t[0]),c=0,l=-1/0;for(let[e,t]of s){let n=Math.max(e,l);t>n&&(c+=t-n),l=Math.max(l,t)}return a-c},absoluteEndLength:t=>{let{end:n}=e[t];if(!r.endsAsRefreshed||n.mode!==`absolute`||d===null)return null;let i=d.order===null?d.reported:p(t);return Math.max(0,n.value-i[t][0])}}),h=(t,n,i,o=null,d=2,p=1)=>{let h=m(t,n),g=[],_=null;for(let m=0;m<i;m+=1){let i=c(Et(e,a,_,t,h,o)),m=f(i,t,n),v=l(i,m.reported);if(!r||_!==null&&s(v,_))return{lengths:i,...m};let y=v;if(_!==null){g.push(_);let e=-1;for(let t=0;t<d-1&&e===-1;t+=1)g.length>t+1&&s(v,g[g.length-t-2])&&(e=t);if(e!==-1){let t=[...g.slice(g.length-e-1),v];y=u(t,t.map(()=>1/t.length))}else p<1&&(y=u([v,_],[p,1-p]))}_=y}return null},g=(t,r)=>{let i=m(null,r),o=t=>{let{reported:n}=f(t,null,r);return c(Et(e,a,l(t,n),null,i,null,!0))},s=o(t),u=e.map(()=>[]);return n.forEach(e=>{let n=t.slice();n[e]+=2**-7,o(n).forEach((t,n)=>{n!==e&&Math.abs(t-s[n])>1e-6&&u[n].push(e)})}),u},_=e=>e===null||e.reported.some(e=>e.some(e=>!(Math.abs(e)<=2**48))),v=e.map(()=>/* @__PURE__ */ new Set),y={endsAsRefreshed:!0,startsAsRefreshed:!1},b=h(null,y,Math.max(64,2*e.length+2),(e,t)=>t.forEach(t=>v[e].add(t))),x=(()=>{if(_(b))return Mt(e,v);if(!r)return null;let t=g(b.lengths,y);return Nt(n,t)?Mt(e,v):Nt(n,Pt(e,b.lengths,t))?{isBefore:(e,t)=>e<t}:null})();if(x){let t={endsAsRefreshed:!1,startsAsRefreshed:!1};b=h(x,t,2*e.length+2),_(b)&&(b=h(x,t,Math.max(64,2*e.length+2),null,4,.5)),_(b)&&(b=h(x,{endsAsRefreshed:!0,startsAsRefreshed:!0},2*e.length+2))}if(_(b))throw Error(`StickyScrollTrigger: could not resolve endTrigger positions: some endTrigger references form a circular structural dependency that never settles. Point each endTrigger at an element that doesn't depend on it.`);let{reported:S,engaged:C}=b,ee=e.map(({kind:e},r)=>{if(e!==`scene`)return null;let[i,a]=C[r],o=n.reduce((e,t)=>t>r&&C[t][1]<=i+.05?e+(C[t][1]-C[t][0]):e,0);return{freezeStart:S[r][0],freezeEnd:S[r][1],engagedStart:i,engagedEnd:a,stickyTop:t.structureTop-(i-o),paddingHeight:a-i}}),w=n.map(e=>({freezeStart:C[e][0],freezeEnd:C[e][1]})),T=ee.map((t,n)=>t??Dt(e,n,w,a));return T.forEach((e,n)=>t.onPlanned(n,e)),T},Lt=`--sst-scroll-margin-top-offset`;let Rt=0;const zt=typeof CSS<`u`&&typeof CSS.supports==`function`&&CSS.supports(`animation-timeline`,`scroll()`),Bt=typeof CSSStyleSheet==`function`&&typeof CSSStyleSheet.prototype.replaceSync==`function`&&typeof document<`u`&&Array.isArray(document.adoptedStyleSheets),Vt=zt&&Bt,Ht=(e,t)=>{let n=[],r=[],i=[],a=[];return t.forEach((t,o)=>{let s=`--${e}-c${o}`,c=`${e}-k${o}`;n.push(`@property ${s}{syntax:"<length>";inherits:true;initial-value:0px}`,`@keyframes ${c}{from{${s}:0px}to{${s}:${t.freezeEnd-t.freezeStart}px}}`),r.push(`${c} linear both`),i.push(`scroll(root block)`),a.push(`${t.freezeStart}px ${t.freezeEnd}px`)}),n.push(`@supports (animation-timeline: scroll()) {[data-${e}]{animation:${r.join(`,`)};animation-timeline:${i.join(`,`)};animation-range:${a.join(`,`)}}}`),n.join(``)},Ut=(e,t)=>{let n=`sst${Rt++}`,r=!Vt&&t!==null,i=/* @__PURE__ */ new WeakMap,a=/* @__PURE__ */ new Set,o=null,s=null,c=[],l=null,u=(e=window.scrollY)=>{l&&c.forEach((t,r)=>{let i=Math.min(Math.max(e-t.freezeStart,0),t.freezeEnd-t.freezeStart);l.style.setProperty(`--${n}-c${r}`,`${i}px`)})},d=()=>u();r&&window.addEventListener(`scroll`,d,{passive:!0});let f=e=>{let t=i.get(e);e.style.scrollMarginTop=t?t.inline:``},p=()=>{o&&=(document.adoptedStyleSheets=document.adoptedStyleSheets.filter(e=>e!==o),null),s?.removeAttribute(`data-${n}`),s=null,c=[],l=null},m=(e,t)=>{s!==t&&(s?.removeAttribute(`data-${n}`),s=t,s.setAttribute(`data-${n}`,``)),r?(c=e,l=t):(o||(o=new CSSStyleSheet,document.adoptedStyleSheets=[...document.adoptedStyleSheets,o]),o.replaceSync(Ht(n,e)))},h=()=>{a.forEach(f),a=/* @__PURE__ */ new Set,p()};return{targets:()=>t===null?[]:Array.from(e.querySelectorAll(t)),sync(r,o,s){let c=r.filter(e=>e.freezeEnd>e.freezeStart).sort((e,t)=>e.freezeStart-t.freezeStart);if(t===null||!c.length||!o){h();return}m(c,o);let l=Array.from(e.querySelectorAll(t)),u=s(l);l.forEach(e=>{let t=i.get(e);t?a.has(e)&&(e.style.scrollMarginTop=t.inline):i.set(e,{inline:e.style.scrollMarginTop})});let d=c.map((e,t)=>`var(--${n}-c${t}, 0px)`).join(` + `);l.forEach((e,t)=>{let n=parseFloat(getComputedStyle(e).scrollMarginTop)||0,r=0,i=c.map(({freezeStart:e,freezeEnd:i})=>{let a=u[t]-n+r-e-Ot;return r+=i-e,`clamp(0px, (${a}px - var(${Lt}, 0px)) * 1000000, ${i-e}px)`}).join(` + `);e.style.scrollMarginTop=`calc(${n}px + var(${Lt}, 0px) + ${d} - (${i}))`});let p=new Set(l);a.forEach(e=>{p.has(e)||f(e)}),a=p},applyRamps(e){u(e)},restore(){r&&window.removeEventListener(`scroll`,d),h()}}},Wt=e=>{for(let t=1;t<e.length;t+=1)if(f(e[t-1].trigger,e[t].trigger)>0)return!0;return!1},Gt=(e,t)=>{t.sort((e,t)=>f(e.trigger,t.trigger));for(let e of t)e.kind===`cover`&&(e.wrapper=x(e.trigger));let n=e,r=null;for(let i of t){if(i.kind!==`scene`)continue;let t=b(n,n===e);i.container=t.container,i.wrapper=t.wrapper,i.padding=t.padding,n=t.container,r=t.container}return r},Kt=e=>{e.wrapper&&=(S(e.wrapper),null)},qt=(e,t,n)=>{n&&(n.parentNode?.insertBefore(e,n),n.remove());for(let e=t.length-1;e>=0;--e){let n=t[e];n.kind===`cover`?Kt(n):(n.wrapper=null,n.container=null,n.padding=null)}},Jt=(e,t,n,a,o,s)=>{if(a===null)return{mode:`auto`};let c=H(a);switch(c.kind){case`dwell`:return{mode:`dwell`,distancePx:Math.max(0,_t(c.value,t))};case`absolute`:return{mode:`absolute`,value:c.value};case`max`:if(n.kind!==`cover`)throw Error(`StickyScrollTrigger: createStickyTrigger's trigger ${r(n.trigger)} has end "${a}". GSAP's 'max' keyword isn't supported here: the layer's own dwell padding adds to the document's max scroll position, so the freeze window would depend on itself. Use createOverlapScroll, which adds no padding, or a dwell distance such as '+=500'.`);return{mode:`max`,offsetPx:bt(c.value,t)};case`clause`:{if(n.kind!==`cover`&&s!==null&&s>o)throw Error(`StickyScrollTrigger: createStickyTrigger's trigger ${r(n.trigger)}'s endTrigger (${r(n.endTrigger)}) refers to a layer positioned later in DOM order, which isn't supported for createStickyTrigger. Point endTrigger at a layer earlier in DOM order, use an unregistered element at the same spot, or use a dwell distance such as '+=500'.`);let t=s===null,a=e.contains(n.endTrigger);if(t&&!a&&n.kind!==`cover`)throw Error(`StickyScrollTrigger: createStickyTrigger's trigger ${r(n.trigger)} has an endTrigger (${r(n.endTrigger)}) outside the shared container: the layer's own dwell keeps pushing it away, so the freeze window never settles. Point endTrigger at an element inside the container, or use a dwell distance such as '+=500'.`);return{mode:`clause`,clause:c.value,rawTop:t&&a?i(n.endTrigger):null,measureLive:t&&!a}}}},Yt=(e,t,n,i)=>{let a=H(t);switch(a.kind){case`absolute`:if(e.kind===`cover`)throw Error(`StickyScrollTrigger: createOverlapScroll's trigger ${r(e.trigger)} has start "${t}", an absolute scroll position (GSAP reads any bare number this way). That isn't supported here: a cover layer's sticky position is computed relative to its own wrapper, so start must be a position clause such as 'bottom bottom'.`);return{mode:`absolute`,value:a.value};case`max`:case`dwell`:case`clause`:return{mode:`clause`,anchorOffset:V(a.value,n,i),elementFraction:pt(a.value)}}},Xt=(e,t,n,r,a)=>{let o=B(n.start),s=n.end===null?null:gt(o,B(n.end)),c=d(n.trigger),l=n.endTrigger===n.trigger,u=e=>[...a].filter(([t])=>e(t)).map(([,e])=>e),f=a.get(n.endTrigger)??null,p=Jt(e,t,n,s,r,f),m=p.mode===`clause`&&!p.measureLive&&!l,h=Yt(n,o,c,t),{end:g}=n,_=n.kind===`scene`&&typeof g==`function`&&(p.mode===`dwell`||p.mode===`absolute`)?()=>Jt(e,t,n,gt(o,g()),r,f):void 0;return{kind:n.kind,start:h,triggerTop:i(n.trigger),triggerHeight:c,triggerEnclosedBy:u(e=>e.contains(n.trigger)),wrapperTop:n.wrapper?i(n.wrapper):0,coverTop:n.kind===`cover`?i(n.cover):0,end:p,endTrigger:{isSelf:l,index:f,height:p.mode===`clause`?d(n.endTrigger):0,enclosedBy:m?u(e=>e.contains(n.endTrigger)):[],nests:m?u(e=>e!==n.endTrigger&&n.endTrigger.contains(e)):[]},liveEnd:_}},Zt=[`trigger`,`start`,`end`,`endTrigger`,`pin`,`pinSpacing`,`anticipatePin`,`pinnedContainer`,`pinReparent`,`pinSpacer`,`pinType`,`horizontal`,`scroller`,`containerAnimation`],Qt=e=>{let t=e=>{if(!Number.isFinite(e))throw Error(`StickyScrollTrigger: createStickyPin's top must be a finite number, got ${e}.`);return`top ${e}px`};return typeof e==`function`?()=>t(e()):t(e)},$t=(e,t,n,r,a)=>{switch(t.kind){case`dwell`:return n+_t(t.value,r);case`absolute`:return t.value;case`clause`:return a(e,i(e)-V(t.value,d(e),r))}},en=(e,t)=>{let n=e.indexOf(t);n!==-1&&e.splice(n,1)},tn=(e,t)=>{let n=[];for(let r=e;r;r=r.outer)n.unshift(r.suspend(t&&r===e));return()=>n.forEach(e=>e())},nn=e=>e.mode===`dwell`?e.distancePx:e.mode===`absolute`?e.value:0,rn=(e,t)=>e.some(e=>e.trigger===t),U=/* @__PURE__ */ new Set,an=/* @__PURE__ */ new Set,W=/* @__PURE__ */ new Map;let on=0,G=null;const K=/* @__PURE__ */ new Set;let q=null,sn=null,J=null,cn=-1/0;const ln=e=>{J=e?window.scrollY:null,cn=performance.now()},un=()=>(J!==null&&(Math.abs(window.scrollY-J)>=.5||performance.now()-cn>=500)&&(J=null),J!==null),dn=e=>(E(e)?re(e):ie(e))&&!un(),Y=e=>re(e)&&!un(),fn=e=>{Math.abs(window.scrollY-e)>=.5&&window.scrollTo({top:e,behavior:`instant`})},pn=e=>{if(q!==null)return fn(0),We(),()=>{};let t=!Y(e);return q=window.scrollY,We(),window.scrollTo({top:0,behavior:`instant`}),()=>{let n=q??0;q=null,window.scrollTo({top:n,behavior:`instant`}),ln(t),oe(e),Ke(window.scrollY)}};let X=!1,mn=0;const hn=e=>{if(X){let t=window.scrollY;if(t===0)return()=>{};let n=!Y(e);return window.scrollTo({top:0,behavior:`instant`}),()=>{window.scrollTo({top:t,behavior:`instant`}),ln(n)}}let t=k(e,!0);if(!t||t.read()===0)return()=>{};let n=!Y(e);return mn=t.read(),We(),window.scrollTo({top:0,behavior:`instant`}),X=!0,()=>{X=!1,window.scrollTo({top:t.read(),behavior:`instant`}),ln(n)}},gn=()=>q??(X?mn:null),_n=(e,t)=>{let n=/* @__PURE__ */ new Set,r=Ge();return e.some(e=>{for(let i=e;i&&!n.has(i)&&i!==document.body&&i!==document.documentElement;i=i.parentElement)if(n.add(i),!t.has(i)&&(r.has(i)||getComputedStyle(i).position===`sticky`))return!0;return!1})},vn=()=>{(X||q!==null)&&fn(0),q!==null&&We()},Z=e=>typeof e==`function`?()=>{try{return e()}finally{vn()}}:e;let Q=null,$=0;const yn=e=>{let t=Q,n=gn();if(n!==null&&!t){let t=k(e,!0);t&&Math.abs(t.read()-n)>=.5&&(t.write(n),He(n))}if(!t)return;let r=tn(t,!1),i=k(e,!0);if(i&&Math.abs(i.read()-t.scroll)>=.5){fn(Math.round(t.scroll)),oe(e);let n=window.scrollY>=Math.round(t.scroll)-.5,r=gn()!==null&&n?t.scroll:window.scrollY;i.write(r),He(r)}let a=$-1,o=!0;Q=null;let s=()=>{!o||$>a||(o=!1,r(),t.ended||(Q=t))};D(e,`refresh`,s),queueMicrotask(()=>O(e,`refresh`,s))},bn=(...e)=>{let t=null;if(e.forEach(e=>{try{e()}catch(e){t?queueMicrotask(()=>{throw e}):t={error:e}}}),t)throw t.error};var xn=class o{#e;#t=[];#n=[];#r=null;#i=/* @__PURE__ */ new WeakMap;#a=!1;#o=!1;#s=null;#c=0;#l=!1;#u=0;#d=!1;#f=!1;#p=!1;#m=null;#h=null;#g=null;#_=null;#v=[];#y=null;#b;#x=!1;#S=null;#C=!1;#w=null;constructor(t,n={}){this.#e=e(t);let r=n.scrollMarginTargets===void 0?`[id]`:n.scrollMarginTargets;if(r!==null)try{this.#e.querySelectorAll(r)}catch{throw Error(`StickyScrollTrigger: scrollMarginTargets "${r}" is not a valid CSS selector.`)}let i=n.nestedStickyOptimization===void 0?`auto`:n.nestedStickyOptimization;if(![`auto`,`always`,`off`].includes(i))throw Error(`StickyScrollTrigger: nestedStickyOptimization must be 'auto', 'always' or 'off', got ${String(i)}.`);this.#b=r,(i===`always`||i===`auto`&&ce())&&(this.#w={mode:i,ownedElements:()=>this.#F(),demotableElements:()=>this.#I()})}#T(){U.delete(this)&&(this.#p=!1),!this.#x&&(this.#x=!0,K.add(this),an.forEach(e=>{e.owner.#A(this)&&(e.cancelled=!0)}),this.#y=Ut(this.#e,this.#b),this.#w&&Je(this.#w))}#E(){if(this.#x&&!this.#l&&!this.#t.length&&!this.#v.length){if(U.has(this))return;let e=this.#_;if(!E(e)&&ie(e)){U.add(this),queueMicrotask(()=>this.#j());return}this.#O(!0,!0)}}#D(){this.#l||U.forEach(e=>{e!==this&&e.#A(this)&&e.#N()})}#O(e,t=!1){let n=e&&this.#a?this.#pe(this.#n):null;this.#p=!1,this.#P(),n&&(k(this.#_)?this.#me(n):(this.#g&&an.delete(this.#g),this.#g={owner:this,position:n,cls:this.#_,onlyAtRest:t,cancelled:!1},an.add(this.#g),queueMicrotask(()=>this.#k())))}#k(){let e=this.#g;e&&(this.#g=null,an.delete(e),!(e.cancelled||e.onlyAtRest&&Y(e.cls))&&this.#me(e.position,e.cls))}#A(e){return this.#e.contains(e.#e)||e.#e.contains(this.#e)}#j(){if(this.#l||this.#h!==null)return;if(Y(this.#_)){this.#h=setTimeout(()=>{this.#h=null,this.#j()},100);return}let e=this.#m;this.#m=null,bn(()=>this.#M(),()=>e?.())}#M(e=!0,t=!1){U.delete(this)&&!this.#l&&!this.#t.length&&!this.#v.length&&this.#O(e,t)}#N(){this.#M(!Y(this.#_),!0)}#P(){this.#x=!1,K.delete(this),Ze(this.#w),this.#y?.restore(),this.#y=null,this.#ve(),this.#R(),this.#n=[]}#F(){return[...this.#I(),...this.#L()]}#I(){return this.#n.flatMap(e=>e.wrapper?[e.wrapper]:[])}#L(){return this.#v.flatMap(({trigger:e,inner:t})=>t?[e]:[])}#R(){this.#a&&=(qt(this.#e,this.#n,this.#s),on+=1,this.#c+=1,this.#r=null,this.#s=null,!1)}#z(){let e=new Set(this.#n);return this.#t.every(t=>e.has(t))}#B(){let e=new Set(this.#t),t=this.#n.flatMap(t=>!e.has(t)&&t.kind===`scene`?[t]:[]);qe(t.flatMap(({wrapper:e})=>e?[e]:[]));for(let e of t)e.wrapper&&(et(e.wrapper,e.padding),e.wrapper=null,e.container=null,e.padding=null);this.#n=[...this.#t],on+=1,this.#c+=1,this.#r=null,this.#o=!1}#V(){this.#s=Gt(this.#e,this.#t),this.#n=[...this.#t],this.#a=!0,this.#o=!1}#H(){this.#M(),this.#fe(),this.#k()}#U(){if(this.#l||(this.#a&&(this.#p=!0),W.has(this)))return;let e=this.#_,t=()=>W.get(this)===n,n=()=>{if(!t()||(W.delete(this),this.#l))return!1;try{this.#H()}catch(e){queueMicrotask(()=>{throw e})}return!0};W.set(this,n);let r=()=>{if(!n())return;let e=Ve();return e?se(e):void 0};D(e,`refreshInit`,r);let i=()=>{try{t()&&!this.#l&&ae(this.#_)}finally{O(e,`refreshInit`,r),n()}};queueMicrotask(()=>{if(t()&&!this.#l&&Y(e)){let e=this.#m;this.#m=e?()=>bn(e,i):i,this.#j()}else i()})}#W(e){this.#l||(this.#_=ne(e),sn=this.#_)}#G(e){let t=t=>{this.#W(t),E(this.#_)&&yn(this.#_);let n=e?.(t),r=E(this.#_),i=!1,a=!1;r&&([...W].forEach(([e,t])=>e!==this&&t()),i=W.get(this)?.()===!0,i&&this.#S?.takeRecords());let o=r&&!e&&!this.#o&&(i||this.#S!==null&&this.#S.takeRecords().length===0),s=r&&(!o||i)?hn(this.#_):()=>{};_(s,()=>{try{o||(a=!0,this.#de(!0))}catch(e){queueMicrotask(()=>{throw e})}r&&(this.#K(),(a||i)&&this.#q())});let c=Ve();return c?se(c,n):n};return e=>{$+=1;try{return t(e)}finally{--$}}}#K(){if(this.#S){this.#S.takeRecords();return}let e=new MutationObserver(()=>{}),t=this.#_,n=()=>{e.disconnect(),this.#S===e&&(this.#S=null),queueMicrotask(()=>O(t,`refresh`,n))};e.observe(document,{subtree:!0,childList:!0,attributes:!0,characterData:!0}),this.#S=e,D(t,`refresh`,n),queueMicrotask(n)}#q(){let e=G??/* @__PURE__ */ new Map;G||(G=e,queueMicrotask(()=>{G===e&&(G=null)})),e.set(this,this.#J()),e.forEach((t,n)=>{if(!(n.#l||t===n.#J())){try{n.#de(!0)}catch(e){queueMicrotask(()=>{throw e})}n.#S?.takeRecords(),e.set(n,n.#J())}})}#J(){let e=[i(this.#e)];return this.#C&&e.push(c()),[...this.#t,...this.#v].forEach(({endTrigger:t})=>{this.#e.contains(t)||e.push(i(t))}),e.join(`,`)}#Y(){this.#v.forEach(e=>{if(e.outer)return;e.savedPosition=m(e.trigger);let t=C(e.trigger);e.outer=t.outer,e.inner=t.inner})}#X(){let e=this.#v.flatMap(({outer:e,inner:t})=>e&&t?[{outer:e,inner:t,range:t.style.height}]:[]);e.forEach(({outer:e,inner:t})=>{nt(e),nt(t)});let t=e.map(({outer:e})=>d(e));e.forEach(({outer:e},n)=>{z(e,`${t[n]}px`)}),e.forEach(({inner:e,range:t})=>z(e,t))}#Z(e){return e.outer?(ee(e.outer,e.trigger,e.savedPosition),e.outer=null,e.inner=null,!0):!1}#Q(){return g(this.#I())}#$(){let e=this.#v.filter(({inner:e})=>e).map(e=>({layer:e,restore:g([e.trigger])}));return()=>e.forEach(({layer:e,restore:t})=>{e.inner&&t()})}static#ee(e,t){let n=e??[...K].find(e=>e.#_),r=(n?n.#_:null)??sn;if(q!==null)return pn(r);let i=E(r);if(i&&X)return hn(r);if(!(i&&$>0)&&!dn(r)&&window.scrollY!==0){let n=new Set(e?e.#F():[]);return _n(t,n)?pn(r):()=>{}}let a=[...K].filter(t=>t!==e).map(e=>e.#Q());return()=>a.reverse().forEach(e=>e())}#te(e){let t=this.#Q(),n=this.#$(),r=o.#ee(this,e);return()=>{r(),n(),t()}}#ne(e){let t=()=>{};_(()=>t(),()=>this.#ie(e,()=>{t=o.#ee(this,this.#re())}))}#re(){let e=[...this.#t,...this.#v].flatMap(e=>[e.trigger,e.endTrigger,...`cover`in e&&e.cover?[e.cover]:[]]);return[this.#e,...e,...this.#y?.targets()??[]]}#ie(e,t){let n=this.#t.filter(e=>e.wrapper!==null),r=n.flatMap(({wrapper:e})=>e?[e]:[]),i=r.map(m),a=this.#v.map(e=>({layer:e,position:m(e.trigger),range:e.inner?e.inner.style.height:``})),o=this.#c,s=()=>this.#c===o,l=e=>{s()&&e.forEach((e,t)=>Qe(t,e))};r.forEach(tt),a.forEach(({layer:e})=>tt(e.trigger)),t();let u,d;try{let t=n.length?this.#oe(e,n):null;d=this.#xe(n),u=t?this.#se(e,n,t):/* @__PURE__ */ new Map,this.#C=a.length>0||(t?.measured.some(({end:e})=>e.mode===`max`)??!1)}catch(e){throw s()&&r.forEach((e,t)=>$e(e,i[t])),a.forEach(({layer:e,position:t})=>{e.inner&&$e(e.trigger,t)}),e}let f=[];try{a.length&&(a.forEach(({layer:e})=>{e.inner&&nt(e.inner)}),f=this.#ae(e,c()))}catch(e){throw l(u),a.forEach(({layer:e,position:t,range:n})=>{e.inner&&($e(e.trigger,t),z(e.inner,n))}),e}l(u),f.forEach(({layer:e,topPx:t,range:n})=>{e.inner&&(Qe(e.trigger,t),z(e.inner,`${n}px`))}),this.#be(d)}#ae(e,t){return this.#v.flatMap(n=>{if(!n.inner)return[];let r=B(n.start),a=gt(r,B(n.end)),o=H(a);if(o.kind===`max`)throw Error(`StickyScrollTrigger: createStickyPin's end "${a}" uses GSAP's 'max' keyword, which isn't supported here. Use a position clause against endTrigger, such as 'top top'.`);let s=i(n.trigger),c=d(n.trigger),l=parseFloat(getComputedStyle(n.trigger).marginBottom)||0,u=H(r);if(u.kind===`absolute`)throw Error(`StickyScrollTrigger: createStickyPin's start "${r}" is an absolute scroll position (GSAP reads any bare number this way). A pin can't act on one: it engages when position:sticky engages, so start says where trigger sits in the viewport while pinned. Use the top option (top: ${r}) for a px distance from the viewport's top edge, or a position clause such as 'top top'.`);let f=V(u.value,c,e),p=(e,t)=>this.#ke(e,t),m=$t(n.endTrigger,o,p(n.trigger,s-f),e,p),h=m-(this.#e.contains(n.trigger)?At(m,this.#Ae()):0)-s+f+c+l,g=t>0?t-s:1/0;return[{layer:n,topPx:f,range:Math.max(0,Math.min(h,g))}]})}#oe(e,t){let n=this.#s?i(this.#s):0;this.#r={top:n,changes:on};let r=/* @__PURE__ */ new Map;return t.forEach((e,t)=>{r.set(e.trigger,t)}),{structureTop:n,measured:t.map((t,n)=>Xt(this.#e,e,t,n,r))}}#se(e,t,{structureTop:n,measured:r}){let a=r.some(e=>e.end.mode===`clause`&&e.end.measureLive),o=r.some(e=>e.end.mode===`max`),s=0,l=!1,u=/* @__PURE__ */ new Map,d=()=>It(r,{viewportHeight:e,structureTop:n,documentMaxScroll:s,measureLiveEndTriggerTop:e=>l?i(t[e].endTrigger):0,onPlanned:(e,n)=>{let r=t[e];r.freezeStart=n.freezeStart,r.freezeEnd=n.freezeEnd,r.engagedStart=n.engagedStart,r.engagedEnd=n.engagedEnd,r.wrapper&&(u.set(r.wrapper,n.stickyTop),r.kind===`scene`&&r.padding&&n.paddingHeight!==null&&z(r.padding,`${n.paddingHeight}px`))}});return this.#ce(t,r,()=>{let i=t.map(()=>0);return It(r,{viewportHeight:e,structureTop:n,documentMaxScroll:s,measureLiveEndTriggerTop:()=>0,onPlanned:(e,t)=>{i[e]=t.paddingHeight??0}}),i}),d(),o&&(s=Math.max(0,c()-e)),l=!0,(a||o)&&d(),u}#ce(e,t,n){let r=t.flatMap(({liveEnd:e},t)=>e?[{index:t,liveEnd:e}]:[]);if(!r.length)return;let i=window.scrollY;try{for(let a=0;a<6;a+=1){let a=n(),o=!1;if(r.forEach(({index:n,liveEnd:r})=>{let s=this.#le(e,a,n,r,gn()??i),c=t[n].end;s&&s.mode===c.mode&&(Math.abs(nn(s)-nn(c))<=.5||(t[n]={...t[n],end:s},o=!0))}),!o)break}}finally{fn(i)}}#le(e,t,n,r,i){let a=e.flatMap((e,r)=>r<n&&e.kind===`scene`&&t[r]?[{after:e.trigger,height:t[r]}]:[]),o=()=>{let e=[...K].filter(e=>e!==this&&f(this.#e,e.#e)<0),t=[this,...e].flatMap(e=>e.#t.flatMap(e=>e.kind===`scene`&&e.padding?[{layer:e,padding:e.padding}]:[])),n=t.map(({padding:e})=>e.style.height);t.forEach(({padding:e})=>z(e,`0px`));let r=v(a);return()=>{r(),t.forEach(({layer:e,padding:t},r)=>{e.padding===t&&t.style.height===`0px`&&z(t,n[r])})}},s=()=>{},c=0,l={resolved:!1,ended:!1,outer:Q,scroll:Q?.scroll??i,suspend:e=>(e&&(l.resolved=!0),c+=1,c===1&&(s(),s=()=>{}),()=>{--c,c===0&&!l.ended&&(s=o())})};try{s=o(),Q=l;let e=r();return l.resolved?null:e}finally{l.ended=!0,Q=l.outer,s()}}refresh(){this.#u>0||E(this.#_)||this.#l||!this.#x||U.has(this)||window.scrollY===0||this.#ue()?this.#de(!1):_(pn(this.#_),()=>this.#de(!1))}#ue(){return ie(this.#_)&&!_n(this.#re(),new Set(this.#F()))}#de(e){if(this.#u>0&&!this.#o){if(!e){this.#f=!0;return}if(this.#d)return;this.#d=!0}this.#fe()}#fe(){if(this.#u>0&&(this.#f=!0),this.#l||!this.#x||U.has(this))return;let e=null,t=this.#p?this.#pe(this.#n):null;this.#p=!1,this.#u+=1;try{this.#ge(),this.#u===1&&this.#f&&!this.#l&&this.#x&&!U.has(this)&&this.#ge()}catch(t){e={error:t}}finally{--this.#u,this.#u===0&&(this.#d=!1,this.#f=!1)}try{Be(this.#_)}catch(e){Ue(),queueMicrotask(()=>{throw e})}if(!e&&t!==null&&this.#me(t),this.#y?.applyRamps(gn()??k(this.#_)?.read()),e)throw e.error}#pe(e){let t=this.#r,n=this.#s,r=t&&n&&t.changes!==on?(e=>_(E(this.#_)&&$>0?hn(this.#_):o.#ee(this,[e]),()=>i(e)))(n)-t.top:0,a=(k(this.#_)?.read()??q??window.scrollY)-r,s=/* @__PURE__ */ new Map;return e.forEach(e=>{e.kind===`scene`&&s.set(e.trigger,a>e.engagedEnd?1/0:At(a,this.#Ae([e])))}),{natural:a-At(a,this.#Ae(e))+r,consumed:s}}#me(e,t=this.#_){let n=this.#he(e),r=k(this.#_);r?r.write(n):q===null?E(t)||(Math.abs(window.scrollY-n)>=.5&&window.scrollTo({top:Math.round(n),behavior:`instant`}),oe(t)):Math.abs(q-n)>=.5&&(q=Math.round(n))}#he({natural:e,consumed:t}){let n=0,r=e;return this.#n.flatMap(e=>e.kind===`scene`?[e]:[]).sort((e,t)=>e.engagedStart-t.engagedStart).forEach(i=>{let a=i.engagedEnd-i.engagedStart,o=t.get(i.trigger);o===void 0?i.engagedStart<e+n-.05&&(r+=a):r+=Math.min(o,a),n+=a}),r}#ge(){!this.#a||Wt(this.#t)||this.#o&&!this.#z()?(this.#R(),this.#V()):this.#o&&this.#B(),this.#ve();try{this.#Y(),this.#X()}finally{this.#ye()}let e=this.#t.length||this.#v.length?a():0;this.#ne(e)}#_e(){return this.#t.filter(e=>e.kind===`cover`)}#ve(){this.#_e().forEach(e=>this.#i.get(e)?.())}#ye(){this.#_e().forEach(e=>{let t=this.#v.find(({trigger:t})=>t===e.cover);this.#i.set(e,te(t?.outer??e.cover))})}#be(e){this.#y?.sync(this.#Ae(),this.#s,t=>{let n=t.filter(t=>!e.has(t));return n.length&&_(this.#te(n),()=>n.forEach(t=>e.set(t,i(t)))),t.map(t=>e.get(t))})}#xe(e){let t=this.#y&&e.some(({kind:e})=>e===`scene`)?this.#y.targets():[];return new Map(t.map(e=>[e,i(e)]))}#Se(e,t){let n=Zt.filter(t=>t in e);if(n.length!==0)throw Error(`${t}: ${n.join(`, `)} ${n.length>1?`are`:`is`} not supported here; this module handles pinning and the scroll axis itself.`)}#Ce(e,t,n){if(rn(e,t))throw Error(n)}#we(e,t){if(e===this.#e)throw Error(`${t}: trigger ${r(e)} is the shared container itself. Point trigger at an element inside the container.`);if(!this.#e.contains(e))throw Error(`${t}: trigger ${r(e)} is outside the shared container. Point trigger at an element inside it, or use createStickyPin, which works on either side.`)}#Te(e,t){if(!e.contains(this.#e))return;let n=e===this.#e?`is the shared container itself`:`is an ancestor of the shared container`;throw Error(`${t}: trigger ${r(e)} ${n}. A pin makes trigger itself position:sticky inside a box holding the pin range, so the container and every layer's dwell padding would be pinned along with it. Pin an element that doesn't contain the container.`)}#Ee(e,t,n){if(this.#l)throw Error(`StickyScrollTrigger: cannot register a new layer after destroy() has been called.`);return this.#Ce(this.#t,e.trigger,`StickyScrollTrigger: ${r(e.trigger)} is already registered as a trigger for another layer. Each element can be used once per controller instance, across createStickyTrigger and createOverlapScroll: reusing one makes endTrigger resolution ambiguous.`),this.#Ce(this.#v,e.trigger,`StickyScrollTrigger: ${r(e.trigger)} is already registered as a pin trigger (createStickyPin). Using the same element as both a Scene/Cover trigger and a pin trigger wraps it twice and produces conflicting position:sticky behavior.`),this.#T(),this.#t.push(e),this.#o=!0,this.#u>0&&(this.#f=!0),{...n,trigger:e.trigger,start:()=>e.freezeStart,end:()=>e.freezeEnd||.001,invalidateOnRefresh:n.invalidateOnRefresh??!0,onKill:n=>{this.#W(n),this.#t.includes(e)&&(en(this.#t,e),this.#o=!0,this.#U(),this.#E()),t?.(n)},onRefreshInit:this.#G(n.onRefreshInit)}}createStickyTrigger({trigger:e,start:r=`0 0`,end:i=`100% 0`,endTrigger:a,onKill:o,...s}){this.#Se(s,`createStickyTrigger`),this.#D();let c=t(e,`createStickyTrigger`);this.#we(c,`createStickyTrigger`);let l=n(c,a,`createStickyTrigger`);return this.#Ee({kind:`scene`,trigger:c,endTrigger:l,container:null,wrapper:null,padding:null,start:Z(r),end:Z(i),freezeStart:0,freezeEnd:0,engagedStart:0,engagedEnd:0},o,s)}createOverlapScroll({trigger:e,cover:i,start:a=`bottom bottom`,end:o=null,endTrigger:s,onKill:c,...l}){this.#Se(l,`createOverlapScroll`),this.#D();let u=t(e,`createOverlapScroll`);this.#we(u,`createOverlapScroll`);let d=n(u,s,`createOverlapScroll`),f=i===void 0?u.nextElementSibling:t(i,`createOverlapScroll`);if(!(f instanceof HTMLElement))throw Error(`createOverlapScroll: cover element (trigger.nextElementSibling) not found for trigger ${r(u)}`);if(f.parentNode!==u.parentNode)throw Error(`createOverlapScroll: cover ${r(f)} must be a sibling of trigger `+r(u));let p={kind:`cover`,trigger:u,endTrigger:d,cover:f,wrapper:null,start:Z(a),end:o===null?null:Z(o),freezeStart:0,freezeEnd:0,engagedStart:0,engagedEnd:0},m=this.#Ee(p,e=>{this.#i.get(p)?.(),Kt(p),c?.(e)},l);return this.#i.set(p,te(f)),m}createStickyPin({trigger:e,start:i,top:a,endTrigger:o,end:s=`bottom top`,onKill:c,...l}){if(this.#Se(l,`createStickyPin`),this.#D(),this.#l)throw Error(`StickyScrollTrigger: cannot register a new pin after destroy() has been called.`);if(i!==void 0&&a!==void 0)throw Error(`StickyScrollTrigger: createStickyPin accepts either start or top, not both (top: 20 is start: 'top 20px'). Use top for a plain px distance from the viewport's top edge, start for anything else.`);let u=t(e,`createStickyPin`),d=n(u,o,`createStickyPin`);this.#Te(u,`createStickyPin`),this.#Ce(this.#v,u,`StickyScrollTrigger: ${r(u)} is already registered as a pin trigger.`),this.#Ce(this.#t,u,`StickyScrollTrigger: ${r(u)} is already registered as a trigger for another layer (createStickyTrigger/createOverlapScroll). Using the same element as both a Scene/Cover trigger and a pin trigger wraps it twice and produces conflicting position:sticky behavior.`);let f={trigger:u,savedPosition:m(u),outer:null,inner:null,start:Z(a===void 0?i??`top top`:Qt(a)),endTrigger:d,end:Z(s)};return this.#T(),this.#v.push(f),this.#u>0&&(this.#f=!0),{...l,trigger:u,onKill:e=>{this.#W(e),en(this.#v,f),this.#Z(f)&&this.#U(),this.#E(),c?.(e)},onRefreshInit:this.#G(l.onRefreshInit)}}resolveScrollPosition(e,t){let n=Q&&tn(Q,!0);try{return this.#De(e,t)}finally{n?.()}}#De(e,n){let r=t(e,`resolveScrollPosition`),i=B(n),o=a(),s=H(i);switch(s.kind){case`max`:return l(o)+bt(s.value,o);case`absolute`:return s.value;case`dwell`:case`clause`:return this.#Oe(r,s.value,o)}}#Oe(e,t,n){let r=V(t,d(e),n),a=_(this.#te([e]),()=>i(e))-r;return this.#ke(e,a)}#ke(e,t){return this.#e.contains(e)?t+kt(t,this.#Ae()):t}#Ae(e=this.#n){return e.flatMap(e=>e.kind===`scene`?[{freezeStart:e.engagedStart,freezeEnd:e.engagedEnd}]:[])}static getScrollTop(e,n){let r=t(e,`StickyScrollTrigger.getScrollTop`),a=n.find(e=>e.#e.contains(r));if(a)return a.resolveScrollPosition(r,`top top`);let s=n.map(e=>e.#$());try{return _(o.#ee(null,[r]),()=>i(r))}finally{s.forEach(e=>e())}}createResolvedTrigger({trigger:e,start:r=`top bottom`,end:i=`bottom top`,endTrigger:o,...s}){this.#Se(s,`createResolvedTrigger`),this.#D();let c=t(e,`createResolvedTrigger`),l=n(c,o,`createResolvedTrigger`);return{...s,trigger:c,start:()=>this.resolveScrollPosition(c,r),end:()=>{let e=B(i),t=H(e);return t.kind===`dwell`?this.resolveScrollPosition(c,r)+_t(t.value,a()):this.resolveScrollPosition(l,gt(r,e))}}}destroy(){this.#l||bn(()=>this.#N(),()=>this.#je())}#je(){this.#h!==null&&clearTimeout(this.#h),this.#h=null,this.#l=!0;let e=this.#m;this.#m=null,e?.(),this.#x&&this.#P(),this.#t.length=0,this.#v.forEach(e=>this.#Z(e)),this.#v.length=0,this.#_=null}};export{xn as default};
|
|
8
|
+
const e=e=>{let t=typeof e==`string`?document.querySelector(e):e;if(!t){let t=typeof e==`string`?`"${e}"`:String(e);throw Error(`StickyScrollTrigger: root ${t} not found`)}return t},t=(e,t)=>{let n=typeof e==`string`?document.querySelector(e):e;if(!n){let n=typeof e==`string`?`"${e}"`:String(e);throw Error(`${t}: element ${n} not found`)}return n},n=(e,n,r)=>n===void 0?e:t(n,r),r=e=>{let t=e.id?`#${e.id}`:``,n=e.classList.length>0?`.${Array.from(e.classList).join(`.`)}`:``;return`<${e.tagName.toLowerCase()}${t}${n}>`},i=e=>{let t=0,n=e;for(;n;){t+=n.offsetTop;let e=n.offsetParent;e&&(t+=e.clientTop),n=e}return t},a=()=>{let e=document.createElement(`div`);e.style.height=`100vh`,e.style.position=`absolute`,document.body.appendChild(e);let t=e.offsetHeight||window.innerHeight;return e.remove(),t},o=()=>document.documentElement.scrollHeight||document.body.scrollHeight,s=/* @__PURE__ */ new Set,c=()=>{s.forEach(e=>{e.isConnected||s.delete(e)});let e=[...s].map(e=>({inner:e,height:e.style.height}));e.forEach(({inner:e})=>{e.style.height=``});let t=o();return e.forEach(({inner:e,height:t})=>{e.style.height=t}),t},l=e=>Math.max(0,o()-e),u=(e,t)=>e===`none`||e===`hidden`?0:parseFloat(t),d=(e,t)=>{let n=t===`height`?e.offsetHeight:e.offsetWidth,r=getComputedStyle(e),i=parseFloat(r[t]);if(!Number.isFinite(i))return n;let[a,o]=t===`height`?[`Top`,`Bottom`]:[`Left`,`Right`],s=r.boxSizing===`border-box`?i:i+parseFloat(r[`padding${a}`])+parseFloat(r[`padding${o}`])+u(r[`border${a}Style`],r[`border${a}Width`])+u(r[`border${o}Style`],r[`border${o}Width`]);return n>0&&Math.abs(s-n)>=1?n:s},f=e=>d(e,`height`),p=e=>d(e,`width`),m=(e,t)=>f(e)+parseFloat(t.marginTop)+parseFloat(t.marginBottom),h=(e,t)=>{let n=e.compareDocumentPosition(t);return n&Node.DOCUMENT_POSITION_FOLLOWING?-1:n&Node.DOCUMENT_POSITION_PRECEDING?1:0},g=e=>{e.style.setProperty(`position`,`relative`,`important`),e.style.setProperty(`top`,`auto`,`important`),e.style.setProperty(`bottom`,`auto`,`important`)},_=(e,t)=>({value:e.style.getPropertyValue(t),priority:e.style.getPropertyPriority(t)}),v=(e,t,n)=>{e.style.setProperty(t,n.value,n.priority)},y=e=>({position:_(e,`position`),top:_(e,`top`),bottom:_(e,`bottom`)}),b=(e,t)=>{v(e,`position`,t.position),v(e,`top`,t.top),S(e,`bottom`,t.bottom,`auto`,`important`)},x=(e,t,n,r=``)=>(e.style.setProperty(t,n,r),e.style.getPropertyValue(t)),S=(e,t,n,r,i=``)=>{let{style:a}=e;return a.getPropertyValue(t)!==r||a.getPropertyPriority(t)!==i?!1:(v(e,t,n),!0)},C=e=>{let t=e.map(y);return e.forEach(g),()=>e.forEach((e,n)=>b(e,t[n]))},w=(e,t)=>{try{return t()}finally{e()}},ee=e=>{let t=e.map(({after:e,height:t})=>{let n=document.createElement(`div`);return n.style.cssText=`height:${t}px;margin:0;padding:0;border:0`,e.after(n),n});return()=>t.forEach(e=>e.remove())},T=()=>{let e=document.createElement(`div`);return e.style.setProperty(`transition`,`none`,`important`),e};let E=0;const te=()=>E>0,D=(e,t,n=null)=>{let r=e;E+=1;try{if(r.moveBefore&&e.isConnected&&t.isConnected)try{r.moveBefore(t,n);return}catch{}e.insertBefore(t,n)}finally{--E}},O=/* @__PURE__ */ new WeakSet,ne=(e,t)=>O.has(e)||t.has(e),re=(e,t)=>{let n=e.parentElement;for(;n&&ne(n,t);)n=n.parentElement;return n},ie=(e,t)=>{if(!ne(e,t))return e;for(let n of Array.from(e.children)){let e=ie(n,t);if(e)return e}return null},ae=(e,t)=>{for(let n=e;;){for(let e=n.nextElementSibling;e;e=e.nextElementSibling){let n=ie(e,t);if(n)return n}let e=n.parentElement;if(!e||!ne(e,t))return null;n=e}},oe=e=>{let t=e;for(;t.parentElement&&O.has(t.parentElement);)t=t.parentElement;return t},se=(e,t)=>{if(!e.parentNode)throw Error(`StickyScrollTrigger: ${r(e)} is not attached to the document`);let n=T(),i=T(),a=T();if([n,i,a].forEach(e=>O.add(e)),a.setAttribute(`aria-hidden`,`true`),a.style.pointerEvents=`none`,e.parentNode.insertBefore(n,e),n.appendChild(i),D(i,e),n.appendChild(a),t){let e=T();e.style.display=`flow-root`,O.add(e),i.appendChild(e)}return{container:n,wrapper:i,padding:a}},ce=e=>{let t=oe(e),n=t.parentNode;if(!n)throw Error(`createOverlapScroll: trigger ${r(e)} is not attached to the document`);let i=T();for(n.insertBefore(i,n.firstChild);i.nextSibling;){let e=i.nextSibling;if(D(i,e),e===t)break}return i},le=e=>{let t=e.parentNode;if(t){for(;e.firstChild;)D(t,e.firstChild,e);e.remove()}},ue=e=>{if(!e.parentNode)throw Error(`createStickyPin: trigger ${r(e)} is not attached to the document`);let t=T(),n=T();return t.style.display=`flow-root`,O.add(t),O.add(n),e.parentNode.insertBefore(t,e),t.appendChild(n),D(n,e),s.add(n),{outer:t,inner:n}},de=[`flexGrow`,`flexShrink`,`flexBasis`,`alignSelf`,`justifySelf`,`order`,`gridColumnStart`,`gridColumnEnd`,`gridRowStart`,`gridRowEnd`,`cssFloat`,`clear`,`verticalAlign`],fe=e=>{let t=e.parentElement;for(;t&&getComputedStyle(t).display===`contents`;)t=t.parentElement;return t},pe=[`left`,`right`,`inline-start`,`inline-end`],me=e=>e.display!==`none`&&e.display!==`contents`,he=e=>me(e)&&!e.display.startsWith(`inline`),ge=(e,t)=>{if(!me(t))return null;let n=fe(e),r=n?getComputedStyle(n).display:``;return r.includes(`flex`)?`flex`:r.includes(`grid`)?`grid`:pe.includes(t.cssFloat)?`float`:t.display.startsWith(`inline-`)?`inline`:null},_e=e=>e===`inline`?`inline-block`:`flow-root`,ve=[`width`,`max-width`,`height`,`max-height`,`min-height`,`padding-top`,`padding-right`,`padding-bottom`,`padding-left`,`margin-top`,`margin-right`,`margin-bottom`,`margin-left`],ye=[`height`,`max-height`,`min-height`],be=(e,t)=>t.map(t=>e.getPropertyValue(t.replace(/^m(ax|in)-/,``))),xe=`important`,Se=/* @__PURE__ */ new WeakMap,Ce=(e,t,n)=>{let r=t.map(t=>_(e,t));Se.set(e,{properties:t,authored:r,written:t.map((t,r)=>x(e,t,n[r],xe))})},we=e=>{let t=Se.get(e);if(t)return t.properties.forEach((n,r)=>{S(e,n,t.authored[r],t.written[r],xe)}),Se.delete(e),t},Te=e=>{let t=e.map(({trigger:e})=>we(e)),n=e.map(({trigger:t})=>e.filter(e=>e.trigger!==t&&e.trigger.contains(t))),r=e.map(()=>void 0);try{for(let t=Math.max(0,...n.map(({length:e})=>e));t>=0;t--){let i=e.flatMap((e,r)=>n[r].length===t?[r]:[]),a=new Set(i.flatMap(e=>n[e]));Ee(i.map(t=>e[t]),[...a]).forEach((e,t)=>{r[i[t]]=e})}return r}catch(n){throw e.forEach(({trigger:e},n)=>{let r=t[n];we(e),r&&Ce(e,r.properties,r.written)}),n}},Ee=(e,t)=>{let n=e.map(({trigger:e})=>getComputedStyle(e)),r=e.map(({outer:e},t)=>ge(e,n[t])),i=e.map(({trigger:e})=>e.getClientRects().length>0),a=n.map((e,t)=>de.map(n=>r[t]||n===`clear`&&he(e)?e[n]:``)),o=e.flatMap((e,t)=>i[t]?[{...e,index:t,layout:r[t]}]:[]),s=t.map(({outer:e,inner:t})=>[e.style.display,t.style.display]);e.forEach(({outer:e},t)=>{e.style.width=``,de.forEach((n,r)=>{e.style[n]=a[t][r]}),e.style.display=i[t]?`contents`:_e(r[t])}),[...o,...t].forEach(({outer:e,inner:t})=>{e.style.display=`contents`,t.style.display=`contents`});let c;try{c=o.map(({trigger:e,index:t,layout:r})=>{let i=n[t];return r?{item:{width:r===`grid`?void 0:p(e)+parseFloat(i.marginLeft)+parseFloat(i.marginRight),height:m(e,i)},box:be(i,ve)}:{box:be(i,ye)}})}finally{o.forEach(({outer:e,inner:t,layout:n})=>{e.style.display=_e(n),t.style.display=``}),t.forEach(({outer:e,inner:t},n)=>{[e.style.display,t.style.display]=s[n]})}let l=c.map(({box:e})=>e.every(e=>e.endsWith(`px`))),u=De(o,c,l,n),d=e.map(()=>void 0);return o.forEach(({outer:e,trigger:t,index:n,layout:r},i)=>{let{item:a,box:o}=c[i];if(!a){l[i]&&u.has(i)&&Ce(t,ye,o);return}let{width:s,height:f}=a;Number.isFinite(f)&&(s===void 0||Number.isFinite(s))&&(r===`flex`&&(e.style.flex=`0 0 auto`),s!==void 0&&(e.style.width=`${s}px`),d[n]=f,l[i]&&Ce(t,ve,o))}),d},De=(e,t,n,r)=>{let i=e.flatMap((e,r)=>!t[r].item&&n[r]?[{...e,i:r}]:[]),a=new Set(Oe(i,()=>`123456px`,t)),o=i.filter(({index:e,i:t})=>!a.has(t)&&r[e].maxHeight.includes(`%`));return Oe(o,({i:e})=>t[e].box[0],t).forEach(e=>a.add(e)),a},Oe=(e,t,n)=>{let r=e.map(({outer:e,inner:t})=>[e.style.height,t.style.height]),i=e.map(({outer:e})=>getComputedStyle(e).height);e.forEach((e,n)=>{e.outer.style.height=i[n],e.inner.style.height=t(e)});try{return e.flatMap(({trigger:e,i:t})=>getComputedStyle(e).height===n[t].box[0]?[]:[t])}finally{e.forEach(({outer:e,inner:t},n)=>{[e.style.height,t.style.height]=r[n]})}},ke=(e,t,n)=>{let r=e.parentNode;b(t,n),we(t),r&&D(r,t,e),e.firstElementChild instanceof HTMLElement&&s.delete(e.firstElementChild),e.remove()},Ae={position:`relative`,"z-index":`1`},je=/* @__PURE__ */ new WeakMap,Me=e=>{let t=[];for(let n=e;n;n=n.nextElementSibling){if(!(n instanceof HTMLElement))continue;let e=n,r=je.get(e);if(r)r.count+=1;else{let t=getComputedStyle(e),n=[];t.position===`static`&&n.push(`position`),t.zIndex===`auto`&&n.push(`z-index`);let r=n.map(t=>({property:t,authored:_(e,t),written:x(e,t,Ae[t])}));je.set(e,{count:1,applied:r})}t.push(e)}return()=>{t.forEach(e=>{let t=je.get(e);t&&(--t.count,!(t.count>0)&&(t.applied.forEach(({property:t,authored:n,written:r})=>{S(e,t,n,r)}),je.delete(e)))}),t.length=0}},Ne=e=>e.constructor,k=e=>e?.isRefreshing===!0,Pe=e=>!!e?.isScrolling?.(),Fe=e=>!!(e?.isScrolling?.()||e?.isUpdating===!0),A=(e,t,n)=>{e?.addEventListener?.(t,n)},j=(e,t,n)=>{e?.removeEventListener?.(t,n)},Ie=e=>{typeof e?.refresh==`function`&&e.refresh()},M=(e,t=!1)=>{if(!e||!k(e))return null;let n=e.getScrollFunc?.(window);if(!(n&&typeof n.rec==`number`&&(t||n.rec)))return null;let r=n;return{read:()=>r.rec,write:e=>{r.rec=e}}},Le=e=>{let t=e?.getScrollFunc?.(window);if(typeof t!=`function`)return;let n=t();(typeof n!=`number`||Math.abs(n-window.scrollY)>=.5)&&t(window.scrollY)},Re=(e,t)=>({render:n=>{t?.render?.(n),e()}}),ze=()=>typeof CSS<`u`&&typeof CSS.supports==`function`&&CSS.supports(`font`,`-apple-system-body`)||typeof navigator<`u`&&navigator.vendor===`Apple Computer, Inc.`&&!/\bjsdom\//.test(navigator.userAgent),Be=e=>{let t=e.filter(([e,t])=>t>e).sort((e,t)=>e[0]-t[0]),n=[];return t.forEach(([e,t])=>{let r=n.at(-1);r&&e<=r[1]?r[1]=Math.max(r[1],t):n.push([e,t])}),n},Ve=(e,t,n)=>{let r=t;for(let[t,i]of e)if(n?t<=r:t<r)r+=i-t;else break;return r},He=e=>[e.transform,e.translate,e.scale,e.rotate].some(e=>e!==void 0&&e!==``&&e!==`none`),Ue=(e,t)=>{if(!e)return!1;let n=t.get(e);if(n!==void 0)return n;let r=He(getComputedStyle(e))||Ue(e.parentElement,t);return t.set(e,r),r},We=e=>![e.overflowX,e.overflowY].every(e=>e===`visible`||e===`clip`),Ge=()=>We(getComputedStyle(document.documentElement))&&We(getComputedStyle(document.body)),Ke=(e,t)=>{let n=e.parentElement;if(!n||n===document.body||n===document.documentElement)return!1;let r=t.get(n);if(r!==void 0)return r;let i=getComputedStyle(n),a=i.position===`fixed`||We(i)||Ke(n,t);return t.set(n,a),a},qe=(e,t)=>{let n=/* @__PURE__ */ new Map,r=e=>{if(!e)return 0;let i=n.get(e);if(i!==void 0)return i;let a=(t.has(e)||getComputedStyle(e).position===`sticky`?1:0)+r(e.parentElement);return n.set(e,a),a},i=/* @__PURE__ */ new Map,a=0;for(let t of e)t.isConnected&&!Ke(t,i)&&(a=Math.max(a,1+r(t.parentElement)));return a},Je=/^-?(?:\d+\.?\d*|\.\d+)(?:e[+-]?\d+)?(px|%)$/i,N=/* @__PURE__ */ new Set;let P=[],Ye=0,Xe=!1,F=null,I=`idle`,Ze=!1,Qe=null;const L=/* @__PURE__ */ new Set,$e=()=>Array.from(L).some(e=>k(e)),et=(e,t)=>e.demotable?t<e.lo-Ye?`before`:t>e.hi+Ye&&!e.holdsAfter?`after`:`in`:`in`,R=(e,t=!1)=>{let{style:n}=e.el,r=e.state!==`in`,i=t&&n.position===`static`||r&&n.position===`relative`;i&&(n.position=e.position),r&&i&&n.top===e.demotedTop&&(n.top=e.top),r&&e.zIndexAuto&&n.zIndex===`0`&&(n.zIndex=e.zIndex),r&&e.willChangeAuto&&n.willChange===`opacity`&&(n.willChange=e.willChange),e.state=`in`},tt=(e,t)=>{if(e.state===t)return;if(t===`in`){R(e);return}let{style:n}=e.el;n.position=`relative`,n.top=`${t===`before`?0:e.travel}px`,e.demotedTop=n.top,e.zIndexAuto&&(n.zIndex=`0`),e.willChangeAuto&&(n.willChange=`opacity`),e.state=t},z=e=>{P.forEach(t=>tt(t,et(t,e)))},nt=()=>z(window.scrollY),rt=e=>{e!==Xe&&(Xe=e,e?window.addEventListener(`scroll`,nt,{passive:!0}):window.removeEventListener(`scroll`,nt))},B=()=>{P.forEach(e=>R(e)),P=[],rt(!1)},it=()=>{let e=F;I===`measuring`&&e!==null&&(I=`restored`,P.length&&z(e))},at=()=>{I=`idle`,F=null,Ze=!1},ot=()=>{try{vt(null)}catch(e){B(),queueMicrotask(()=>{throw e})}},st=()=>{let e=I!==`idle`;at(),e&&ht().length&&ot()},ct=()=>{let e=Array.from(L).find(e=>k(e));return M(e)?.read()??window.scrollY},lt=()=>(I===`idle`&&(I=`measuring`,F=ct(),queueMicrotask(st),P.length&&z(0)),Re(it)),ut=e=>{L.has(e)||(k(e)&&(Ze=!0),L.add(e),A(e,`refresh`,st),A(e,`refreshInit`,lt))},dt=()=>{L.size&&queueMicrotask(()=>{ht().length||(L.forEach(e=>{j(e,`refresh`,st),j(e,`refreshInit`,lt)}),L.clear())})},ft=e=>{let t=/* @__PURE__ */ new Map,n=e=>e.isConnected&&getComputedStyle(e).position===`sticky`&&!Ke(e,t);if(Qe)return Array.from(/* @__PURE__ */ new Set([...Qe,...P.map(e=>e.el),...e])).filter(n);let r=Array.from(document.querySelectorAll(`*`)).filter(n);return Qe=r,queueMicrotask(()=>{Qe=null}),r},pt=(e,t)=>{let n=P.flatMap(n=>{let r=n.demotable?[Math.max(0,n.lo-e),Math.min(t,n.hi+(n.holdsAfter?1/0:e))]:[0,t];return r[1]>=r[0]?[{record:n,start:r[0],end:r[1]}]:[]}),r=0;return(/* @__PURE__ */ new Set([0,...n.filter(({record:e})=>e.demotable).map(({start:e})=>e)])).forEach(e=>{let t=new Set(n.filter(({start:t,end:n})=>t<=e&&e<=n).map(({record:e})=>e));t.forEach(e=>{r=Math.max(r,1+e.ancestors.filter(e=>t.has(e)).length)})}),r},mt=(e,t)=>{let n=13,r=Math.floor(e/25);if(r<n||pt(n*25,t)>4)return 325;for(;n<r;){let e=Math.ceil((n+r)/2);pt(e*25,t)<=4?n=e:r=e-1}return n*25},ht=()=>{let e=[];return N.forEach(t=>{let n=t.deref();if(!n){N.delete(t);return}let r=n.ownedElements();r.some(e=>e.isConnected)&&e.push({client:n,owned:r,demotable:n.demotableElements()})}),e},gt=(e,t,n)=>{let r=window.scrollY,i=document.documentElement.clientHeight||window.innerHeight,a=/* @__PURE__ */ new Map,s=o();return e.forEach(e=>{let{el:o}=e,s=o.getBoundingClientRect(),c=getComputedStyle(o),l=o.parentElement,u=s.bottom+r;if(l){let t=getComputedStyle(l);u=l.getBoundingClientRect().bottom+r-parseFloat(t.borderBottomWidth)-parseFloat(t.paddingBottom),(t.display===`contents`||t.display===`inline`)&&n.add(e)}if(e.naturalTop=s.top+r,e.travel=Math.max(0,u-(e.naturalTop+s.height+parseFloat(c.marginBottom))),e.overflowBottom=e.naturalTop+o.clientTop+o.scrollHeight,(c.position!==`static`||Ue(o,a))&&n.add(e),(c.bottom!==`auto`||c.left!==`auto`||c.right!==`auto`)&&n.add(e),t.has(o)&&(!c.top.endsWith(`px`)||Math.abs(parseFloat(c.top)-parseFloat(o.style.top))>.01)&&n.add(e),!t.has(o)&&c.top===`auto`)e.stickyTop=0,e.travel=0;else if(!t.has(o)){let t=Je.exec(c.top)?.[1];t?e.stickyTop=t===`%`?parseFloat(c.top)*i/100:parseFloat(c.top):n.add(e)}}),{scroll:r,viewportHeight:i,documentHeight:s}},_t=()=>{B(),at(),dt()},vt=e=>{let t=ht();if(!t.length){_t();return}if(e&&ut(e),$e()||at(),!L.size||Ge()||!t.some(({demotable:e})=>e.length)){B();return}let n=/* @__PURE__ */ new Map;t.forEach(({client:e,owned:t})=>{t.forEach(t=>n.set(t,e))});let r=t.every(({client:e})=>e.mode===`auto`),i=new Set(P.filter(e=>e.state!==`in`).map(e=>e.el));if(r&&qe(n.keys(),i)<7){B();return}let a=ft(n.keys()),o=new Set(a),s=P.filter(e=>e.state!==`in`&&!o.has(e.el));s.filter(e=>!e.el.isConnected).forEach(e=>R(e));let c=s.filter(e=>e.el.isConnected),l=new Map(P.map(e=>[e.el,e])),u=[...a.map(e=>{let t=getComputedStyle(e),n=l.get(e);return n&&n.state!==`in`?{...n,demotable:!1,position:e.style.position,top:e.style.top,stickyTop:parseFloat(e.style.top)||0,ancestors:[],state:`before`}:{el:e,demotable:!1,position:e.style.position,top:e.style.top,zIndex:e.style.zIndex,willChange:e.style.willChange,zIndexAuto:t.zIndex===`auto`,willChangeAuto:t.willChange===`auto`,stickyTop:parseFloat(e.style.top)||0,naturalTop:0,travel:0,ancestors:[],lo:0,hi:0,overflowBottom:0,holdsAfter:!1,state:`in`,demotedTop:``}}),...c];u.sort((e,t)=>h(e.el,t.el)),u.forEach((e,t)=>{e.ancestors=u.slice(0,t).filter(t=>t.el.contains(e.el))});let d=/* @__PURE__ */ new Set;u.forEach(e=>{n.has(e.el)&&e.ancestors.forEach(e=>d.add(e))});let f=u.filter(e=>n.has(e.el)||d.has(e)||e.state!==`in`||e.ancestors.some(e=>n.has(e.el))),p=new Set(f);f.forEach(e=>{e.ancestors=e.ancestors.filter(e=>p.has(e))});let m=/* @__PURE__ */ new Map;f.forEach(e=>{let t=n.get(e.el);t&&m.set(t,Math.max(m.get(t)??0,e.ancestors.length+1))});let g=new Set(t.map(({client:e})=>e).filter(e=>e.mode===`always`||(m.get(e)??0)>=7)),y=new Set(t.flatMap(e=>e.demotable));if(f.forEach(e=>{let t=n.get(e.el);e.demotable=t!==void 0&&g.has(t)&&y.has(e.el)}),P=f,!f.some(e=>e.demotable)){B();return}let b=f.filter(e=>n.has(e.el)||d.has(e)||e.state!==`in`),x=new Map(b.filter(e=>!n.has(e.el)&&e.state===`in`).map(({el:e})=>[e,e.hasAttribute(`style`)?_(e,`position`):null])),S=()=>b.forEach(e=>{if(!x.has(e.el)){R(e,!0);return}let t=x.get(e.el);t?v(e.el,`position`,t):e.el.removeAttribute(`style`)});b.forEach(({el:e})=>{e.style.position=`static`});let C=/* @__PURE__ */ new Set,w;try{w=gt(b,n,C)}finally{S()}let{scroll:ee,viewportHeight:T,documentHeight:E}=w,te=Math.max(0,E-T);f.forEach(e=>{let t=Be(e.ancestors.map(e=>[e.lo,e.hi])),n=e.naturalTop-e.stickyTop;e.lo=Ve(t,n,!0),e.hi=Ve(t,n+e.travel,!1),(C.has(e)||e.ancestors.some(e=>C.has(e)))&&(e.demotable=!1);let r=e.ancestors.filter(e=>e.demotable&&!e.holdsAfter).reduce((e,t)=>e+t.travel,0);e.holdsAfter=e.overflowBottom+e.travel+r>E+1}),Ye=mt(T,te),z(I===`measuring`?0:(I===`restored`?F:null)??ee),rt(!0)},yt=()=>!Ze||!$e()?null:(lt(),it),bt=e=>{I!==`idle`&&(F=e)},xt=B,St=()=>{P.forEach(e=>{e.state===`after`&&tt(e,`before`)})},Ct=()=>new Set(P.filter(e=>e.state===`after`&&e.travel>0).map(e=>e.el)),wt=e=>{P.length&&z(I===`measuring`?0:e)},Tt=e=>{let t=new Set(e);P=P.filter(e=>!t.has(e.el)||(R(e),!1))},Et=e=>{N.add(new WeakRef(e))};let Dt=!1;const Ot=()=>{Dt||(Dt=!0,queueMicrotask(()=>{Dt=!1,ot()}))},kt=e=>{N.forEach(t=>{t.deref()===e&&(N.delete(t),Tt(e.ownedElements()))}),ht().length?Ot():_t()},At=(e,t)=>{e.style.position=`sticky`,e.style.top=`${t}px`},jt=(e,t)=>{b(e,t)},V=(e,t)=>{e.style.height=t},Mt=(e,t)=>{e.style.cssText=t},Nt=(e,t)=>{e.style.position=``,e.style.top=``,t&&(t.style.height=`0px`)},Pt=e=>{e.style.position=``,e.style.top=``},Ft=e=>{e.style.height=``};let H=null;const It=()=>H,Lt=e=>{H=e};let U=null,Rt=-1/0;const zt=e=>{U=e?window.scrollY:null,Rt=performance.now()},Bt=()=>(U!==null&&(Math.abs(window.scrollY-U)>=.5||performance.now()-Rt>=500)&&(U=null),U!==null),Vt=e=>(k(e)?Pe(e):Fe(e))&&!Bt(),W=e=>Pe(e)&&!Bt(),Ht=e=>{Math.abs(window.scrollY-e)>=.5&&window.scrollTo({top:e,behavior:`instant`})},Ut=e=>{if(H!==null)return Ht(0),St(),()=>{};let t=!W(e);return H=window.scrollY,St(),window.scrollTo({top:0,behavior:`instant`}),()=>{let n=H??0;H=null,window.scrollTo({top:n,behavior:`instant`}),zt(t),Le(e),wt(window.scrollY)}};let G=!1,Wt=0;const Gt=e=>{if(G){let t=window.scrollY;if(t===0)return()=>{};let n=!W(e);return window.scrollTo({top:0,behavior:`instant`}),()=>{window.scrollTo({top:t,behavior:`instant`}),zt(n)}}let t=M(e,!0);if(!t||t.read()===0)return()=>{};let n=!W(e);return Wt=t.read(),St(),window.scrollTo({top:0,behavior:`instant`}),G=!0,()=>{G=!1,window.scrollTo({top:t.read(),behavior:`instant`}),zt(n)}},Kt=()=>G,qt=()=>H??(G?Wt:null),Jt=(e,t)=>{let n=/* @__PURE__ */ new Set,r=Ct();return e.some(e=>{for(let i=e;i&&!n.has(i)&&i!==document.body&&i!==document.documentElement;i=i.parentElement)if(n.add(i),!t.has(i)&&(r.has(i)||getComputedStyle(i).position===`sticky`))return!0;return!1})},Yt=()=>{(G||H!==null)&&Ht(0),H!==null&&St()},K=e=>typeof e==`function`?()=>{try{return e()}finally{Yt()}}:e,Xt=(e,t)=>{let n=[];for(let r=e;r;r=r.outer)n.unshift(r.suspend(t&&r===e));return()=>n.forEach(e=>e())};let q=null,J=0;const Zt=e=>{J+=1;try{return e()}finally{--J}},Qt=()=>J>0,$t=e=>{let t=q,n=qt();if(n!==null&&!t){let t=M(e,!0);t&&Math.abs(t.read()-n)>=.5&&(t.write(n),bt(n))}if(!t)return;let r=Xt(t,!1),i=M(e,!0);if(i&&Math.abs(i.read()-t.scroll)>=.5){Ht(Math.round(t.scroll)),Le(e);let n=window.scrollY>=Math.round(t.scroll)-.5,r=qt()!==null&&n?t.scroll:window.scrollY;i.write(r),bt(r)}let a=J-1,o=!0;q=null;let s=()=>{!o||J>a||(o=!1,r(),t.ended||(q=t))};A(e,`refresh`,s),queueMicrotask(()=>j(e,`refresh`,s))},en=(e,t,n)=>{let r=()=>{},i=0,a={resolved:!1,ended:!1,outer:q,scroll:q?.scroll??t,suspend:t=>(t&&(a.resolved=!0),i+=1,i===1&&(r(),r=()=>{}),()=>{--i,i===0&&!a.ended&&(r=e())})};try{r=e(),q=a;let t=n();return a.resolved?null:t}finally{a.ended=!0,q=a.outer,r()}},tn=e=>{let t=q&&Xt(q,!0);try{return e()}finally{t?.()}},Y=e=>typeof e==`function`?e():e,nn={top:0,center:.5,bottom:1},rn=(e,t,n,r)=>{let i=n===`%`?parseFloat(t)/100*r:parseFloat(t);return e?.startsWith(`-`)?-i:i},an=/^(top|center|bottom|[+-]?(?:\d+(?:\.\d*)?|\.\d+))?(%|px)?(?:([+-]=?)(\d+(?:\.\d*)?|\.\d+)(%|px)?)?$/,on=(e,t)=>{let n=an.exec(e);if(!n||!n[1]&&!n[3])throw vn.test(e)?Error(`StickyScrollTrigger: unsupported position clause "${e}": 'max' is GSAP's end-only keyword for the scroller's maximum scroll position.`):Error(`StickyScrollTrigger: unsupported position clause "${e}"`);let[,r,i,a,o,s]=n;if(r!==void 0&&a&&!a.includes(`=`)){let t=`${r}${i??``}${a}=${o}${s??``}`;throw Error(`StickyScrollTrigger: unsupported position clause "${e}": a signed offset needs an explicit '=' when it follows a keyword or number (GSAP needs it to tell "${r}" from the offset). Did you mean "${t}"?`)}let c=r!==void 0&&r in nn,l=i===`%`;return{fraction:c?nn[r]:l?parseFloat(r)/100:0,offsetPx:(!c&&!l&&r!==void 0?parseFloat(r):0)+(a?rn(a,o,s,t):0)}},sn=e=>typeof e==`number`||e.trim()!==``&&!Number.isNaN(Number(e)),cn=e=>typeof e==`number`?e:Number(e),ln=e=>{if(!e.startsWith(`clamp(`))return;let t=e.slice(6).replace(/\)$/,``).trim();throw Error(`StickyScrollTrigger: unsupported position clause "${e}": GSAP's clamp() wrapper isn't supported here.`+(t?` Did you mean "${t}"?`:``))},un=e=>{let t=e.trim();return ln(t),t.split(/\s+/)},dn=(e,t)=>{let{fraction:n,offsetPx:r}=on(e,t);return t*n+r},fn=(e,t)=>dn(un(e)[0],t),pn=e=>fn(e,1)-fn(e,0),X=(e,t,n)=>{let[r,i=`top`]=un(e);return dn(i,n)-dn(r,t)},mn=/^\+=(\d+(?:\.\d*)?|\.\d+)(%|px)?$/,hn=e=>typeof e==`string`&&mn.test(e.trim()),gn=(e,t)=>{if(typeof t!=`string`)return t;let n=t.trim();if(!n.startsWith(`+=`)||!/\s/.test(n))return t;let r=Y(e);if(typeof r!=`string`)return t;let[i]=un(r);try{on(i,0)}catch(e){if(!sn(r))throw e;return t}if(on(n.split(/\s+/)[0],0),i.includes(`=`))throw Error(`StickyScrollTrigger: end "${t}" can't be resolved against start "${r}": GSAP reads an end that starts with '+=' and holds a space by prefixing it with the start clause's element token, and "${i}" carries an offset of its own, which GSAP resolves by discarding the end's. Give end a complete position clause instead, such as 'top+=100 bottom'.`);return i+n},_n=(e,t)=>{let n=mn.exec(String(e).trim());if(!n)throw Error(`StickyScrollTrigger: unsupported end format "${e}"`);let[,r,i]=n;return rn(void 0,r,i,t)},vn=/^max(?:([+-]=)(\d+(?:\.\d*)?|\.\d+)(%|px)?)?$/,yn=e=>typeof e==`string`&&vn.test(e.trim()),bn=(e,t)=>{let n=vn.exec(e.trim());if(!n)throw Error(`StickyScrollTrigger: unsupported max-position format "${e}"`);let[,r,i,a]=n;return r?rn(r,i,a,t):0},Z=e=>typeof e==`number`?{kind:`absolute`,value:e}:hn(e)?{kind:`dwell`,value:e}:yn(e)?{kind:`max`,value:e}:sn(e)?{kind:`absolute`,value:cn(e)}:{kind:`clause`,value:e},xn=(e,t,n,r,i)=>e[t].triggerEnclosedBy.some(a=>a!==t&&e[a].kind===`scene`&&i.isBefore(a,t)&&!(n.includes(a)&&a!==r)),Sn=(e,t)=>e.flatMap(({triggerEnclosedBy:e},n)=>n!==t&&e.includes(t)?[n]:[]),Cn=({measurements:e,world:t,order:n,ownIndex:r},i,a,o,s)=>{let{enclosedBy:c,anchorElement:l}=o,u=e[i];return c.includes(i)?+((u.start.mode===`absolute`?t.unpaddedStart(i,r,a):u.triggerTop-u.start.anchorOffset)<s-.05):n&&xn(e,i,c,l,n)?0:o.nests.includes(i)?o.fraction:+(u.triggerTop+u.triggerHeight<=o.top+.05)},wn=(e,t,n,r,i)=>t.reduce((t,{index:a,freezeStart:o,freezeEnd:s})=>{let{ownIndex:c,order:l}=e;if(a===c||l&&l.isBefore(c,a))return t;let u=Cn(e,a,o,n,r);return u===0?t:(i?.add(a),t+u*(s-o))},0),Tn=(e,t,n)=>{let r=t=>{let{start:n,triggerTop:r}=e[t];return n.mode===`clause`?r-n.anchorOffset:null},i=e.flatMap(({kind:e},t)=>e===`scene`?[t]:[]),a=i.filter(e=>r(e)!==null).sort((e,t)=>{let n=r(e)-r(t);return Math.abs(n)<=.05?e-t:n}),o=i.flatMap(t=>{let{start:n}=e[t];return n.mode===`absolute`?[{k:t,value:n.value}]:[]}).sort((e,t)=>e.value-t.value),s=0,c=0;for(let e of a){let i=r(e);for(;c<o.length&&o[c].value<i+s+.05;)s+=n(o[c].k),c+=1;if(e===t)return i+s;s+=n(e)}throw Error(`StickyScrollTrigger: internal error: clauseFreezeStart was given a layer without a clause start.`)},En=(e,{viewportHeight:t,measureLiveEndTriggerTop:n},r,i,a,o,s=!1)=>{let c=[],l=()=>e.flatMap((e,t)=>{if(e.kind!==`scene`)return[];let n=s?null:c[t];if(n)return[{index:t,freezeStart:n.freezeStart,freezeEnd:n.freezeEnd}];let i=r?.freezeStarts[t]??null,a=r?.paddings[t]??null;return i===null||a===null?[]:[{index:t,freezeStart:i,freezeEnd:i+a}]}),u=e=>(s?null:c[e]?.paddingHeight)??r?.paddings[e]??0,d=[],f=e.map((o,s)=>{if(c[s]=null,o.kind===`cover`)return null;let f={index:s,counted:/* @__PURE__ */ new Set,runs:[]};d.push(f);let p={measurements:e,world:a,order:i,ownIndex:s},m=(e,t)=>{let n=(n,r)=>wn(p,n,e,t,r);return f.runs.push(e=>n(e,f.counted)),n(l())},{start:h}=o,g=h.mode===`absolute`?h.value:r?.freezeStarts[s]??Tn(e,s,u),_=t=>i!==null&&(i.isBefore(s,t)||xn(e,t,o.triggerEnclosedBy,s,i)),v=(t,n)=>{let r=Sn(e,s),i=pn(t.clause)-(h.mode===`clause`?h.elementFraction:0),a=e.reduce((e,t,n)=>i===0||t.kind!==`scene`||!r.includes(n)||_(n)?e:(f.counted.add(n),e+i*u(n)),0);if(h.mode===`clause`)return g+Math.max(0,h.anchorOffset-n+a);let c=e.reduce((e,t,n)=>n===s||t.kind!==`scene`||r.includes(n)||t.triggerTop+t.triggerHeight>o.triggerTop+.05||_(n)?e:(f.counted.add(n),e+u(n)),0);return Math.max(g,o.triggerTop-n+c+a)},y=(t,r)=>{let i;if(t.measureLive)i=n(s);else{let n=o.endTrigger.index===null?t.rawTop:e[o.endTrigger.index].triggerTop;if(n===null)i=0;else{let e={top:n,fraction:pn(t.clause),nests:o.endTrigger.nests,enclosedBy:o.endTrigger.enclosedBy,anchorElement:o.endTrigger.index};i=n+m(e,n-r)}}let a;return a=h.mode===`absolute`?h.value:o.triggerTop-h.anchorOffset+m({top:o.triggerTop,fraction:h.elementFraction,nests:Sn(e,s),enclosedBy:o.triggerEnclosedBy,anchorElement:s},o.triggerTop-h.anchorOffset),g+Math.max(0,i-r-a)},b;switch(o.end.mode){case`dwell`:b=g+o.end.distancePx;break;case`absolute`:{let e=a.absoluteEndLength(s);b=e===null?Math.max(g,o.end.value):g+e;break}case`auto`:case`max`:throw Error(`StickyScrollTrigger: internal error: a Scene layer reached '${o.end.mode}' end mode, which only a cover layer can have.`);case`clause`:{let e=X(o.end.clause,o.endTrigger.height,t);b=o.endTrigger.isSelf?v(o.end,e):y(o.end,e);break}}let x={freezeStart:g,freezeEnd:b,paddingHeight:Math.max(0,b-g)};return c[s]=x,x});if(o){let e=l();d.forEach(({index:t,counted:n,runs:r})=>{r.forEach(t=>t(e)),o(t,n)})}return f},Dn=(e,t,n,{viewportHeight:r,documentMaxScroll:i,measureLiveEndTriggerTop:a})=>{let o=e[t];if(o.start.mode!==`clause`)throw Error(`StickyScrollTrigger: internal error: a cover layer measurement carries an absolute start, which resolveStartSpec should have already rejected.`);let s=e=>e+kn(e,n),c=o.triggerTop-o.start.anchorOffset,l=c+kn(c,n,{countTies:!0}),u;switch(o.end.mode){case`auto`:u=s(o.coverTop);break;case`dwell`:u=l+o.end.distancePx;break;case`absolute`:u=o.end.value;break;case`max`:u=i+o.end.offsetPx;break;case`clause`:{let n=X(o.end.clause,o.endTrigger.height,r);u=o.end.measureLive?a(t)-n:s((o.endTrigger.isSelf?o.triggerTop:o.endTrigger.index===null?o.end.rawTop??0:e[o.endTrigger.index].triggerTop)-n);break}}return{freezeStart:l,freezeEnd:Math.max(l,u),engagedStart:l,engagedEnd:Math.max(l,u),stickyTop:o.start.anchorOffset-(o.triggerTop-o.wrapperTop),paddingHeight:null}},On=.05,kn=(e,t,{countTies:n=!1}={})=>{let r=n?-.05:On,i=0,a=0;return[...t].sort((e,t)=>e.freezeStart-t.freezeStart).forEach(({freezeStart:t,freezeEnd:n})=>{t<e+i-r&&(a+=n-t),i+=n-t}),a},An=(e,t)=>t.reduce((t,{freezeStart:n,freezeEnd:r})=>t+Math.min(Math.max(e-n,0),r-n),0),jn=e=>{let t=e.map(()=>-1),n=e.map(()=>0),r=e.map(()=>-1),i=[],a=0,o=0,s=c=>{t[c]=a,n[c]=a,a+=1,i.push(c);for(let i of e[c])t[i]===-1?(s(i),n[c]=Math.min(n[c],n[i])):r[i]===-1&&(n[c]=Math.min(n[c],t[i]));if(n[c]===t[c]){let e;do e=i.pop(),r[e]=o;while(e!==c);o+=1}};return e.forEach((e,n)=>{t[n]===-1&&s(n)}),r},Mn=(e,t)=>{let n=jn(e.map(({triggerEnclosedBy:n},r)=>[...t[r],...n.filter(t=>t!==r&&e[t].kind===`scene`)])),r=[];return e.map((e,t)=>t).sort((e,t)=>n[e]-n[t]||e-t).forEach((e,t)=>{r[e]=t}),{isBefore:(e,t)=>r[e]<r[t]}},Nn=(e,t)=>{let n=jn(t);return new Set(e.map(e=>n[e])).size<e.length},Pn=(e,t,n)=>{let r=e.map(()=>[]);return n.forEach((n,i)=>{let a=e[i],o=(a.end.mode===`clause`&&!a.endTrigger.isSelf?a.endTrigger.enclosedBy:a.triggerEnclosedBy).filter(e=>e!==a.endTrigger.index);n.forEach(n=>{t[n]<=.05||(r[i].push(n),e[n].triggerEnclosedBy.forEach(t=>{t!==n&&t!==i&&e[t].kind===`scene`&&!o.includes(t)&&r[t].push(n)}))})}),r},Fn=(e,t,n,r)=>{let i=new Set(t),a=[],o=[],s=0,c=-1/0;for(;i.size;){let t=-1,l=0,u=!1,d=0;for(let n of i){let{start:r,triggerTop:i}=e[n],a=r.mode===`absolute`,o=r.mode===`clause`?i-r.anchorOffset:0,c=r.mode===`absolute`?r.value:o+s,f=Math.abs(c-l)<=On;(t===-1||c<l-.05||f&&(a?!u||c<l:!u&&o<d-.05))&&(t=n,l=c,u=a,d=o)}let{end:f}=e[t],p=f.mode===`absolute`&&r(t)?Math.max(l,f.value):l+n[t],m=Math.max(l,c),h=Math.max(m,p);i.delete(t),a[t]=[l,p],o[t]=[m,h],s+=h-m,c=Math.max(c,h)}return{reported:a,engaged:o}},In=(e,t)=>{let n=e.flatMap(({kind:e},t)=>e===`scene`?[t]:[]),r=n.length>1,i=/* @__PURE__ */ new Map,a={...t,measureLiveEndTriggerTop:e=>{let n=i.get(e);if(n!==void 0)return n;let r=t.measureLiveEndTriggerTop(e);return i.set(e,r),r}},o=(e,t)=>e.every((e,n)=>e===t[n]||e!==null&&t[n]!==null&&Math.abs(e-t[n])<=.05),s=(e,t)=>o(e.paddings,t.paddings)&&o(e.freezeStarts,t.freezeStarts),c=e=>e.map(e=>e?Math.max(0,e.freezeEnd-e.freezeStart):0),l=(t,n)=>({paddings:e.map(({kind:e},n)=>e===`scene`?t[n]:null),freezeStarts:e.map(({kind:e},t)=>e===`scene`?n[t][0]:null)}),u=(e,t)=>{let n=n=>n(e[0]).map((r,i)=>r===null?null:e.reduce((e,r,a)=>e+t[a]*n(r)[i],0));return{paddings:n(e=>e.paddings),freezeStarts:n(e=>e.freezeStarts)}},d=null,f=(t,r,i)=>{let a=Fn(e,n,t,()=>i.endsAsRefreshed);return d={lengths:t,order:r,reported:a.reported,refreshTime:[]},a},p=t=>{if(d===null)return null;let{lengths:r,order:i,refreshTime:a}=d,o=e=>e===t||i!==null&&!i.isBefore(e,t);return a[t]??=Fn(e,n,r.map((e,t)=>o(t)?0:e),e=>!o(e)).reported,a[t]},m=(t,r)=>({unpaddedStart:(e,i,a)=>{let o=(r.startsAsRefreshed?p(i):null)??d?.reported??[],s=n.flatMap(n=>{if(n===e||n===i||!o[n]||t&&!t.isBefore(n,i))return[];let[r,s]=o[n];return Math.min(s,a)>r?[[r,Math.min(s,a)]]:[]}).sort((e,t)=>e[0]-t[0]),c=0,l=-1/0;for(let[e,t]of s){let n=Math.max(e,l);t>n&&(c+=t-n),l=Math.max(l,t)}return a-c},absoluteEndLength:t=>{let{end:n}=e[t];if(!r.endsAsRefreshed||n.mode!==`absolute`||d===null)return null;let i=d.order===null?d.reported:p(t);return Math.max(0,n.value-i[t][0])}}),h=(t,n,i,o=null,d=2,p=1)=>{let h=m(t,n),g=[],_=null;for(let m=0;m<i;m+=1){let i=c(En(e,a,_,t,h,o)),m=f(i,t,n),v=l(i,m.reported);if(!r||_!==null&&s(v,_))return{lengths:i,...m};let y=v;if(_!==null){g.push(_);let e=-1;for(let t=0;t<d-1&&e===-1;t+=1)g.length>t+1&&s(v,g[g.length-t-2])&&(e=t);if(e!==-1){let t=[...g.slice(g.length-e-1),v];y=u(t,t.map(()=>1/t.length))}else p<1&&(y=u([v,_],[p,1-p]))}_=y}return null},g=(t,r)=>{let i=m(null,r),o=t=>{let{reported:n}=f(t,null,r);return c(En(e,a,l(t,n),null,i,null,!0))},s=o(t),u=e.map(()=>[]);return n.forEach(e=>{let n=t.slice();n[e]+=2**-7,o(n).forEach((t,n)=>{n!==e&&Math.abs(t-s[n])>1e-6&&u[n].push(e)})}),u},_=e=>e===null||e.reported.some(e=>e.some(e=>!(Math.abs(e)<=2**48))),v=e.map(()=>/* @__PURE__ */ new Set),y={endsAsRefreshed:!0,startsAsRefreshed:!1},b=h(null,y,Math.max(64,2*e.length+2),(e,t)=>t.forEach(t=>v[e].add(t))),x=(()=>{if(_(b))return Mn(e,v);if(!r)return null;let t=g(b.lengths,y);return Nn(n,t)?Mn(e,v):Nn(n,Pn(e,b.lengths,t))?{isBefore:(e,t)=>e<t}:null})();if(x){let t={endsAsRefreshed:!1,startsAsRefreshed:!1};b=h(x,t,2*e.length+2),_(b)&&(b=h(x,t,Math.max(64,2*e.length+2),null,4,.5)),_(b)&&(b=h(x,{endsAsRefreshed:!0,startsAsRefreshed:!0},2*e.length+2))}if(_(b))throw Error(`StickyScrollTrigger: could not resolve endTrigger positions: some endTrigger references form a circular structural dependency that never settles. Point each endTrigger at an element that doesn't depend on it.`);let{reported:S,engaged:C}=b,w=e.map(({kind:e},r)=>{if(e!==`scene`)return null;let[i,a]=C[r],o=n.reduce((e,t)=>t>r&&C[t][1]<=i+.05?e+(C[t][1]-C[t][0]):e,0);return{freezeStart:S[r][0],freezeEnd:S[r][1],engagedStart:i,engagedEnd:a,stickyTop:t.structureTop-(i-o),paddingHeight:a-i}}),ee=n.map(e=>({freezeStart:C[e][0],freezeEnd:C[e][1]})),T=w.map((t,n)=>t??Dn(e,n,ee,a));return T.forEach((e,n)=>t.onPlanned(n,e)),T},Ln=`--sst-scroll-margin-top-offset`,Rn=`important`,zn=/* @__PURE__ */ new WeakMap;let Bn=0;const Vn=typeof CSS<`u`&&typeof CSS.supports==`function`&&CSS.supports(`animation-timeline`,`scroll()`),Hn=typeof CSSStyleSheet==`function`&&typeof CSSStyleSheet.prototype.replaceSync==`function`&&typeof document<`u`&&Array.isArray(document.adoptedStyleSheets),Un=Vn&&Hn,Wn=(e,t)=>{let n=[],r=[],i=[],a=[];return t.forEach((t,o)=>{let s=`--${e}-c${o}`,c=`${e}-k${o}`;n.push(`@property ${s}{syntax:"<length>";inherits:true;initial-value:0px}`,`@keyframes ${c}{from{${s}:0px}to{${s}:${t.freezeEnd-t.freezeStart}px}}`),r.push(`${c} linear both`),i.push(`scroll(root block)`),a.push(`${t.freezeStart}px ${t.freezeEnd}px`)}),n.push(`@supports (animation-timeline: scroll()) {[data-${e}]{animation:${r.join(`,`)};animation-timeline:${i.join(`,`)};animation-range:${a.join(`,`)}}}`),n.join(``)},Gn=(e,t)=>{let n=`sst${Bn++}`,r=!Un&&t!==null,i=/* @__PURE__ */ new Set,a=null,o=null,s=[],c=null,l=(e=window.scrollY)=>{c&&s.forEach((t,r)=>{let i=Math.min(Math.max(e-t.freezeStart,0),t.freezeEnd-t.freezeStart);c.style.setProperty(`--${n}-c${r}`,`${i}px`)})},u=()=>l();r&&window.addEventListener(`scroll`,u,{passive:!0});let d=e=>{let t=zn.get(e);t?.owner===n&&S(e,`scroll-margin-top`,t.authored,t.written,Rn)},f=()=>{a&&=(document.adoptedStyleSheets=document.adoptedStyleSheets.filter(e=>e!==a),null),o?.removeAttribute(`data-${n}`),o=null,s=[],c=null},p=(e,t)=>{o!==t&&(o?.removeAttribute(`data-${n}`),o=t,o.setAttribute(`data-${n}`,``)),r?(s=e,c=t):(a||(a=new CSSStyleSheet,document.adoptedStyleSheets=[...document.adoptedStyleSheets,a]),a.replaceSync(Wn(n,e)))},m=()=>{i.forEach(d),i=/* @__PURE__ */ new Set,f()};return{targets:()=>t===null?[]:Array.from(e.querySelectorAll(t)),sync(r,a,o){let s=r.filter(e=>e.freezeEnd>e.freezeStart).sort((e,t)=>e.freezeStart-t.freezeStart);if(t===null||!s.length||!a){m();return}p(s,a);let c=Array.from(e.querySelectorAll(t)),l=o(c);c.forEach(e=>{let t=zn.get(e);t&&S(e,`scroll-margin-top`,t.authored,t.written,Rn)||zn.set(e,{authored:_(e,`scroll-margin-top`),written:``,owner:n})});let u=s.map((e,t)=>`var(--${n}-c${t}, 0px)`).join(` + `);c.forEach((e,t)=>{let r=parseFloat(getComputedStyle(e).scrollMarginTop)||0,i=0,a=s.map(({freezeStart:e,freezeEnd:n})=>{let a=l[t]-r+i-e-On;return i+=n-e,`clamp(0px, (${a}px - var(${Ln}, 0px)) * 1000000, ${n-e}px)`}).join(` + `),o=zn.get(e);o.written=x(e,`scroll-margin-top`,`calc(${r}px + var(${Ln}, 0px) + ${u} - (${a}))`,Rn),o.owner=n});let f=new Set(c);i.forEach(e=>{f.has(e)||d(e)}),i=f},applyRamps(e){l(e)},restore(){r&&window.removeEventListener(`scroll`,u),m()}}},Kn=e=>{for(let t=1;t<e.length;t+=1)if(h(e[t-1].trigger,e[t].trigger)>0)return!0;return!1},qn=(e,t)=>{t.sort((e,t)=>h(e.trigger,t.trigger));for(let e of t)e.kind===`cover`&&(e.wrapper=ce(e.trigger));let n=e,r=null;for(let i of t){if(i.kind!==`scene`)continue;let t=se(n,n===e);i.container=t.container,i.wrapper=t.wrapper,i.padding=t.padding,n=t.container,r=t.container}return r},Jn=e=>{e.wrapper&&=(le(e.wrapper),null)},Yn=(e,t,n)=>{if(n){let t=n.parentNode;t&&D(t,e,n),n.remove()}for(let e=t.length-1;e>=0;--e){let n=t[e];n.kind===`cover`?Jn(n):(n.wrapper=null,n.container=null,n.padding=null)}},Xn=(e,t,n,a,o,s)=>{if(a===null)return{mode:`auto`};let c=Z(a);switch(c.kind){case`dwell`:return{mode:`dwell`,distancePx:Math.max(0,_n(c.value,t))};case`absolute`:return{mode:`absolute`,value:c.value};case`max`:if(n.kind!==`cover`)throw Error(`StickyScrollTrigger: createStickyTrigger's trigger ${r(n.trigger)} has end "${a}". GSAP's 'max' keyword isn't supported here: the layer's own dwell padding adds to the document's max scroll position, so the freeze window would depend on itself. Use createOverlapScroll, which adds no padding, or a dwell distance such as '+=500'.`);return{mode:`max`,offsetPx:bn(c.value,t)};case`clause`:{if(n.kind!==`cover`&&s!==null&&s>o)throw Error(`StickyScrollTrigger: createStickyTrigger's trigger ${r(n.trigger)}'s endTrigger (${r(n.endTrigger)}) refers to a layer positioned later in DOM order, which isn't supported for createStickyTrigger. Point endTrigger at a layer earlier in DOM order, use an unregistered element at the same spot, or use a dwell distance such as '+=500'.`);let t=s===null,a=e.contains(n.endTrigger);if(t&&!a&&n.kind!==`cover`)throw Error(`StickyScrollTrigger: createStickyTrigger's trigger ${r(n.trigger)} has an endTrigger (${r(n.endTrigger)}) outside the shared container: the layer's own dwell keeps pushing it away, so the freeze window never settles. Point endTrigger at an element inside the container, or use a dwell distance such as '+=500'.`);return{mode:`clause`,clause:c.value,rawTop:t&&a?i(n.endTrigger):null,measureLive:t&&!a}}}},Zn=(e,t,n,i)=>{let a=Z(t);switch(a.kind){case`absolute`:if(e.kind===`cover`)throw Error(`StickyScrollTrigger: createOverlapScroll's trigger ${r(e.trigger)} has start "${t}", an absolute scroll position (GSAP reads any bare number this way). That isn't supported here: a cover layer's sticky position is computed relative to its own wrapper, so start must be a position clause such as 'bottom bottom'.`);return{mode:`absolute`,value:a.value};case`max`:case`dwell`:case`clause`:return{mode:`clause`,anchorOffset:X(a.value,n,i),elementFraction:pn(a.value)}}},Qn=(e,t,n,r,a)=>{let o=Y(n.start),s=n.end===null?null:gn(o,Y(n.end)),c=f(n.trigger),l=n.endTrigger===n.trigger,u=e=>[...a].filter(([t])=>e(t)).map(([,e])=>e),d=a.get(n.endTrigger)??null,p=Xn(e,t,n,s,r,d),m=p.mode===`clause`&&!p.measureLive&&!l,h=Zn(n,o,c,t),{end:g}=n,_=n.kind===`scene`&&typeof g==`function`&&(p.mode===`dwell`||p.mode===`absolute`)?()=>Xn(e,t,n,gn(o,g()),r,d):void 0;return{kind:n.kind,start:h,triggerTop:i(n.trigger),triggerHeight:c,triggerEnclosedBy:u(e=>e.contains(n.trigger)),wrapperTop:n.wrapper?i(n.wrapper):0,coverTop:n.kind===`cover`?i(n.cover):0,end:p,endTrigger:{isSelf:l,index:d,height:p.mode===`clause`?f(n.endTrigger):0,enclosedBy:m?u(e=>e.contains(n.endTrigger)):[],nests:m?u(e=>e!==n.endTrigger&&n.endTrigger.contains(e)):[]},liveEnd:_}},$n=[`trigger`,`start`,`end`,`endTrigger`,`pin`,`pinSpacing`,`anticipatePin`,`pinnedContainer`,`pinReparent`,`pinSpacer`,`pinType`,`horizontal`,`scroller`,`containerAnimation`],er=e=>{let t=e=>{if(!Number.isFinite(e))throw Error(`StickyScrollTrigger: createStickyPin's top must be a finite number, got ${e}.`);return`top ${e}px`};return typeof e==`function`?()=>t(e()):t(e)},tr=(e,t,n,r,a)=>{switch(t.kind){case`dwell`:return n+_n(t.value,r);case`absolute`:return t.value;case`clause`:return a(e,i(e)-X(t.value,f(e),r))}},nr=(e,t)=>{let n=e.indexOf(t);n!==-1&&e.splice(n,1)},rr=e=>e.mode===`dwell`?e.distancePx:e.mode===`absolute`?e.value:0,ir=(e,t)=>e.some(e=>e.trigger===t),Q=/* @__PURE__ */ new Set,ar=/* @__PURE__ */ new Set,$=/* @__PURE__ */ new Map;let or=0,sr=null;const cr=/* @__PURE__ */ new Set;let lr=null;const ur=/* @__PURE__ */ new Map,dr=(...e)=>{let t=null;if(e.forEach(e=>{try{e()}catch(e){t?queueMicrotask(()=>{throw e}):t={error:e}}}),t)throw t.error};var fr=class o{#e;#t=[];#n=[];#r=null;#i=/* @__PURE__ */ new WeakMap;#a=!1;#o=!1;#s=null;#c=0;#l=!1;#u=0;#d=!1;#f=!1;#p=!1;#m=!1;#h=null;#g=null;#_=null;#v=null;#y=[];#b=null;#x;#S=!1;#C=null;#w=!1;#T=null;constructor(t,n={}){this.#e=e(t);let r=n.scrollMarginTargets===void 0?`[id]`:n.scrollMarginTargets;if(r!==null)try{this.#e.querySelectorAll(r)}catch{throw Error(`StickyScrollTrigger: scrollMarginTargets "${r}" is not a valid CSS selector.`)}let i=n.nestedStickyOptimization===void 0?`auto`:n.nestedStickyOptimization;if(![`auto`,`always`,`off`].includes(i))throw Error(`StickyScrollTrigger: nestedStickyOptimization must be 'auto', 'always' or 'off', got ${String(i)}.`);this.#x=r,(i===`always`||i===`auto`&&ze())&&(this.#T={mode:i,ownedElements:()=>this.#I(),demotableElements:()=>this.#L()})}#E(){Q.delete(this)&&(this.#p=!1),!this.#S&&(this.#S=!0,cr.add(this),ar.forEach(e=>{e.owner.#j(this)&&(e.cancelled=!0)}),this.#b=Gn(this.#e,this.#x),this.#T&&Et(this.#T))}#D(){if(this.#S&&!this.#l&&!this.#t.length&&!this.#y.length){if(Q.has(this))return;let e=this.#v;if(!k(e)&&Fe(e)){Q.add(this),queueMicrotask(()=>this.#M());return}this.#k(!0,!0)}}#O(){this.#l||Q.forEach(e=>{e!==this&&e.#j(this)&&e.#P()})}#k(e,t=!1){let n=e&&this.#a?this.#he(this.#n):null;this.#p=!1,this.#F(),n&&(M(this.#v)?this.#ge(n):(this.#_&&ar.delete(this.#_),this.#_={owner:this,position:n,cls:this.#v,onlyAtRest:t,cancelled:!1},ar.add(this.#_),queueMicrotask(()=>this.#A())))}#A(){let e=this.#_;e&&(this.#_=null,ar.delete(e),!(e.cancelled||e.onlyAtRest&&W(e.cls))&&this.#ge(e.position,e.cls))}#j(e){return this.#e.contains(e.#e)||e.#e.contains(this.#e)}#M(){if(this.#l||this.#g!==null)return;if(W(this.#v)){this.#g=setTimeout(()=>{this.#g=null,this.#M()},100);return}let e=this.#h;this.#h=null,dr(()=>this.#N(),()=>e?.())}#N(e=!0,t=!1){Q.delete(this)&&!this.#l&&!this.#t.length&&!this.#y.length&&this.#k(e,t)}#P(){this.#N(!W(this.#v),!0)}#F(){this.#S=!1,cr.delete(this),kt(this.#T),this.#b?.restore(),this.#b=null,this.#be(),this.#z(),this.#n=[]}#I(){return[...this.#L(),...this.#R()]}#L(){return this.#n.flatMap(e=>e.wrapper?[e.wrapper]:[])}#R(){return this.#y.flatMap(({trigger:e,inner:t})=>t?[e]:[])}#z(){this.#a&&=(Yn(this.#e,this.#n,this.#s),or+=1,this.#c+=1,this.#r=null,this.#s=null,!1)}#B(){let e=new Set(this.#n);return this.#t.every(t=>e.has(t))}#V(){let e=new Set(this.#t),t=this.#n.flatMap(t=>!e.has(t)&&t.kind===`scene`?[t]:[]);Tt(t.flatMap(({wrapper:e})=>e?[e]:[]));for(let e of t)e.wrapper&&(Nt(e.wrapper,e.padding),e.wrapper=null,e.container=null,e.padding=null);this.#n=[...this.#t],or+=1,this.#c+=1,this.#r=null,this.#o=!1}#H(){this.#s=qn(this.#e,this.#t),this.#n=[...this.#t],this.#a=!0,this.#o=!1}#U(){this.#N(),this.#pe(),this.#A()}#W(){if(this.#l||(this.#a&&(this.#p=!0),$.has(this)))return;let e=this.#v,t=()=>$.get(this)===n,n=()=>{if(!t()||($.delete(this),this.#l))return!1;try{this.#U()}catch(e){queueMicrotask(()=>{throw e})}return!0};$.set(this,n);let r=()=>{if(!n())return;let e=yt();return e?Re(e):void 0};A(e,`refreshInit`,r);let i=()=>{try{t()&&!this.#l&&Ie(this.#v)}finally{j(e,`refreshInit`,r),n()}};queueMicrotask(()=>{if(t()&&!this.#l&&W(e)){let e=this.#h;this.#h=e?()=>dr(e,i):i,this.#M()}else i()})}#G(e){this.#l||(this.#v=Ne(e),lr=this.#v)}#K(e){let t=t=>{this.#G(t),k(this.#v)&&$t(this.#v);let n=e?.(t),r=k(this.#v),i=!1,a=!1;r&&([...$].forEach(([e,t])=>e!==this&&t()),i=$.get(this)?.()===!0,i&&this.#C?.takeRecords());let o=r&&!e&&!this.#o&&(i||this.#C!==null&&this.#C.takeRecords().length===0),s=r&&(!o||i)?Gt(this.#v):()=>{};w(s,()=>{try{o||(a=!0,this.#fe(!0))}catch(e){queueMicrotask(()=>{throw e})}r&&(this.#q(),(a||i)&&this.#J())});let c=yt();return c?Re(c,n):n};return e=>Zt(()=>t(e))}#q(){if(this.#C){this.#C.takeRecords();return}let e=new MutationObserver(()=>{}),t=this.#v,n=()=>{e.disconnect(),this.#C===e&&(this.#C=null),queueMicrotask(()=>j(t,`refresh`,n))};e.observe(document,{subtree:!0,childList:!0,attributes:!0,characterData:!0}),this.#C=e,A(t,`refresh`,n),queueMicrotask(n)}#J(){let e=sr??/* @__PURE__ */ new Map;sr||(sr=e,queueMicrotask(()=>{sr===e&&(sr=null)})),e.set(this,this.#Y()),e.forEach((t,n)=>{if(!(n.#l||t===n.#Y())){try{n.#fe(!0)}catch(e){queueMicrotask(()=>{throw e})}n.#C?.takeRecords(),e.set(n,n.#Y())}})}#Y(){let e=[i(this.#e)];return this.#w&&e.push(c()),[...this.#t,...this.#y].forEach(({endTrigger:t})=>{this.#e.contains(t)||e.push(i(t))}),e.join(`,`)}#X(){this.#y.forEach(e=>{if(e.outer)return;e.savedPosition=y(e.trigger);let t=ue(e.trigger);e.outer=t.outer,e.inner=t.inner})}#Z(){let e=this.#y.flatMap(({outer:e,inner:t,trigger:n})=>e&&t?[{outer:e,inner:t,trigger:n,savedStyle:e.style.cssText,range:t.style.height}]:[]);e.forEach(({outer:e,inner:t})=>{Ft(e),Ft(t)});let t;try{let n=Te(e);t=e.map(({outer:e},t)=>n[t]??f(e))}catch(t){throw e.forEach(({outer:e,inner:t,savedStyle:n,range:r})=>{Mt(e,n),V(t,r)}),t}e.forEach(({outer:e},n)=>{V(e,`${t[n]}px`)}),e.forEach(({inner:e,range:t})=>V(e,t))}#Q(e){return e.outer?(ke(e.outer,e.trigger,e.savedPosition),e.outer=null,e.inner=null,!0):!1}#$(){return C(this.#L())}#ee(){let e=this.#y.filter(({inner:e})=>e).map(e=>({layer:e,restore:C([e.trigger])}));return()=>e.forEach(({layer:e,restore:t})=>{e.inner&&t()})}static#te(e,t){let n=e??[...cr].find(e=>e.#v),r=(n?n.#v:null)??lr;if(It()!==null)return Ut(r);let i=k(r);if(i&&Kt())return Gt(r);if(!(i&&Qt())&&!Vt(r)&&window.scrollY!==0){let n=new Set(e?e.#I():[]);return Jt(t,n)?Ut(r):()=>{}}let a=[...cr].filter(t=>t!==e).map(e=>e.#$());return()=>a.reverse().forEach(e=>e())}#ne(e){let t=this.#$(),n=this.#ee(),r=o.#te(this,e);return()=>{r(),n(),t()}}#re(e){let t=()=>{};w(()=>t(),()=>this.#ae(e,()=>{t=o.#te(this,this.#ie())}))}#ie(){let e=[...this.#t,...this.#y].flatMap(e=>[e.trigger,e.endTrigger,...`cover`in e&&e.cover?[e.cover]:[]]);return[this.#e,...e,...this.#b?.targets()??[]]}#ae(e,t){let n=this.#t.filter(e=>e.wrapper!==null),r=n.flatMap(({wrapper:e})=>e?[e]:[]),i=r.map(y),a=this.#y.map(e=>({layer:e,position:y(e.trigger),range:e.inner?e.inner.style.height:``})),o=this.#c,s=()=>this.#c===o,l=e=>{s()&&e.forEach((e,t)=>At(t,e))};r.forEach(Pt),a.forEach(({layer:e})=>Pt(e.trigger)),t();let u,d;try{let t=n.length?this.#se(e,n):null;d=this.#Ce(n),u=t?this.#ce(e,n,t):/* @__PURE__ */ new Map,this.#w=a.length>0||(t?.measured.some(({end:e})=>e.mode===`max`)??!1)}catch(e){throw s()&&r.forEach((e,t)=>jt(e,i[t])),a.forEach(({layer:e,position:t})=>{e.inner&&jt(e.trigger,t)}),e}let f=[];try{a.length&&(a.forEach(({layer:e})=>{e.inner&&Ft(e.inner)}),f=this.#oe(e,c()))}catch(e){throw l(u),a.forEach(({layer:e,position:t,range:n})=>{e.inner&&(jt(e.trigger,t),V(e.inner,n))}),e}l(u),f.forEach(({layer:e,topPx:t,range:n})=>{e.inner&&(At(e.trigger,t),V(e.inner,`${n}px`))}),this.#Se(d)}#oe(e,t){return this.#y.flatMap(n=>{if(!n.inner)return[];let r=Y(n.start),a=gn(r,Y(n.end)),o=Z(a);if(o.kind===`max`)throw Error(`StickyScrollTrigger: createStickyPin's end "${a}" uses GSAP's 'max' keyword, which isn't supported here. Use a position clause against endTrigger, such as 'top top'.`);let s=i(n.trigger),c=f(n.trigger),l=parseFloat(getComputedStyle(n.trigger).marginBottom)||0,u=Z(r);if(u.kind===`absolute`)throw Error(`StickyScrollTrigger: createStickyPin's start "${r}" is an absolute scroll position (GSAP reads any bare number this way). A pin can't act on one: it engages when position:sticky engages, so start says where trigger sits in the viewport while pinned. Use the top option (top: ${r}) for a px distance from the viewport's top edge, or a position clause such as 'top top'.`);let d=X(u.value,c,e),p=(e,t)=>this.#je(e,t),m=tr(n.endTrigger,o,p(n.trigger,s-d),e,p),h=m-(this.#e.contains(n.trigger)?An(m,this.#Me()):0)-s+d+c+l,g=t>0?t-s:1/0,_=c+l;return[{layer:n,topPx:d,range:Math.max(0,Math.min(Math.max(h,_),g))}]})}#se(e,t){let n=this.#s?i(this.#s):0;this.#r={top:n,changes:or};let r=/* @__PURE__ */ new Map;return t.forEach((e,t)=>{r.set(e.trigger,t)}),{structureTop:n,measured:t.map((t,n)=>Qn(this.#e,e,t,n,r))}}#ce(e,t,{structureTop:n,measured:r}){let a=r.some(e=>e.end.mode===`clause`&&e.end.measureLive),o=r.some(e=>e.end.mode===`max`),s=0,l=!1,u=/* @__PURE__ */ new Map,d=()=>In(r,{viewportHeight:e,structureTop:n,documentMaxScroll:s,measureLiveEndTriggerTop:e=>l?i(t[e].endTrigger):0,onPlanned:(e,n)=>{let r=t[e];r.freezeStart=n.freezeStart,r.freezeEnd=n.freezeEnd,r.engagedStart=n.engagedStart,r.engagedEnd=n.engagedEnd,r.wrapper&&(u.set(r.wrapper,n.stickyTop),r.kind===`scene`&&r.padding&&n.paddingHeight!==null&&V(r.padding,`${n.paddingHeight}px`))}});return this.#le(t,r,()=>{let i=t.map(()=>0);return In(r,{viewportHeight:e,structureTop:n,documentMaxScroll:s,measureLiveEndTriggerTop:()=>0,onPlanned:(e,t)=>{i[e]=t.paddingHeight??0}}),i}),d(),o&&(s=Math.max(0,c()-e)),l=!0,(a||o)&&d(),u}#le(e,t,n){let r=t.flatMap(({liveEnd:e},t)=>e?[{index:t,liveEnd:e}]:[]);if(!r.length)return;let i=window.scrollY;try{for(let a=0;a<6;a+=1){let a=n(),o=!1;if(r.forEach(({index:n,liveEnd:r})=>{let s=this.#ue(e,a,n,r,qt()??i),c=t[n].end;s&&s.mode===c.mode&&(Math.abs(rr(s)-rr(c))<=.5||(t[n]={...t[n],end:s},o=!0))}),!o)break}}finally{Ht(i)}}#ue(e,t,n,r,i){let a=e.flatMap((e,r)=>r<n&&e.kind===`scene`&&t[r]?[{after:e.trigger,height:t[r]}]:[]);return en(()=>{let e=[...cr].filter(e=>e!==this&&h(this.#e,e.#e)<0),t=[this,...e].flatMap(e=>e.#t.flatMap(e=>e.kind===`scene`&&e.padding?[{layer:e,padding:e.padding}]:[])),n=t.map(({padding:e})=>e.style.height);t.forEach(({padding:e})=>V(e,`0px`));let r=ee(a);return()=>{r(),t.forEach(({layer:e,padding:t},r)=>{e.padding===t&&t.style.height===`0px`&&V(t,n[r])})}},i,r)}refresh(){this.#u>0||k(this.#v)||this.#l||!this.#S||Q.has(this)||te()||window.scrollY===0||this.#de()?this.#fe(!1):w(Ut(this.#v),()=>this.#fe(!1))}#de(){return Fe(this.#v)&&!Jt(this.#ie(),new Set(this.#I()))}#fe(e){if(this.#u>0&&!this.#o){if(!e){this.#f=!0;return}if(this.#d)return;this.#d=!0}this.#pe()}#pe(){if(te()){let e=k(this.#v)?this.#v:null;this.#m=!0,ur.size===0&&queueMicrotask(o.#me),ur.set(this,ur.get(this)??e);return}if(this.#u>0&&(this.#f=!0),this.#l||!this.#S||Q.has(this))return;let e=null,t=this.#p?this.#he(this.#n):null;this.#p=!1,this.#u+=1;try{this.#ve(),this.#u===1&&this.#f&&!this.#l&&this.#S&&!Q.has(this)&&this.#ve()}catch(t){e={error:t}}finally{--this.#u,this.#u===0&&(this.#d=!1,this.#f=!1,this.#m=!1)}try{vt(this.#v)}catch(e){xt(),queueMicrotask(()=>{throw e})}if(!e&&t!==null&&this.#ge(t),this.#b?.applyRamps(qt()??M(this.#v)?.read()),e)throw e.error}static#me(){let e=[...ur];ur.clear();let t=new Set(e.flatMap(([,e])=>e?[e]:[])),n=e.flatMap(([e,t])=>!t&&e.#m?[e]:[]);dr(...[...t].map(e=>()=>Ie(e)),...n.map(e=>()=>e.refresh()))}#he(e){let t=this.#r,n=this.#s,r=t&&n&&t.changes!==or?(e=>w(k(this.#v)&&Qt()?Gt(this.#v):o.#te(this,[e]),()=>i(e)))(n)-t.top:0,a=(M(this.#v)?.read()??It()??window.scrollY)-r,s=/* @__PURE__ */ new Map;return e.forEach(e=>{e.kind===`scene`&&s.set(e.trigger,a>e.engagedEnd?1/0:An(a,this.#Me([e])))}),{natural:a-An(a,this.#Me(e))+r,consumed:s}}#ge(e,t=this.#v){let n=this.#_e(e),r=M(this.#v);if(r){r.write(n);return}let i=It();i===null?k(t)||(Math.abs(window.scrollY-n)>=.5&&window.scrollTo({top:Math.round(n),behavior:`instant`}),Le(t)):Math.abs(i-n)>=.5&&Lt(Math.round(n))}#_e({natural:e,consumed:t}){let n=0,r=e;return this.#n.flatMap(e=>e.kind===`scene`?[e]:[]).sort((e,t)=>e.engagedStart-t.engagedStart).forEach(i=>{let a=i.engagedEnd-i.engagedStart,o=t.get(i.trigger);o===void 0?i.engagedStart<e+n-.05&&(r+=a):r+=Math.min(o,a),n+=a}),r}#ve(){!this.#a||Kn(this.#t)||this.#o&&!this.#B()?(this.#z(),this.#H()):this.#o&&this.#V(),this.#be();try{this.#X(),this.#Z()}finally{this.#xe()}let e=this.#t.length||this.#y.length?a():0;this.#re(e)}#ye(){return this.#t.filter(e=>e.kind===`cover`)}#be(){this.#ye().forEach(e=>this.#i.get(e)?.())}#xe(){this.#ye().forEach(e=>{this.#i.set(e,Me(oe(e.cover)))})}#Se(e){this.#b?.sync(this.#Me(),this.#s,t=>{let n=t.filter(t=>!e.has(t));return n.length&&w(this.#ne(n),()=>n.forEach(t=>e.set(t,i(t)))),t.map(t=>e.get(t))})}#Ce(e){let t=this.#b&&e.some(({kind:e})=>e===`scene`)?this.#b.targets():[];return new Map(t.map(e=>[e,i(e)]))}#we(e,t){let n=$n.filter(t=>t in e);if(n.length!==0)throw Error(`${t}: ${n.join(`, `)} ${n.length>1?`are`:`is`} not supported here; this module handles pinning and the scroll axis itself.`)}#Te(e,t,n){if(ir(e,t))throw Error(n)}#Ee(e,t){if(e===this.#e)throw Error(`${t}: trigger ${r(e)} is the shared container itself. Point trigger at an element inside the container.`);if(!this.#e.contains(e))throw Error(`${t}: trigger ${r(e)} is outside the shared container. Point trigger at an element inside it, or use createStickyPin, which works on either side.`)}#De(e,t){if(!e.contains(this.#e))return;let n=e===this.#e?`is the shared container itself`:`is an ancestor of the shared container`;throw Error(`${t}: trigger ${r(e)} ${n}. A pin makes trigger itself position:sticky inside a box holding the pin range, so the container and every layer's dwell padding would be pinned along with it. Pin an element that doesn't contain the container.`)}#Oe(e,t,n){if(this.#l)throw Error(`StickyScrollTrigger: cannot register a new layer after destroy() has been called.`);return this.#Te(this.#t,e.trigger,`StickyScrollTrigger: ${r(e.trigger)} is already registered as a trigger for another layer. Each element can be used once per controller instance, across createStickyTrigger and createOverlapScroll: reusing one makes endTrigger resolution ambiguous.`),this.#Te(this.#y,e.trigger,`StickyScrollTrigger: ${r(e.trigger)} is already registered as a pin trigger (createStickyPin). Using the same element as both a Scene/Cover trigger and a pin trigger wraps it twice and produces conflicting position:sticky behavior.`),this.#E(),this.#t.push(e),this.#o=!0,this.#u>0&&(this.#f=!0),{...n,trigger:e.trigger,start:()=>e.freezeStart,end:()=>e.freezeEnd||.001,invalidateOnRefresh:n.invalidateOnRefresh??!0,onKill:n=>{this.#G(n),this.#t.includes(e)&&(nr(this.#t,e),this.#o=!0,this.#W(),this.#D()),t?.(n)},onRefreshInit:this.#K(n.onRefreshInit)}}createStickyTrigger({trigger:e,start:r=`0 0`,end:i=`100% 0`,endTrigger:a,onKill:o,...s}){this.#we(s,`createStickyTrigger`),this.#O();let c=t(e,`createStickyTrigger`);this.#Ee(c,`createStickyTrigger`);let l=n(c,a,`createStickyTrigger`);return this.#Oe({kind:`scene`,trigger:c,endTrigger:l,container:null,wrapper:null,padding:null,start:K(r),end:K(i),freezeStart:0,freezeEnd:0,engagedStart:0,engagedEnd:0},o,s)}createOverlapScroll({trigger:e,cover:i,start:a=`bottom bottom`,end:o=null,endTrigger:s,onKill:c,...l}){this.#we(l,`createOverlapScroll`),this.#O();let u=t(e,`createOverlapScroll`);this.#Ee(u,`createOverlapScroll`);let d=n(u,s,`createOverlapScroll`),f=new Set(this.#ye().flatMap(({wrapper:e})=>e?[e]:[])),p=i===void 0?ae(u,f):t(i,`createOverlapScroll`);if(!(p instanceof HTMLElement))throw Error(`createOverlapScroll: cover element (trigger's next sibling) not found for trigger ${r(u)}`);if(re(p,f)!==re(u,f))throw Error(`createOverlapScroll: cover ${r(p)} must be a sibling of trigger `+r(u));let m={kind:`cover`,trigger:u,endTrigger:d,cover:p,wrapper:null,start:K(a),end:o===null?null:K(o),freezeStart:0,freezeEnd:0,engagedStart:0,engagedEnd:0},h=this.#Oe(m,e=>{this.#i.get(m)?.(),Jn(m),c?.(e)},l);return this.#i.set(m,Me(oe(p))),h}createStickyPin({trigger:e,start:i,top:a,endTrigger:o,end:s=`bottom top`,onKill:c,...l}){if(this.#we(l,`createStickyPin`),this.#O(),this.#l)throw Error(`StickyScrollTrigger: cannot register a new pin after destroy() has been called.`);if(i!==void 0&&a!==void 0)throw Error(`StickyScrollTrigger: createStickyPin accepts either start or top, not both (top: 20 is start: 'top 20px'). Use top for a plain px distance from the viewport's top edge, start for anything else.`);let u=t(e,`createStickyPin`),d=n(u,o,`createStickyPin`);this.#De(u,`createStickyPin`),this.#Te(this.#y,u,`StickyScrollTrigger: ${r(u)} is already registered as a pin trigger.`),this.#Te(this.#t,u,`StickyScrollTrigger: ${r(u)} is already registered as a trigger for another layer (createStickyTrigger/createOverlapScroll). Using the same element as both a Scene/Cover trigger and a pin trigger wraps it twice and produces conflicting position:sticky behavior.`);let f={trigger:u,savedPosition:y(u),outer:null,inner:null,start:K(a===void 0?i??`top top`:er(a)),endTrigger:d,end:K(s)};return this.#E(),this.#y.push(f),this.#u>0&&(this.#f=!0),{...l,trigger:u,onKill:e=>{this.#G(e),nr(this.#y,f),this.#Q(f)&&this.#W(),this.#D(),c?.(e)},onRefreshInit:this.#K(l.onRefreshInit)}}resolveScrollPosition(e,t){return tn(()=>this.#ke(e,t))}#ke(e,n){let r=t(e,`resolveScrollPosition`),i=Y(n),o=a(),s=Z(i);switch(s.kind){case`max`:return l(o)+bn(s.value,o);case`absolute`:return s.value;case`dwell`:case`clause`:return this.#Ae(r,s.value,o)}}#Ae(e,t,n){let r=X(t,f(e),n),a=w(this.#ne([e]),()=>i(e))-r;return this.#je(e,a)}#je(e,t){return this.#e.contains(e)?t+kn(t,this.#Me()):t}#Me(e=this.#n){return e.flatMap(e=>e.kind===`scene`?[{freezeStart:e.engagedStart,freezeEnd:e.engagedEnd}]:[])}static getScrollTop(e,n){let r=t(e,`StickyScrollTrigger.getScrollTop`),a=n.find(e=>e.#e.contains(r));if(a)return a.resolveScrollPosition(r,`top top`);let s=n.map(e=>e.#ee());try{return w(o.#te(null,[r]),()=>i(r))}finally{s.reverse().forEach(e=>e())}}createResolvedTrigger({trigger:e,start:r=`top bottom`,end:i=`bottom top`,endTrigger:o,...s}){this.#we(s,`createResolvedTrigger`),this.#O();let c=t(e,`createResolvedTrigger`),l=n(c,o,`createResolvedTrigger`);return{...s,trigger:c,start:()=>this.resolveScrollPosition(c,r),end:()=>{let e=Y(i),t=Z(e);return t.kind===`dwell`?this.resolveScrollPosition(c,r)+_n(t.value,a()):this.resolveScrollPosition(l,gn(r,e))}}}destroy(){this.#l||dr(()=>this.#P(),()=>this.#Ne())}#Ne(){this.#g!==null&&clearTimeout(this.#g),this.#g=null,this.#l=!0;let e=this.#h;this.#h=null,e?.(),this.#S&&this.#F(),this.#t.length=0,this.#y.forEach(e=>this.#Q(e)),this.#y.length=0,this.#v=null}};export{fr as default};
|