sticky-scroll-trigger 0.11.0 → 0.12.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.
- package/README.md +29 -7
- package/dist/StickyScrollTrigger.d.ts +4 -1
- package/dist/StickyScrollTrigger.global.js +604 -121
- package/dist/StickyScrollTrigger.global.min.js +2 -2
- package/dist/StickyScrollTrigger.js +604 -121
- package/dist/StickyScrollTrigger.min.js +2 -2
- package/package.json +12 -12
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* @license
|
|
3
|
-
* StickyScrollTrigger v0.
|
|
3
|
+
* StickyScrollTrigger v0.12.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
|
-
var StickyScrollTrigger=(function(){let 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=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,t)=>{e.style.position=`sticky`,e.style.top=`${t}px`},h=e=>({position:e.style.position,top:e.style.top}),g=(e,t)=>{e.style.position=t.position,e.style.top=t.top},_=(e,t)=>{if(!e.parentNode)throw Error(`StickyScrollTrigger: ${r(e)} is not attached to the document`);let n=document.createElement(`div`),i=document.createElement(`div`),a=document.createElement(`div`);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=document.createElement(`div`);e.style.display=`flow-root`,i.appendChild(e)}return{container:n,wrapper:i,padding:a}},v=e=>{let t=e.parentNode;if(!t)throw Error(`createOverlapScroll: trigger ${r(e)} is not attached to the document`);let n=document.createElement(`div`);for(t.insertBefore(n,t.firstChild);n.nextSibling;){let t=n.nextSibling;if(n.appendChild(t),t===e)break}return n},y=e=>{let t=e.parentNode;if(t){for(;e.firstChild;)t.insertBefore(e.firstChild,e);e.remove()}},b=e=>{if(!e.parentNode)throw Error(`createStickyPin: trigger ${r(e)} is not attached to the document`);let t=document.createElement(`div`),n=document.createElement(`div`);return t.style.display=`flow-root`,e.parentNode.insertBefore(t,e),t.appendChild(n),n.appendChild(e),s.add(n),{outer:t,inner:n}},x=(e,t,n)=>{let r=e.parentNode;g(t,n),r&&r.insertBefore(t,e),e.firstElementChild instanceof HTMLElement&&s.delete(e.firstElementChild),e.remove()},S={position:`relative`,zIndex:`1`},C=new WeakMap,w=e=>{let t=[];for(let n=e;n;n=n.nextElementSibling){if(!(n instanceof HTMLElement))continue;let e=n,r=C.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]=S[t]}),C.set(e,{count:1,applied:n})}t.push(e)}return()=>{t.forEach(e=>{let t=C.get(e);t&&(--t.count,!(t.count>0)&&(t.applied.forEach(t=>{e.style[t]===S[t]&&(e.style[t]=``)}),C.delete(e)))}),t.length=0}},T=e=>typeof e==`function`?e():e,E={top:0,center:.5,bottom:1},D=(e,t,n,r)=>{let i=n===`%`?parseFloat(t)/100*r:parseFloat(t);return e?.startsWith(`-`)?-i:i},ee=/^(top|center|bottom|[+-]?(?:\d+(?:\.\d*)?|\.\d+))?(%|px)?(?:([+-]=?)(\d+(?:\.\d*)?|\.\d+)(%|px)?)?$/,O=(e,t)=>{let n=ee.exec(e);if(!n||!n[1]&&!n[3])throw R.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 E,l=i===`%`;return{fraction:c?E[r]:l?parseFloat(r)/100:0,offsetPx:(!c&&!l&&r!==void 0?parseFloat(r):0)+(a?D(a,o,s,t):0)}},k=e=>typeof e==`number`||e.trim()!==``&&!Number.isNaN(Number(e)),A=e=>typeof e==`number`?e:Number(e),j=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}"?`:``))},M=(e,t)=>{let n=e.trim();j(n);let r=O(n.split(/\s+/)[0],t);return t*r.fraction+r.offsetPx},N=e=>M(e,1)-M(e,0),P=(e,t,n)=>{let r=e.trim();j(r);let i=r.split(/\s+/)[1]??`top`,a=O(i,n);return n*a.fraction+a.offsetPx-M(r,t)},F=/^\+=(\d+(?:\.\d*)?|\.\d+)(%|px)?$/,te=e=>typeof e==`string`&&F.test(e.trim()),I=(e,t)=>{if(typeof t!=`string`)return t;let n=t.trim();if(!n.startsWith(`+=`)||!/\s/.test(n))return t;let r=T(e);if(typeof r!=`string`)return t;let i=r.trim();j(i);let[a]=i.split(/\s+/);try{O(a,0)}catch(e){if(!k(r))throw e;return t}if(O(n.split(/\s+/)[0],0),a.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 "${a}" 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 a+n},L=(e,t)=>{let n=F.exec(String(e).trim());if(!n)throw Error(`StickyScrollTrigger: unsupported end format "${e}"`);let[,r,i]=n;return D(void 0,r,i,t)},R=/^max(?:([+-]=)(\d+(?:\.\d*)?|\.\d+)(%|px)?)?$/,ne=e=>typeof e==`string`&&R.test(e.trim()),z=(e,t)=>{let n=R.exec(e.trim());if(!n)throw Error(`StickyScrollTrigger: unsupported max-position format "${e}"`);let[,r,i,a]=n;return r?D(r,i,a,t):0},B=e=>typeof e==`number`?{kind:`absolute`,value:e}:te(e)?{kind:`dwell`,value:e}:ne(e)?{kind:`max`,value:e}:k(e)?{kind:`absolute`,value:A(e)}:{kind:`clause`,value:e},V=(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)),H=(e,t)=>e.flatMap(({triggerEnclosedBy:e},n)=>n!==t&&e.includes(t)?[n]:[]),re=(e,t,n,r,i,a,o,s,c,l)=>{let u=e[n];return o.includes(n)?+((u.start.mode===`absolute`?t.unpaddedStart(n,l,r):u.triggerTop-u.start.anchorOffset)<a-.05):c&&V(e,n,o,s,c)?0:i.nests.includes(n)?i.fraction:+(u.triggerTop+u.triggerHeight<=i.top+.05)},U=(e,t,n,r,i,a,o,s,c,l)=>n.reduce((n,{index:u,freezeStart:d,freezeEnd:f})=>{if(u===o||c&&c.isBefore(o,u))return n;let p=re(e,t,u,d,r,i,a,s,c,o);return p===0?n:(l?.add(u),n+p*(f-d))},0),ie=(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.`)},W=(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:new Set,runs:[]};d.push(f);let{start:p}=o,m=p.mode===`absolute`?p.value:r?.freezeStarts[s]??ie(e,s,u),h;switch(o.end.mode){case`dwell`:h=m+o.end.distancePx;break;case`absolute`:{let e=a.absoluteEndLength(s);h=e===null?Math.max(m,o.end.value):m+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 r=P(o.end.clause,o.endTriggerHeight,t);if(o.endTriggerIsSelf){let t=H(e,s),n=N(o.end.clause)-(p.mode===`clause`?p.elementFraction:0),a=e.reduce((r,a,c)=>n===0||a.kind!==`scene`||!t.includes(c)||i&&(i.isBefore(s,c)||V(e,c,o.triggerEnclosedBy,s,i))?r:(f.counted.add(c),r+n*u(c)),0);if(p.mode===`clause`){h=m+Math.max(0,p.anchorOffset-r+a);break}let c=e.reduce((n,r,a)=>a===s||r.kind!==`scene`||t.includes(a)||r.triggerTop+r.triggerHeight>o.triggerTop+.05||i&&(i.isBefore(s,a)||V(e,a,o.triggerEnclosedBy,s,i))?n:(f.counted.add(a),n+u(a)),0);h=Math.max(m,o.triggerTop-r+c+a);break}let c;if(o.end.measureLive)c=n(s);else{let t=o.endTriggerIndex===null?o.end.rawTop:e[o.endTriggerIndex].triggerTop;if(t===null)c=0;else{let n={top:t,fraction:N(o.end.clause),nests:o.endTriggerNests},u=(c,l)=>U(e,a,c,n,t-r,o.endTriggerEnclosedBy,s,o.endTriggerIndex,i,l);c=t+u(l()),f.runs.push(e=>u(e,f.counted))}}let d;if(p.mode===`absolute`)d=p.value;else{let t=(t,n)=>U(e,a,t,{top:o.triggerTop,fraction:p.elementFraction,nests:H(e,s)},o.triggerTop-p.anchorOffset,o.triggerEnclosedBy,s,s,i,n);d=o.triggerTop-p.anchorOffset+t(l()),f.runs.push(e=>t(e,f.counted))}h=m+Math.max(0,c-r-d);break}}let g={freezeStart:m,freezeEnd:h,paddingHeight:Math.max(0,h-m)};return c[s]=g,g});if(o){let e=l();d.forEach(({index:t,counted:n,runs:r})=>{r.forEach(t=>t(e)),o(t,n)})}return f},ae=(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+K(e,n),c=o.triggerTop-o.start.anchorOffset,l=c+K(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=P(o.end.clause,o.endTriggerHeight,r);u=o.end.measureLive?a(t)-n:s((o.endTriggerIsSelf?o.triggerTop:o.endTriggerIndex===null?o.end.rawTop??0:e[o.endTriggerIndex].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}},G=.05,K=(e,t,{countTies:n=!1}={})=>{let r=n?-.05:G,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},q=(e,t)=>t.reduce((t,{freezeStart:n,freezeEnd:r})=>t+Math.min(Math.max(e-n,0),r-n),0),J=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},Y=(e,t)=>{let n=J(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]}},X=(e,t)=>{let n=J(t);return new Set(e.map(e=>n[e])).size<e.length},oe=(e,t,n)=>{let r=e.map(()=>[]);return n.forEach((n,i)=>{let a=e[i],o=(a.end.mode===`clause`&&!a.endTriggerIsSelf?a.endTriggerEnclosedBy:a.triggerEnclosedBy).filter(e=>e!==a.endTriggerIndex);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},Z=(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)<=G;(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}},se=(e,t)=>{let n=e.flatMap(({kind:e},t)=>e===`scene`?[t]:[]),r=n.length>1,i=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=Z(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]??=Z(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(W(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(W(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(()=>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 Y(e,v);if(!r)return null;let t=g(b.lengths,y);return X(n,t)?Y(e,v):X(n,oe(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}}),T=n.map(e=>({freezeStart:C[e][0],freezeEnd:C[e][1]})),E=w.map((t,n)=>t??ae(e,n,T,a));return E.forEach((e,n)=>t.onPlanned(n,e)),E},Q=`--sst-scroll-margin-top-offset`,ce=0,le=typeof CSS<`u`&&typeof CSS.supports==`function`&&CSS.supports(`animation-timeline`,`scroll()`),ue=typeof CSSStyleSheet==`function`&&typeof CSSStyleSheet.prototype.replaceSync==`function`&&typeof document<`u`&&Array.isArray(document.adoptedStyleSheets),de=le&&ue,$=(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(``)},fe=(e,t)=>{let n=`sst${ce++}`,r=!de&&t!==null,i=new WeakMap,a=new Set,o=null,s=null,c=[],l=null,u=()=>{if(!l)return;let e=window.scrollY;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`)})};r&&window.addEventListener(`scroll`,u,{passive:!0});let d=e=>{let t=i.get(e);e.style.scrollMarginTop=t?t.inline:``},f=()=>{o&&=(document.adoptedStyleSheets=document.adoptedStyleSheets.filter(e=>e!==o),null),s?.removeAttribute(`data-${n}`),s=null,c=[],l=null};return{sync(p,m,h){let g=p.filter(e=>e.freezeEnd>e.freezeStart).sort((e,t)=>e.freezeStart-t.freezeStart);if(t===null||!g.length||!m){a.forEach(d),a=new Set,f();return}s!==m&&(s?.removeAttribute(`data-${n}`),s=m,s.setAttribute(`data-${n}`,``)),r?(c=g,l=m,u()):(o||(o=new CSSStyleSheet,document.adoptedStyleSheets=[...document.adoptedStyleSheets,o]),o.replaceSync($(n,g)));let _=Array.from(e.querySelectorAll(t)),v=h(_);_.forEach(e=>{let t=i.get(e);t?a.has(e)&&(e.style.scrollMarginTop=t.inline):i.set(e,{inline:e.style.scrollMarginTop})});let y=g.map((e,t)=>`var(--${n}-c${t}, 0px)`).join(` + `);_.forEach((e,t)=>{let n=parseFloat(getComputedStyle(e).scrollMarginTop)||0,r=0,i=g.map(({freezeStart:e,freezeEnd:i})=>{let a=v[t]-n+r-e-G;return r+=i-e,`clamp(0px, (${a}px - var(${Q}, 0px)) * 1000000, ${i-e}px)`}).join(` + `);e.style.scrollMarginTop=`calc(${n}px + var(${Q}, 0px) + ${y} - (${i}))`});let b=new Set(_);a.forEach(e=>{b.has(e)||d(e)}),a=b},restore(){r&&window.removeEventListener(`scroll`,u),a.forEach(d),a=new Set,f()}}},pe=e=>{for(let t=1;t<e.length;t+=1)if(f(e[t-1].trigger,e[t].trigger)>0)return!0;return!1},me=(e,t)=>{t.sort((e,t)=>f(e.trigger,t.trigger));for(let e of t)e.kind===`cover`&&(e.wrapper=v(e.trigger));let n=e,r=null;for(let i of t){if(i.kind!==`scene`)continue;let t=_(n,n===e);i.container=t.container,i.wrapper=t.wrapper,i.padding=t.padding,n=t.container,r=t.container}return r},he=(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`&&n.wrapper&&y(n.wrapper)}t.forEach(e=>{e.wrapper=null,e.kind===`scene`&&(e.container=null,e.padding=null)})},ge=(e,t,n,a,o,s)=>{if(a===null)return{mode:`auto`};let c=B(a);switch(c.kind){case`dwell`:return{mode:`dwell`,distancePx:Math.max(0,L(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:z(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}}}},_e=(e,t,n,i)=>{let a=B(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:P(a.value,n,i),elementFraction:N(a.value)}}},ve=(e,t,n,r,a)=>{let o=T(n.start),s=n.end===null?null:I(o,T(n.end)),c=d(n.trigger),l=n.endTrigger===n.trigger,u=a.get(n.endTrigger)??null,f=ge(e,t,n,s,r,u),p=_e(n,o,c,t);return{kind:n.kind,start:p,triggerTop:i(n.trigger),triggerHeight:c,triggerEnclosedBy:[...a].filter(([e])=>e.contains(n.trigger)).map(([,e])=>e),wrapperTop:n.wrapper?i(n.wrapper):0,coverTop:n.kind===`cover`?i(n.cover):0,end:f,endTriggerIsSelf:l,endTriggerIndex:u,endTriggerHeight:f.mode===`clause`?d(n.endTrigger):0,endTriggerEnclosedBy:f.mode===`clause`&&!f.measureLive&&!l?[...a].filter(([e])=>e.contains(n.endTrigger)).map(([,e])=>e):[],endTriggerNests:f.mode===`clause`&&!f.measureLive&&!l?[...a].filter(([e])=>e!==n.endTrigger&&n.endTrigger.contains(e)).map(([,e])=>e):[]}},ye=[`trigger`,`start`,`end`,`endTrigger`,`pin`,`pinSpacing`,`anticipatePin`,`pinnedContainer`,`pinReparent`,`pinSpacer`,`pinType`,`horizontal`,`scroller`,`containerAnimation`],be=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)},xe=(e,t,n,r,a)=>{switch(t.kind){case`dwell`:return n+L(t.value,r);case`absolute`:return t.value;case`clause`:return a(e,i(e)-P(t.value,d(e),r))}},Se=(e,t)=>e.some(e=>e.trigger===t);return class{#e;#t=[];#n=[];#r=new WeakMap;#i=!1;#a=!1;#o=null;#s=!1;#c=!1;#l=null;#u=[];#d;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.`)}this.#d=fe(this.#e,r)}#f(){this.#i&&=(he(this.#e,this.#n,this.#o),this.#o=null,!1)}#p(){this.#o=me(this.#e,this.#t),this.#n=[...this.#t],this.#i=!0,this.#a=!1}#m(){this.#c||this.#s||(this.#c=!0,queueMicrotask(()=>{this.#c=!1,!this.#s&&(this.refresh(),typeof this.#l?.refresh==`function`&&this.#l.refresh())}))}#h(e){this.#s||(this.#l=e.constructor)}#g(e){return t=>{this.#h(t);let n=e?.(t);try{this.refresh()}catch(e){queueMicrotask(()=>{throw e})}return n}}#_(){this.#u.forEach(e=>{if(e.outer)return;e.savedPosition=h(e.trigger);let t=b(e.trigger);e.outer=t.outer,e.inner=t.inner})}#v(){let e=this.#u.flatMap(({outer:e,inner:t})=>e&&t?[{outer:e,inner:t,range:t.style.height}]:[]);e.forEach(({outer:e,inner:t})=>{e.style.height=``,t.style.height=``});let t=e.map(({outer:e})=>d(e));e.forEach(({outer:e},n)=>{e.style.height=`${t[n]}px`}),e.forEach(({inner:e,range:t})=>{e.style.height=t})}#y(e){return e.outer?(x(e.outer,e.trigger,e.savedPosition),e.outer=null,e.inner=null,!0):!1}#b(){let e=this.#t.map(e=>e.wrapper).filter(e=>e!==null).map(e=>({wrapper:e,position:e.style.position,top:e.style.top}));return e.forEach(({wrapper:e})=>p(e)),()=>{e.forEach(({wrapper:e,position:t,top:n})=>{e.style.position=t,e.style.top=n})}}#x(){let e=this.#u.filter(e=>e.inner).map(({trigger:e})=>({trigger:e,position:h(e)}));return e.forEach(({trigger:e})=>p(e)),()=>{e.forEach(({trigger:e,position:t})=>g(e,t))}}#S(){let e=this.#b(),t=this.#x();return()=>{t(),e()}}#C(){let e=this.#u.map(e=>({layer:e,position:h(e.trigger),height:e.inner?e.inner.style.height:``}));return e.forEach(({layer:e})=>{p(e.trigger),e.inner&&(e.inner.style.height=``)}),()=>{e.forEach(({layer:e,position:t,height:n})=>{g(e.trigger,t),e.inner&&(e.inner.style.height=n)})}}#w(e){if(!this.#u.length)return;let t=this.#b(),n=this.#C();try{this.#T(e,c())}catch(e){throw n(),e}finally{t()}}#T(e,t){this.#u.forEach(n=>{if(!n.inner)return;let r=T(n.start),a=I(r,T(n.end)),o=B(a);if(o.kind===`max`)throw Error(`StickyScrollTrigger: createStickyPin's end "${a}" uses GSAP's 'max' keyword, which isn't supported here: the pin's own spacer height adds to the document's max scroll position, so it would depend on itself. 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=B(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=P(u.value,c,e),p=(e,t)=>this.#R(e,t),h=xe(n.endTrigger,o,p(n.trigger,s-f),e,p),g=h-(this.#e.contains(n.trigger)?q(h,this.#z()):0)-s+f+c+l,_=t>0?t-s:1/0;m(n.trigger,f),n.inner.style.height=`${Math.max(0,Math.min(g,_))}px`})}#E(e){if(!this.#t.length)return;let t=this.#t.filter(e=>e.wrapper!==null);if(!t.length)return;let n=this.#b(),r=this.#x();try{this.#D(e,t)}catch(e){throw n(),e}finally{r()}}#D(e,t){let n=this.#o?i(this.#o):0,r=new Map;t.forEach((e,t)=>{r.set(e.trigger,t)});let a=t.map((t,n)=>ve(this.#e,e,t,n,r)),o=0,s=()=>se(a,{viewportHeight:e,structureTop:n,documentMaxScroll:o,measureLiveEndTriggerTop:e=>i(t[e].endTrigger),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&&(m(r.wrapper,n.stickyTop),r.kind===`scene`&&r.padding&&n.paddingHeight!==null&&(r.padding.style.height=`${n.paddingHeight}px`))}});s();let c=a.some(e=>e.end.mode===`clause`&&e.end.measureLive),u=a.some(e=>e.end.mode===`max`);u&&(o=l(e)),(c||u)&&s()}refresh(){if(this.#s)return;(this.#a||!this.#i||pe(this.#t))&&(this.#f(),this.#p()),this.#k();try{this.#_(),this.#v()}finally{this.#A()}let e=this.#t.length||this.#u.length?a():0;this.#E(e),this.#w(e),this.#j()}#O(){return this.#t.filter(e=>e.kind===`cover`)}#k(){this.#O().forEach(e=>this.#r.get(e)?.())}#A(){this.#O().forEach(e=>{let t=this.#u.find(({trigger:t})=>t===e.cover);this.#r.set(e,w(t?.outer??e.cover))})}#j(){this.#d.sync(this.#z(),this.#o,e=>{if(!e.length)return[];let t=this.#S(),n=e.map(e=>i(e));return t(),n})}#M(e,t){let n=ye.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.`)}#N(e,t,n){if(Se(e,t))throw Error(n)}#P(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.`)}#F(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.`)}#I(e,t,n){if(this.#s)throw Error(`StickyScrollTrigger: cannot register a new layer after destroy() has been called.`);return this.#N(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.#N(this.#u,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.push(e),this.#a=!0,{...n,trigger:e.trigger,start:()=>e.freezeStart,end:()=>e.freezeEnd||.001,invalidateOnRefresh:n.invalidateOnRefresh??!0,onKill:n=>{this.#h(n);let r=this.#t.indexOf(e);r!==-1&&this.#t.splice(r,1),this.#a=!0,this.#m(),t?.(n)},onRefreshInit:this.#g(n.onRefreshInit)}}createStickyTrigger({trigger:e,start:r=`0 0`,end:i=`100% 0`,endTrigger:a,onKill:o,...s}){this.#M(s,`createStickyTrigger`);let c=t(e,`createStickyTrigger`);this.#P(c,`createStickyTrigger`);let l=n(c,a,`createStickyTrigger`);return this.#I({kind:`scene`,trigger:c,endTrigger:l,container:null,wrapper:null,padding:null,start:r,end: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.#M(l,`createOverlapScroll`);let u=t(e,`createOverlapScroll`);this.#P(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:a,end:o,freezeStart:0,freezeEnd:0,engagedStart:0,engagedEnd:0},m=this.#I(p,e=>{this.#r.get(p)?.(),c?.(e)},l);return this.#r.set(p,w(f)),m}createStickyPin({trigger:e,start:i,top:a,endTrigger:o,end:s=`bottom top`,onKill:c,...l}){if(this.#M(l,`createStickyPin`),this.#s)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.#F(u,`createStickyPin`),this.#N(this.#u,u,`StickyScrollTrigger: ${r(u)} is already registered as a pin trigger.`),this.#N(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:h(u),outer:null,inner:null,start:a===void 0?i??`top top`:be(a),endTrigger:d,end:s};return this.#u.push(f),{...l,trigger:u,onKill:e=>{this.#h(e);let t=this.#u.indexOf(f);t!==-1&&this.#u.splice(t,1),this.#y(f)&&this.#m(),c?.(e)},onRefreshInit:this.#g(l.onRefreshInit)}}resolveScrollPosition(e,n){let r=t(e,`resolveScrollPosition`),i=T(n),o=a(),s=B(i);switch(s.kind){case`max`:return l(o)+z(s.value,o);case`absolute`:return s.value;case`dwell`:case`clause`:return this.#L(r,s.value,o)}}#L(e,t,n){let r=P(t,d(e),n),a=this.#S(),o=i(e)-r;return a(),this.#R(e,o)}#R(e,t){return this.#e.contains(e)?t+K(t,this.#z()):t}#z(){return this.#t.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 o=n.map(e=>e.#x()),s=i(r);return o.forEach(e=>e()),s}createResolvedTrigger({trigger:e,start:r=`top bottom`,end:i=`bottom top`,endTrigger:o,...s}){this.#M(s,`createResolvedTrigger`);let c=t(e,`createResolvedTrigger`),l=n(c,o,`createResolvedTrigger`);return{...s,trigger:c,start:()=>this.resolveScrollPosition(c,r),end:()=>{let e=T(i),t=B(e);return t.kind===`dwell`?this.resolveScrollPosition(c,r)+L(t.value,a()):this.resolveScrollPosition(l,I(r,e))}}}destroy(){this.#s||(this.#s=!0,this.#d.restore(),this.#k(),this.#f(),this.#t.length=0,this.#n=[],this.#u.forEach(e=>this.#y(e)),this.#u.length=0,this.#l=null)}}})();
|
|
8
|
+
var StickyScrollTrigger=(function(){let 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=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,t)=>{e.style.position=`sticky`,e.style.top=`${t}px`},h=e=>({position:e.style.position,top:e.style.top}),g=(e,t)=>{e.style.position=t.position,e.style.top=t.top},_=e=>{let t=e.map(h);return e.forEach(p),()=>e.forEach((e,n)=>g(e,t[n]))},v=(e,t)=>{if(!e.parentNode)throw Error(`StickyScrollTrigger: ${r(e)} is not attached to the document`);let n=document.createElement(`div`),i=document.createElement(`div`),a=document.createElement(`div`);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=document.createElement(`div`);e.style.display=`flow-root`,i.appendChild(e)}return{container:n,wrapper:i,padding:a}},y=e=>{let t=e.parentNode;if(!t)throw Error(`createOverlapScroll: trigger ${r(e)} is not attached to the document`);let n=document.createElement(`div`);for(t.insertBefore(n,t.firstChild);n.nextSibling;){let t=n.nextSibling;if(n.appendChild(t),t===e)break}return n},b=e=>{let t=e.parentNode;if(t){for(;e.firstChild;)t.insertBefore(e.firstChild,e);e.remove()}},x=e=>{if(!e.parentNode)throw Error(`createStickyPin: trigger ${r(e)} is not attached to the document`);let t=document.createElement(`div`),n=document.createElement(`div`);return t.style.display=`flow-root`,e.parentNode.insertBefore(t,e),t.appendChild(n),n.appendChild(e),s.add(n),{outer:t,inner:n}},S=(e,t,n)=>{let r=e.parentNode;g(t,n),r&&r.insertBefore(t,e),e.firstElementChild instanceof HTMLElement&&s.delete(e.firstElementChild),e.remove()},C={position:`relative`,zIndex:`1`},w=new WeakMap,T=e=>{let t=[];for(let n=e;n;n=n.nextElementSibling){if(!(n instanceof HTMLElement))continue;let e=n,r=w.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]=C[t]}),w.set(e,{count:1,applied:n})}t.push(e)}return()=>{t.forEach(e=>{let t=w.get(e);t&&(--t.count,!(t.count>0)&&(t.applied.forEach(t=>{e.style[t]===C[t]&&(e.style[t]=``)}),w.delete(e)))}),t.length=0}},E=()=>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),ee=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},te=(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},ne=e=>[e.transform,e.translate,e.scale,e.rotate].some(e=>e!==void 0&&e!==``&&e!==`none`),re=(e,t)=>{if(!e)return!1;let n=t.get(e);if(n!==void 0)return n;let r=ne(getComputedStyle(e))||re(e.parentElement,t);return t.set(e,r),r},D=e=>![e.overflowX,e.overflowY].every(e=>e===`visible`||e===`clip`),ie=()=>D(getComputedStyle(document.documentElement))&&D(getComputedStyle(document.body)),O=(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`||D(i)||O(n,t);return t.set(n,a),a},ae=(e,t)=>{let n=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=new Map,a=0;for(let t of e)t.isConnected&&!O(t,i)&&(a=Math.max(a,1+r(t.parentElement)));return a},oe=/^-?(?:\d+\.?\d*|\.\d+)(?:e[+-]?\d+)?(px|%)$/i,k=new Set,A=[],j=0,se=!1,M=null,N=`idle`,P=!1,F=null,I=new Set,ce=()=>Array.from(I).some(e=>e.isRefreshing===!0),le=(e,t)=>e.demotable?t<e.lo-j?`before`:t>e.hi+j&&!e.holdsAfter?`after`:`in`:`in`,L=(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`},ue=(e,t)=>{if(e.state===t)return;if(t===`in`){L(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},R=e=>{A.forEach(t=>ue(t,le(t,e)))},de=()=>R(window.scrollY),fe=e=>{e!==se&&(se=e,e?window.addEventListener(`scroll`,de,{passive:!0}):window.removeEventListener(`scroll`,de))},z=()=>{A.forEach(e=>L(e)),A=[],fe(!1)},pe=()=>{let e=M;N===`measuring`&&e!==null&&(N=`restored`,A.length&&R(e))},B=()=>{N=`idle`,M=null,P=!1},me=()=>{try{Se(null)}catch(e){z(),queueMicrotask(()=>{throw e})}},V=()=>{let e=N!==`idle`;B(),e&&U().length&&me()},H=()=>(N===`idle`&&(N=`measuring`,M=window.scrollY,queueMicrotask(V),A.length&&R(0)),{render:pe}),he=e=>{I.has(e)||(e.isRefreshing===!0&&(P=!0),I.add(e),e.addEventListener?.(`refresh`,V),e.addEventListener?.(`refreshInit`,H))},ge=()=>{I.size&&queueMicrotask(()=>{U().length||(I.forEach(e=>{e.removeEventListener?.(`refresh`,V),e.removeEventListener?.(`refreshInit`,H)}),I.clear())})},_e=e=>{let t=new Map,n=e=>e.isConnected&&getComputedStyle(e).position===`sticky`&&!O(e,t);if(F)return Array.from(new Set([...F,...A.map(e=>e.el),...e])).filter(n);let r=Array.from(document.querySelectorAll(`*`)).filter(n);return F=r,queueMicrotask(()=>{F=null}),r},ve=(e,t)=>{let n=A.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 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},ye=(e,t)=>{let n=13,r=Math.floor(e/25);if(r<n||ve(n*25,t)>4)return 325;for(;n<r;){let e=Math.ceil((n+r)/2);ve(e*25,t)<=4?n=e:r=e-1}return n*25},U=()=>{let e=[];return k.forEach(t=>{let n=t.deref();if(!n){k.delete(t);return}let r=n.ownedElements();r.some(e=>e.isConnected)&&e.push({client:n,owned:r})}),e},be=(e,t,n)=>{let r=window.scrollY,i=document.documentElement.clientHeight||window.innerHeight,a=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`||re(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=oe.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}},xe=()=>{z(),B(),ge()},Se=e=>{let t=U();if(!t.length){xe();return}if(e&&he(e),ce()||B(),!I.size||ie()){z();return}let n=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(A.filter(e=>e.state!==`in`).map(e=>e.el));if(r&&ae(n.keys(),i)<7){z();return}let a=_e(n.keys()),o=new Set(a),s=A.filter(e=>e.state!==`in`&&!o.has(e.el));s.filter(e=>!e.el.isConnected).forEach(e=>L(e));let c=s.filter(e=>e.el.isConnected),l=new Map(A.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=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=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));if(p.forEach(e=>{let t=n.get(e.el);e.demotable=t!==void 0&&g.has(t)}),A=p,!p.some(e=>e.demotable)){z();return}let _=p.filter(e=>n.has(e.el)||d.has(e)||e.state!==`in`),v=new Map(_.filter(e=>!n.has(e.el)&&e.state===`in`).map(({el:e})=>[e,e.getAttribute(`style`)])),y=()=>_.forEach(e=>{if(!v.has(e.el)){L(e,!0);return}let t=v.get(e.el);t==null?e.el.removeAttribute(`style`):e.el.setAttribute(`style`,t)});_.forEach(({el:e})=>{e.style.position=`static`});let b=new Set,x;try{x=be(_,n,b)}finally{y()}let{scroll:S,viewportHeight:C,documentHeight:w}=x,T=Math.max(0,w-C);p.forEach(e=>{let t=ee(e.ancestors.map(e=>[e.lo,e.hi])),n=e.naturalTop-e.stickyTop;e.lo=te(t,n,!0),e.hi=te(t,n+e.travel,!1),(b.has(e)||e.ancestors.some(e=>b.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}),j=ye(C,T),R(N===`measuring`?0:(N===`restored`?M:null)??S),fe(!0)},Ce=()=>P&&ce()?H().render:null,we=z,Te=e=>{let t=new Set(e);A=A.filter(e=>!t.has(e.el)||(L(e),!1))},Ee=e=>{k.add(new WeakRef(e))},W=!1,De=()=>{W||(W=!0,queueMicrotask(()=>{W=!1,me()}))},Oe=e=>{k.forEach(t=>{t.deref()===e&&(k.delete(t),Te(e.ownedElements()))}),U().length?De():xe()},G=e=>typeof e==`function`?e():e,ke={top:0,center:.5,bottom:1},K=(e,t,n,r)=>{let i=n===`%`?parseFloat(t)/100*r:parseFloat(t);return e?.startsWith(`-`)?-i:i},Ae=/^(top|center|bottom|[+-]?(?:\d+(?:\.\d*)?|\.\d+))?(%|px)?(?:([+-]=?)(\d+(?:\.\d*)?|\.\d+)(%|px)?)?$/,q=(e,t)=>{let n=Ae.exec(e);if(!n||!n[1]&&!n[3])throw Re.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 ke,l=i===`%`;return{fraction:c?ke[r]:l?parseFloat(r)/100:0,offsetPx:(!c&&!l&&r!==void 0?parseFloat(r):0)+(a?K(a,o,s,t):0)}},je=e=>typeof e==`number`||e.trim()!==``&&!Number.isNaN(Number(e)),Me=e=>typeof e==`number`?e:Number(e),Ne=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}"?`:``))},Pe=e=>{let t=e.trim();return Ne(t),t.split(/\s+/)},J=(e,t)=>{let{fraction:n,offsetPx:r}=q(e,t);return t*n+r},Fe=(e,t)=>J(Pe(e)[0],t),Y=e=>Fe(e,1)-Fe(e,0),X=(e,t,n)=>{let[r,i=`top`]=Pe(e);return J(i,n)-J(r,t)},Ie=/^\+=(\d+(?:\.\d*)?|\.\d+)(%|px)?$/,Le=e=>typeof e==`string`&&Ie.test(e.trim()),Z=(e,t)=>{if(typeof t!=`string`)return t;let n=t.trim();if(!n.startsWith(`+=`)||!/\s/.test(n))return t;let r=G(e);if(typeof r!=`string`)return t;let[i]=Pe(r);try{q(i,0)}catch(e){if(!je(r))throw e;return t}if(q(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},Q=(e,t)=>{let n=Ie.exec(String(e).trim());if(!n)throw Error(`StickyScrollTrigger: unsupported end format "${e}"`);let[,r,i]=n;return K(void 0,r,i,t)},Re=/^max(?:([+-]=)(\d+(?:\.\d*)?|\.\d+)(%|px)?)?$/,ze=e=>typeof e==`string`&&Re.test(e.trim()),Be=(e,t)=>{let n=Re.exec(e.trim());if(!n)throw Error(`StickyScrollTrigger: unsupported max-position format "${e}"`);let[,r,i,a]=n;return r?K(r,i,a,t):0},$=e=>typeof e==`number`?{kind:`absolute`,value:e}:Le(e)?{kind:`dwell`,value:e}:ze(e)?{kind:`max`,value:e}:je(e)?{kind:`absolute`,value:Me(e)}:{kind:`clause`,value:e},Ve=(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)),He=(e,t)=>e.flatMap(({triggerEnclosedBy:e},n)=>n!==t&&e.includes(t)?[n]:[]),Ue=({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&&Ve(e,i,c,l,n)?0:o.nests.includes(i)?o.fraction:+(u.triggerTop+u.triggerHeight<=o.top+.05)},We=(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=Ue(e,a,o,n,r);return u===0?t:(i?.add(a),t+u*(s-o))},0),Ge=(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.`)},Ke=(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:new Set,runs:[]};d.push(f);let p={measurements:e,world:a,order:i,ownIndex:s},m=(e,t)=>{let n=(n,r)=>We(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]??Ge(e,s,u),_=t=>i!==null&&(i.isBefore(s,t)||Ve(e,t,o.triggerEnclosedBy,s,i)),v=(t,n)=>{let r=He(e,s),i=Y(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:Y(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:He(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},qe=(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+Ye(e,n),c=o.triggerTop-o.start.anchorOffset,l=c+Ye(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}},Je=.05,Ye=(e,t,{countTies:n=!1}={})=>{let r=n?-.05:Je,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},Xe=(e,t)=>t.reduce((t,{freezeStart:n,freezeEnd:r})=>t+Math.min(Math.max(e-n,0),r-n),0),Ze=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},Qe=(e,t)=>{let n=Ze(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]}},$e=(e,t)=>{let n=Ze(t);return new Set(e.map(e=>n[e])).size<e.length},et=(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},tt=(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)<=Je;(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}},nt=(e,t)=>{let n=e.flatMap(({kind:e},t)=>e===`scene`?[t]:[]),r=n.length>1,i=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=tt(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]??=tt(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(Ke(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(Ke(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(()=>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 Qe(e,v);if(!r)return null;let t=g(b.lengths,y);return $e(n,t)?Qe(e,v):$e(n,et(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}}),T=n.map(e=>({freezeStart:C[e][0],freezeEnd:C[e][1]})),E=w.map((t,n)=>t??qe(e,n,T,a));return E.forEach((e,n)=>t.onPlanned(n,e)),E},rt=`--sst-scroll-margin-top-offset`,it=0,at=typeof CSS<`u`&&typeof CSS.supports==`function`&&CSS.supports(`animation-timeline`,`scroll()`),ot=typeof CSSStyleSheet==`function`&&typeof CSSStyleSheet.prototype.replaceSync==`function`&&typeof document<`u`&&Array.isArray(document.adoptedStyleSheets),st=at&&ot,ct=(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(``)},lt=(e,t)=>{let n=`sst${it++}`,r=!st&&t!==null,i=new WeakMap,a=new Set,o=null,s=null,c=[],l=null,u=()=>{if(!l)return;let e=window.scrollY;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`)})};r&&window.addEventListener(`scroll`,u,{passive:!0});let d=e=>{let t=i.get(e);e.style.scrollMarginTop=t?t.inline:``},f=()=>{o&&=(document.adoptedStyleSheets=document.adoptedStyleSheets.filter(e=>e!==o),null),s?.removeAttribute(`data-${n}`),s=null,c=[],l=null},p=(e,t)=>{s!==t&&(s?.removeAttribute(`data-${n}`),s=t,s.setAttribute(`data-${n}`,``)),r?(c=e,l=t,u()):(o||(o=new CSSStyleSheet,document.adoptedStyleSheets=[...document.adoptedStyleSheets,o]),o.replaceSync(ct(n,e)))},m=()=>{a.forEach(d),a=new Set,f()};return{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){m();return}p(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 f=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-Je;return r+=i-e,`clamp(0px, (${a}px - var(${rt}, 0px)) * 1000000, ${i-e}px)`}).join(` + `);e.style.scrollMarginTop=`calc(${n}px + var(${rt}, 0px) + ${f} - (${i}))`});let h=new Set(l);a.forEach(e=>{h.has(e)||d(e)}),a=h},restore(){r&&window.removeEventListener(`scroll`,u),m()}}},ut=e=>{for(let t=1;t<e.length;t+=1)if(f(e[t-1].trigger,e[t].trigger)>0)return!0;return!1},dt=(e,t)=>{t.sort((e,t)=>f(e.trigger,t.trigger));for(let e of t)e.kind===`cover`&&(e.wrapper=y(e.trigger));let n=e,r=null;for(let i of t){if(i.kind!==`scene`)continue;let t=v(n,n===e);i.container=t.container,i.wrapper=t.wrapper,i.padding=t.padding,n=t.container,r=t.container}return r},ft=(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`&&n.wrapper&&b(n.wrapper)}t.forEach(e=>{e.wrapper=null,e.kind===`scene`&&(e.container=null,e.padding=null)})},pt=(e,t,n,a,o,s)=>{if(a===null)return{mode:`auto`};let c=$(a);switch(c.kind){case`dwell`:return{mode:`dwell`,distancePx:Math.max(0,Q(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:Be(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}}}},mt=(e,t,n,i)=>{let a=$(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:Y(a.value)}}},ht=(e,t,n,r,a)=>{let o=G(n.start),s=n.end===null?null:Z(o,G(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=pt(e,t,n,s,r,f),m=p.mode===`clause`&&!p.measureLive&&!l,h=mt(n,o,c,t);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)):[]}}},gt=[`trigger`,`start`,`end`,`endTrigger`,`pin`,`pinSpacing`,`anticipatePin`,`pinnedContainer`,`pinReparent`,`pinSpacer`,`pinType`,`horizontal`,`scroller`,`containerAnimation`],_t=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)},vt=(e,t,n,r,a)=>{switch(t.kind){case`dwell`:return n+Q(t.value,r);case`absolute`:return t.value;case`clause`:return a(e,i(e)-X(t.value,d(e),r))}},yt=(e,t)=>{let n=e.indexOf(t);n!==-1&&e.splice(n,1)},bt=(e,t)=>e.some(e=>e.trigger===t);return class{#e;#t=[];#n=[];#r=new WeakMap;#i=!1;#a=!1;#o=null;#s=!1;#c=!1;#l=null;#u=[];#d;#f=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.#d=lt(this.#e,r),(i===`always`||i===`auto`&&E())&&(this.#f={mode:i,ownedElements:()=>this.#p()},Ee(this.#f))}#p(){return[...this.#n.flatMap(e=>e.wrapper?[e.wrapper]:[]),...this.#m()]}#m(){return this.#u.flatMap(({trigger:e,inner:t})=>t?[e]:[])}#h(){this.#i&&=(ft(this.#e,this.#n,this.#o),this.#o=null,!1)}#g(){this.#o=dt(this.#e,this.#t),this.#n=[...this.#t],this.#i=!0,this.#a=!1}#_(){this.#c||this.#s||(this.#c=!0,queueMicrotask(()=>{this.#c=!1,!this.#s&&(this.refresh(),typeof this.#l?.refresh==`function`&&this.#l.refresh())}))}#v(e){this.#s||(this.#l=e.constructor)}#y(e){return t=>{this.#v(t);let n=e?.(t);try{this.refresh()}catch(e){queueMicrotask(()=>{throw e})}let r=Ce();return r?{render:e=>{n?.render?.(e),r()}}:n}}#b(){this.#u.forEach(e=>{if(e.outer)return;e.savedPosition=h(e.trigger);let t=x(e.trigger);e.outer=t.outer,e.inner=t.inner})}#x(){let e=this.#u.flatMap(({outer:e,inner:t})=>e&&t?[{outer:e,inner:t,range:t.style.height}]:[]);e.forEach(({outer:e,inner:t})=>{e.style.height=``,t.style.height=``});let t=e.map(({outer:e})=>d(e));e.forEach(({outer:e},n)=>{e.style.height=`${t[n]}px`}),e.forEach(({inner:e,range:t})=>{e.style.height=t})}#S(e){return e.outer?(Te([e.trigger]),S(e.outer,e.trigger,e.savedPosition),e.outer=null,e.inner=null,!0):!1}#C(){return _(this.#t.flatMap(({wrapper:e})=>e?[e]:[]))}#w(){return _(this.#m())}#T(){let e=this.#C(),t=this.#w();return()=>{t(),e()}}#E(){let e=this.#u.map(e=>({layer:e,position:h(e.trigger),height:e.inner?e.inner.style.height:``}));return e.forEach(({layer:e})=>{p(e.trigger),e.inner&&(e.inner.style.height=``)}),()=>{e.forEach(({layer:e,position:t,height:n})=>{g(e.trigger,t),e.inner&&(e.inner.style.height=n)})}}#D(e){if(!this.#u.length)return;let t=this.#C(),n=this.#E();try{this.#O(e,c())}catch(e){throw n(),e}finally{t()}}#O(e,t){this.#u.forEach(n=>{if(!n.inner)return;let r=G(n.start),a=Z(r,G(n.end)),o=$(a);if(o.kind===`max`)throw Error(`StickyScrollTrigger: createStickyPin's end "${a}" uses GSAP's 'max' keyword, which isn't supported here: the pin's own spacer height adds to the document's max scroll position, so it would depend on itself. 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=$(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=X(u.value,c,e),p=(e,t)=>this.#H(e,t),h=vt(n.endTrigger,o,p(n.trigger,s-f),e,p),g=h-(this.#e.contains(n.trigger)?Xe(h,this.#U()):0)-s+f+c+l,_=t>0?t-s:1/0;m(n.trigger,f),n.inner.style.height=`${Math.max(0,Math.min(g,_))}px`})}#k(e){if(!this.#t.length)return;let t=this.#t.filter(e=>e.wrapper!==null);if(!t.length)return;let n=this.#C(),r=this.#w();try{this.#A(e,t)}catch(e){throw n(),e}finally{r()}}#A(e,t){let n=this.#o?i(this.#o):0,r=new Map;t.forEach((e,t)=>{r.set(e.trigger,t)});let a=t.map((t,n)=>ht(this.#e,e,t,n,r)),o=0,s=()=>nt(a,{viewportHeight:e,structureTop:n,documentMaxScroll:o,measureLiveEndTriggerTop:e=>i(t[e].endTrigger),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&&(m(r.wrapper,n.stickyTop),r.kind===`scene`&&r.padding&&n.paddingHeight!==null&&(r.padding.style.height=`${n.paddingHeight}px`))}});s();let c=a.some(e=>e.end.mode===`clause`&&e.end.measureLive),u=a.some(e=>e.end.mode===`max`);u&&(o=l(e)),(c||u)&&s()}refresh(){if(this.#s)return;let e=null;try{this.#j()}catch(t){e={error:t}}try{Se(this.#l)}catch(e){we(),queueMicrotask(()=>{throw e})}if(e)throw e.error}#j(){(this.#a||!this.#i||ut(this.#t))&&(this.#h(),this.#g()),this.#N();try{this.#b(),this.#x()}finally{this.#P()}let e=this.#t.length||this.#u.length?a():0;this.#k(e),this.#D(e),this.#F()}#M(){return this.#t.filter(e=>e.kind===`cover`)}#N(){this.#M().forEach(e=>this.#r.get(e)?.())}#P(){this.#M().forEach(e=>{let t=this.#u.find(({trigger:t})=>t===e.cover);this.#r.set(e,T(t?.outer??e.cover))})}#F(){this.#d.sync(this.#U(),this.#o,e=>{if(!e.length)return[];let t=this.#T(),n=e.map(e=>i(e));return t(),n})}#I(e,t){let n=gt.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.`)}#L(e,t,n){if(bt(e,t))throw Error(n)}#R(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.`)}#z(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.`)}#B(e,t,n){if(this.#s)throw Error(`StickyScrollTrigger: cannot register a new layer after destroy() has been called.`);return this.#L(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.#L(this.#u,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.push(e),this.#a=!0,{...n,trigger:e.trigger,start:()=>e.freezeStart,end:()=>e.freezeEnd||.001,invalidateOnRefresh:n.invalidateOnRefresh??!0,onKill:n=>{this.#v(n),yt(this.#t,e),this.#a=!0,this.#_(),t?.(n)},onRefreshInit:this.#y(n.onRefreshInit)}}createStickyTrigger({trigger:e,start:r=`0 0`,end:i=`100% 0`,endTrigger:a,onKill:o,...s}){this.#I(s,`createStickyTrigger`);let c=t(e,`createStickyTrigger`);this.#R(c,`createStickyTrigger`);let l=n(c,a,`createStickyTrigger`);return this.#B({kind:`scene`,trigger:c,endTrigger:l,container:null,wrapper:null,padding:null,start:r,end: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.#I(l,`createOverlapScroll`);let u=t(e,`createOverlapScroll`);this.#R(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:a,end:o,freezeStart:0,freezeEnd:0,engagedStart:0,engagedEnd:0},m=this.#B(p,e=>{this.#r.get(p)?.(),c?.(e)},l);return this.#r.set(p,T(f)),m}createStickyPin({trigger:e,start:i,top:a,endTrigger:o,end:s=`bottom top`,onKill:c,...l}){if(this.#I(l,`createStickyPin`),this.#s)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.#z(u,`createStickyPin`),this.#L(this.#u,u,`StickyScrollTrigger: ${r(u)} is already registered as a pin trigger.`),this.#L(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:h(u),outer:null,inner:null,start:a===void 0?i??`top top`:_t(a),endTrigger:d,end:s};return this.#u.push(f),{...l,trigger:u,onKill:e=>{this.#v(e),yt(this.#u,f),this.#S(f)&&this.#_(),c?.(e)},onRefreshInit:this.#y(l.onRefreshInit)}}resolveScrollPosition(e,n){let r=t(e,`resolveScrollPosition`),i=G(n),o=a(),s=$(i);switch(s.kind){case`max`:return l(o)+Be(s.value,o);case`absolute`:return s.value;case`dwell`:case`clause`:return this.#V(r,s.value,o)}}#V(e,t,n){let r=X(t,d(e),n),a=this.#T(),o=i(e)-r;return a(),this.#H(e,o)}#H(e,t){return this.#e.contains(e)?t+Ye(t,this.#U()):t}#U(){return this.#t.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 o=n.map(e=>e.#w()),s=i(r);return o.forEach(e=>e()),s}createResolvedTrigger({trigger:e,start:r=`top bottom`,end:i=`bottom top`,endTrigger:o,...s}){this.#I(s,`createResolvedTrigger`);let c=t(e,`createResolvedTrigger`),l=n(c,o,`createResolvedTrigger`);return{...s,trigger:c,start:()=>this.resolveScrollPosition(c,r),end:()=>{let e=G(i),t=$(e);return t.kind===`dwell`?this.resolveScrollPosition(c,r)+Q(t.value,a()):this.resolveScrollPosition(l,Z(r,e))}}}destroy(){this.#s||(this.#s=!0,Oe(this.#f),this.#d.restore(),this.#N(),this.#h(),this.#t.length=0,this.#n=[],this.#u.forEach(e=>this.#S(e)),this.#u.length=0,this.#l=null)}}})();
|